-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc: Tweak expansion of #[proc_macro] for 2018 #52326
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
a06f8a7
to
a67ba36
Compare
r? @nrc cc @petrochenkov (not directly related to macros 1.2, but you probably want to be aware of this) |
@@ -385,9 +389,21 @@ fn mk_registrar(cx: &mut ExtCtxt, | |||
let register_custom_derive = Ident::from_str("register_custom_derive"); | |||
let register_attr_proc_macro = Ident::from_str("register_attr_proc_macro"); | |||
let register_bang_proc_macro = Ident::from_str("register_bang_proc_macro"); | |||
let crate_kw = Ident::with_empty_ctxt(keywords::Crate.name()); | |||
let use_crate_kw = match cx.ecfg.features { |
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.
Can't we always generate crate::proc_macro_fn
regardless of editions and enabled features?
The whole registrar code is under allow_internal_unstable: true
span anyway.
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 thought so! I originally did that but it generated feature errors :(
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.
That's because the path spans are set to cd.span
/ca.span
/cm.span
and not span
.
You can use cd.span.with_ctxt(span.ctxt())
to keep the sane locations, but apply stability hygiene.
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.
Worked like a charm!
The syntactical expansion of `#[proc_macro]` and related attributes currently contains absolute paths which conflicts with a lint for the 2018 edition, causing issues like rust-lang#52214. This commit puts a band-aid on the issue by ensuring that procedural macros can also migrate to the 2018 edition for now by tweaking the expansion based on what features are activated. A more long-term solution would probably tweak the edition hygiene of spans, but this should do the trick for now. Closes rust-lang#52214
a67ba36
to
94c9ea4
Compare
@bors r+ |
📌 Commit 94c9ea4 has been approved by |
⌛ Testing commit 94c9ea4 with merge 6241dcf5557f9f4d7481205581d4500d11e29230... |
💔 Test failed - status-appveyor |
…henkov rustc: Tweak expansion of #[proc_macro] for 2018 The syntactical expansion of `#[proc_macro]` and related attributes currently contains absolute paths which conflicts with a lint for the 2018 edition, causing issues like #52214. This commit puts a band-aid on the issue by ensuring that procedural macros can also migrate to the 2018 edition for now by tweaking the expansion based on what features are activated. A more long-term solution would probably tweak the edition hygiene of spans, but this should do the trick for now. Closes #52214
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
⌛ Testing commit 94c9ea4 with merge 253a01c41e1a51b368699199a158bb9eb4dd70c6... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
…henkov rustc: Tweak expansion of #[proc_macro] for 2018 The syntactical expansion of `#[proc_macro]` and related attributes currently contains absolute paths which conflicts with a lint for the 2018 edition, causing issues like #52214. This commit puts a band-aid on the issue by ensuring that procedural macros can also migrate to the 2018 edition for now by tweaking the expansion based on what features are activated. A more long-term solution would probably tweak the edition hygiene of spans, but this should do the trick for now. Closes #52214
☀️ Test successful - status-appveyor, status-travis |
The syntactical expansion of
#[proc_macro]
and related attributes currentlycontains absolute paths which conflicts with a lint for the 2018 edition,
causing issues like #52214. This commit puts a band-aid on the issue by ensuring
that procedural macros can also migrate to the 2018 edition for now by tweaking
the expansion based on what features are activated. A more long-term solution
would probably tweak the edition hygiene of spans, but this should do the trick
for now.
Closes #52214