about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-06-22 21:11:27 -0700
committerGitHub <noreply@github.com>2016-06-22 21:11:27 -0700
commit4960f2f9074d0d0f9de80b39f0b0ded6547e2ad8 (patch)
tree36dce8fb815e3a389fd7afff4ae501c8aed73d7e /src/libsyntax/parse/parser.rs
parent6dcc2c1dee3b58afd44665d1df4a248bdd04cce5 (diff)
parenteef8485f5f707fbe0143d0f7c64aefceba6900d9 (diff)
downloadrust-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