librustc: Fix the issue with labels shadowing variable names by making
the leading quote part of the identifier for the purposes of hygiene. This adopts @jbclements' solution to #14539. I'm not sure if this is a breaking change or not. Closes #12512. [breaking-change]
This commit is contained in:
parent
e7f11f20e5
commit
2ed4734873
17 changed files with 159 additions and 89 deletions
|
|
@ -15,5 +15,5 @@ macro_rules! foo {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
'x: loop { foo!() } //~ ERROR use of undeclared label `x`
|
||||
'x: loop { foo!() } //~ ERROR use of undeclared label `'x`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ macro_rules! foo {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
foo!(break 'x); //~ ERROR use of undeclared label `x`
|
||||
foo!(break 'x); //~ ERROR use of undeclared label `'x`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ macro_rules! foo {
|
|||
|
||||
pub fn main() {
|
||||
'x: for _ in range(0,1) {
|
||||
foo!() //~ ERROR use of undeclared label `x`
|
||||
foo!() //~ ERROR use of undeclared label `'x`
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ macro_rules! foo {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
foo!(break 'x); //~ ERROR use of undeclared label `x`
|
||||
foo!(break 'x); //~ ERROR use of undeclared label `'x`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo<'static> { //~ ERROR illegal lifetime parameter name: `static`
|
||||
struct Foo<'static> { //~ ERROR illegal lifetime parameter name: `'static`
|
||||
x: &'static int
|
||||
}
|
||||
|
||||
|
|
|
|||
19
src/test/run-pass/loop-label-shadowing.rs
Normal file
19
src/test/run-pass/loop-label-shadowing.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Issue #12512.
|
||||
|
||||
fn main() {
|
||||
let mut foo = Vec::new();
|
||||
'foo: for i in [1, 2, 3].iter() {
|
||||
foo.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue