-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support #[macro_use]
on macro-expanded crates
#34032
Conversation
cc @durka |
1b05450
to
38166c8
Compare
@@ -925,4 +940,8 @@ impl SyntaxEnv { | |||
let last_chain_index = self.chain.len() - 1; | |||
&mut self.chain[last_chain_index].info | |||
} | |||
|
|||
pub fn is_crate_root(&mut self) -> bool { | |||
self.chain.len() == 2 |
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.
Huh? Why 2? This probably needs a comment. :d
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.
Done.
(Otherwise: 👍 💯) |
f953a79
to
acbff87
Compare
@bors: r+ |
📌 Commit acbff87 has been approved by |
🔒 Merge conflict |
☔ The latest upstream changes (presumably #34010) made this pull request unmergeable. Please resolve the merge conflicts. |
acbff87
to
dbf0326
Compare
Rebased. @bors r=nrc |
📌 Commit dbf0326 has been approved by |
Support `#[macro_use]` on macro-expanded crates This PR loads macros from `#[macro_use]` crates during expansion so that - macro-expanded `#[macro_use]` crates work (fixes #33936, fixes #28071), and - macros imported from crates have the same scope as macros imported from modules. This is a [breaking-change]. For example, this will break: ```rust macro_rules! m { () => { #[macro_use(foo)] extern crate core; } //~ ERROR imported macro not found } m!(); ``` Also, this will break: ```rust macro_rules! try { () => {} } // #[macro_use] mod bar { macro_rules! try { ... } } //< ... just like this would ... fn main() { try!(); } //< ... making this an error ``` r? @nrc
Added |
This PR loads macros from
#[macro_use]
crates during expansion so that#[macro_use]
crates work (fixes#[macro_use]
does not work on macro-expandedextern crate
s #33936, fixesinclude!
ed files are unable to #[macro_use] #28071), andmacros imported from crates have the same scope as macros imported from modules.(EDIT: reverted in Revert a change in the scope of macros imported from crates to fix a regression #34239)
This is a [breaking-change]. For example, this will break:
Also, this will break:r? @nrc