diff options
| author | bors <bors@rust-lang.org> | 2016-06-22 21:11:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-22 21:11:27 -0700 |
| commit | 4960f2f9074d0d0f9de80b39f0b0ded6547e2ad8 (patch) | |
| tree | 36dce8fb815e3a389fd7afff4ae501c8aed73d7e /src/libsyntax/parse/parser.rs | |
| parent | 6dcc2c1dee3b58afd44665d1df4a248bdd04cce5 (diff) | |
| parent | eef8485f5f707fbe0143d0f7c64aefceba6900d9 (diff) | |
| download | rust-4960f2f9074d0d0f9de80b39f0b0ded6547e2ad8.tar.gz rust-4960f2f9074d0d0f9de80b39f0b0ded6547e2ad8.zip | |
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
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
0 files changed, 0 insertions, 0 deletions
