Uh oh!
There was an error while loading. Please reload this page.
Fix macro hygiene bug - #32923
Merged
Merged
Conversation
Closed
jseyfried
commented
Apr 14, 2016
ContributorAuthor
This could use a crater run (cf. discussion in #32922). |
alexcrichton
commented
Apr 14, 2016
Member
Starting a crater run |
alexcrichton
commented
Apr 15, 2016
Member
Crater reports one regression, but it looks spurious, so essentially nothing from crater. |
jseyfried
commented
Apr 15, 2016
ContributorAuthor
Great, thanks! |
nrc
commented
Apr 15, 2016
Member
Could you add some of the tests from #31856 please? r+ with that |
jseyfried
commented
Apr 15, 2016
ContributorAuthor
nrc
commented
Apr 15, 2016
Member
@bors: r+ |
bors
commented
Apr 15, 2016
Collaborator
📌 Commit ca1d29c has been approved by |
Manishearth added a commit
to Manishearth/rust
that referenced
this pull request
Apr 15, 2016
Fix macro hygiene bug This fixesrust-lang#32922 (EDIT: and fixesrust-lang#31856), macro hygiene bugs. It is a [breaking-change]. For example, the following would break: ```rust fn main() { let x = true; macro_rules! foo { () => { let x = 0; macro_rules! bar { () => {x} } let _: bool = bar!(); //^ `bar!()` used to resolve the first `x` (a bool), //| but will now resolve to the second x (an i32). }} foo! {}; } ``` r? @nrc
jseyfried
commented
Jun 2, 2016
ContributorAuthor
Fixes #10681. |
jseyfried
commented
Jun 9, 2016
ContributorAuthor
Fixes #26223. |
bors added a commit
that referenced
this pull request
Jun 23, 2016
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
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes#32922 (EDIT: also #31856, #10681, and #26223), macro hygiene bugs.
It is a [breaking-change]. For example, the following would break:
r? @nrc