-
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: Fix proc_macro expansions on trait methods #44089
Conversation
r? @nrc |
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_resolve/macros.rs
Outdated
@@ -402,7 +402,7 @@ impl<'a> Resolver<'a> { | |||
let ast::Path { ref segments, span } = *path; | |||
let path: Vec<_> = segments.iter().map(|seg| respan(seg.span, seg.identifier)).collect(); | |||
let invocation = self.invocations[&scope]; | |||
self.current_module = invocation.module.get(); | |||
self.current_module = self.module_map[&invocation.module.get().normal_ancestor_id]; |
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.
Tests are failing; this should be:
let module = invocation.module.get();
self.current_module = if module.is_trait() { module.parent.unwrap() } else { module };
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.
Updated!
This commit fixes procedural macro attributes being attached to trait methods, ensuring that they get resolved and expanded as other procedural macro attributes. The bug here was that `current_module` on the resolver was accidentally set to be a trait when it's otherwise only ever expecting a `mod`/block module. The actual fix here came from @jseyfried, I'm just helping to land it in the compiler! Closes rust-lang#42493
19e85c7
to
ce322ee
Compare
@bors: r+ |
📌 Commit ce322ee has been approved by |
⌛ Testing commit ce322ee with merge 8f3556f704699e504138184f1e4428bd512014ff... |
💔 Test failed - status-travis |
rustc: Fix proc_macro expansions on trait methods This commit fixes procedural macro attributes being attached to trait methods, ensuring that they get resolved and expanded as other procedural macro attributes. The bug here was that `current_module` on the resolver was accidentally set to be a trait when it's otherwise only ever expecting a `mod`/block module. The actual fix here came from @jseyfried, I'm just helping to land it in the compiler! Closes rust-lang#42493
This commit fixes procedural macro attributes being attached to trait methods,
ensuring that they get resolved and expanded as other procedural macro
attributes. The bug here was that
current_module
on the resolver wasaccidentally set to be a trait when it's otherwise only ever expecting a
mod
/block module. The actual fix here came from @jseyfried, I'm just helpingto land it in the compiler!
Closes #42493