-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes labelled loops hygiene by performing renaming of the labels defined in e.g. `'x: loop { ... }` and then used in break and continue statements within loop body so that they act hygienically when used with macros. Closes #12262.
- Loading branch information
Showing
18 changed files
with
262 additions
and
28 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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2012-2014 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. | ||
|
||
#[feature(macro_rules)]; | ||
|
||
macro_rules! foo { | ||
() => { break 'x; } | ||
} | ||
|
||
pub fn main() { | ||
'x: loop { foo!() } //~ ERROR use of undeclared label `x` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2012-2014 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. | ||
|
||
#[feature(macro_rules)]; | ||
|
||
macro_rules! foo { | ||
($e: expr) => { 'x: loop { $e } } | ||
} | ||
|
||
pub fn main() { | ||
foo!(break 'x); //~ ERROR use of undeclared label `x` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2012-2014 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. | ||
|
||
#[feature(macro_rules)]; | ||
|
||
macro_rules! foo { | ||
() => { break 'x; } | ||
} | ||
|
||
pub fn main() { | ||
'x: for _ in range(0,1) { | ||
foo!() //~ ERROR use of undeclared label `x` | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2012-2014 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. | ||
|
||
#[feature(macro_rules)]; | ||
|
||
macro_rules! foo { | ||
($e: expr) => { 'x: for _ in range(0,1) { $e } } | ||
} | ||
|
||
pub fn main() { | ||
foo!(break 'x); //~ ERROR use of undeclared label `x` | ||
} |
Oops, something went wrong.
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from cmr
at edwardw@386db05
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging edwardw/rust/hygienic-break-continue = 386db05 into auto
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edwardw/rust/hygienic-break-continue = 386db05 merged ok, testing candidate = 71f29014
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1382
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from cmr
at edwardw@386db05
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging edwardw/rust/hygienic-break-continue = 386db05 into auto
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edwardw/rust/hygienic-break-continue = 386db05 merged ok, testing candidate = 329fcd4
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/4433
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/2275
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/2276
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/4431
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/3531
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/3537
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/4446
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/3534
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/3540
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/4448
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/3534
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/3539
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/3608
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1387
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/4440
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/3541
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/3547
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/4208
386db05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 329fcd4