Skip to content
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

Merged
merged 1 commit into from
Aug 31, 2017

Conversation

alexcrichton
Copy link
Member

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 #42493

@alexcrichton
Copy link
Member Author

r? @nrc

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive assigned nrc and unassigned pnkfelix Aug 25, 2017
@@ -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];
Copy link
Contributor

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 };

Copy link
Member Author

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
@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2017
@nrc
Copy link
Member

nrc commented Aug 29, 2017

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 29, 2017

📌 Commit ce322ee has been approved by nrc

@bors
Copy link
Contributor

bors commented Aug 29, 2017

⌛ Testing commit ce322ee with merge 8f3556f704699e504138184f1e4428bd512014ff...

@bors
Copy link
Contributor

bors commented Aug 29, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member Author

@arielb1 arielb1 added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 29, 2017
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Aug 30, 2017
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
bors added a commit that referenced this pull request Aug 31, 2017
Rollup of 8 pull requests

- Successful merges: #44044, #44089, #44116, #44125, #44154, #44157, #44160, #44172
- Failed merges: #44162
@bors bors merged commit ce322ee into rust-lang:master Aug 31, 2017
@alexcrichton alexcrichton deleted the trait-proc-macro branch September 1, 2017 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[proc_macro_attribute] doesn't work on trait methods
8 participants