Motivation
rocket_codegen currently uses Rust's plugin system, which is slated for future removal and is a leading cause of breakage on nightly Rust. Rocket should move to implementing its code generation through proc_macro and related features for better stability guarantees.
Related issues
Questions/Concerns
- Forward compatibility, including everything to do with possible changes to feature gates, hygiene, and editions.
- Hygiene
Progress
Attribute macros:
Custom derives:
Bang macros:
Upstream:
Required rustc Features
These unstable features will need to be used by Rocket's proc_macro crate.
proc_macro_diagnostic, proc_macro_span. Allows Rocket to provide useful error messages from macros.
These unstable features will need to be used by application crates that use Rocket's macros.
proc_macro_hygiene. For macros that expand to non-items or macro definitions, including routes!, catchers!, and uri!, and #[route].
decl_macro, for #[route].
Testing
- All existing tests for attribute syntax, etc.
- Verify that macros work via all applicable import mechanisms: macro_use (
#[macro_use] extern crate rocket;), use_extern_macros (use rocket::macro), and proc_macro_path_invoc (#[derive(rocket::macro)], #[rocket::macro], or rocket::macro!()), and any others missing from this list. Ensure these cases are enough to cover compatibility with consumer crates that target the 2018 edition as well.
Motivation
rocket_codegencurrently uses Rust'spluginsystem, which is slated for future removal and is a leading cause of breakage on nightly Rust. Rocket should move to implementing its code generation throughproc_macroand related features for better stability guarantees.Related issues
quote_macros #678: Stop using the quote_ macros. This conversion process supersedes that issue.proc_macrotracking issueproc_macro_expansion feature gates asproc_macro_hygienerust-lang/rust#52121: merge severalproc_macrofeatures asproc_macro_hygieneQuestions/Concerns
Progress
Attribute macros:
routeand its variants (get,put,post,delete,head,patch,options)catchCustom derives:
derive(FromForm)derive(FromFormValue)derive(Responder)derive(UriDisplay)Bang macros:
routes!: Reimplement routes! and catchers! as proc_macros #680catchers!: PR: Reimplement routes! and catchers! as proc_macros #680uri!rocket_internal_uri!(some remaining work on the diagnostics)Upstream:
Required rustc Features
These unstable features will need to be used by Rocket's proc_macro crate.
proc_macro_diagnostic,proc_macro_span. Allows Rocket to provide useful error messages from macros.These unstable features will need to be used by application crates that use Rocket's macros.
proc_macro_hygiene. For macros that expand to non-items or macro definitions, includingroutes!,catchers!, anduri!, and#[route].decl_macro, for#[route].Testing
#[macro_use] extern crate rocket;), use_extern_macros (use rocket::macro), and proc_macro_path_invoc (#[derive(rocket::macro)],#[rocket::macro], orrocket::macro!()), and any others missing from this list. Ensure these cases are enough to cover compatibility with consumer crates that target the 2018 edition as well.