// ignore-pretty: pprust doesn't print hygiene output
-#![feature(macro_rules)]
-
macro_rules! loop_x {
($e: expr) => {
// $e shouldn't be able to interact with this 'x
}
}
+macro_rules! while_true {
+ ($e: expr) => {
+ // $e shouldn't be able to interact with this 'x
+ 'x: while 1i + 1 == 2 { $e }
+ }
+}
+
macro_rules! run_once {
($e: expr) => {
// ditto
- 'x: for _ in range(0, 1) { $e }
+ 'x: for _ in range(0i, 1) { $e }
}
}
pub fn main() {
let mut i = 0i;
- let j = {
+ let j: int = {
'x: loop {
// this 'x should refer to the outer loop, lexically
loop_x!(break 'x);
};
assert_eq!(j, 1i);
- let k = {
- 'x: for _ in range(0, 1) {
+ let k: int = {
+ 'x: for _ in range(0i, 1) {
// ditto
loop_x!(break 'x);
i += 1;
};
assert_eq!(k, 1i);
- let n = {
- 'x: for _ in range(0, 1) {
+ let l: int = {
+ 'x: for _ in range(0i, 1) {
+ // ditto
+ while_true!(break 'x);
+ i += 1;
+ }
+ i + 1
+ };
+ assert_eq!(l, 1i);
+
+ let n: int = {
+ 'x: for _ in range(0i, 1) {
// ditto
run_once!(continue 'x);
i += 1;