-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement routes! and catchers! as proc_macros #680
Conversation
link_flag("-L", "crate", &[]), | ||
link_flag("-L", "dependency", &["deps"]), | ||
extern_dep("rocket_codegen", Kind::Dynamic).expect("find codegen dep"), | ||
extern_dep("rocket", Kind::Static).expect("find core dep") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should rocket_codegen_next
go in this list as well?
let mut paths = parser.parse_sep(Seperator::Comma, |p| { | ||
p.parse::<Path>() | ||
})?; | ||
parser.eof()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing for eof()
is necessary, otherwise something like routes![a, b c]
will be accepted and parse as only a,b
. The compiler plugin macro says it expected ,
, ::
, or <eof>
. This proc_macro currently just says expected eof
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try replacing the error message with a better one, like "expected paths separated by commas".
5f88331
to
982d1d6
Compare
c600d9b
to
aea8de5
Compare
As discussed in IRC, it would be nice if users didn't need to import these macros just like today. Current situation: proc_macro situation: 2018 crates: Proposed design, assuming this all works:
One of Note that attribute proc_macros and proc_macro derives are not covered above. They are in a similar situation as far as imports go, but a macro_rules workaround can't be used in this situation. Derives appear to be covered by |
74dc968
to
d008eab
Compare
Now implements the following variant of the above design:
My plan is to investigate the use of EDIT: proc_macro_hack looks undesirable because it goes through strings, discarding all useful span information. |
433feb3
to
0902910
Compare
a29c47a
to
ff69434
Compare
…rnal; add macro_rules! wrappers
…to be listed in the manifest
ff69434
to
f500547
Compare
Merged in 8e77961. Woo! |
What the title says. Also adds compiletest to the codegen_next crate and updates all examples and tests to properly import the macros.
Unfortunately, at present
#![feature(proc_macro_non_items)]
is required on downstream crates. They are also imported withuse
like items are instead of with#[macro_use]
, which makes for a noisy commit.This branch does not currently move any of the associated documentation.