-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #34374 - jseyfried:fix_hygiene_bug, r=nrc
Fix macro hygiene regression The regression was caused by #32923, which is currently in beta. The following is an example of regressed code: ```rust fn main() { let x = 0; macro_rules! foo { () => { println!("{}", x); // prints `0` on stable and after this PR, prints `1` on beta and nightly } } let x = 1; foo!(); } ``` For code to regress, the following is necessary (but not sufficient): - There must be a local variable before a macro in a block, and the macro must use the variable. - There must be a second local variable with the same name after the macro. - The macro must be invoked in a statement position after the second local variable. For example, if the `let x = 0;` from the breaking example were commented out, it would (correctly) not compile on beta/nightly. If the semicolon were removed from `foo!();`, it would (correctly) print `0` on beta and nightly. r? @nrc
- Loading branch information
Showing
3 changed files
with
163 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.