Skip to content

Commit 9a6864d

Browse files
committed
Add more hygiene tests
1 parent d19ee0d commit 9a6864d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/run-pass/hygiene.rs

+23
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,27 @@ fn main() {
1818

1919
let x = 1;
2020
foo!();
21+
22+
g();
23+
}
24+
25+
fn g() {
26+
let x = 0;
27+
macro_rules! m { ($x:ident) => {
28+
macro_rules! m2 { () => { ($x, x) } }
29+
let x = 1;
30+
macro_rules! m3 { () => { ($x, x) } }
31+
} }
32+
33+
let x = 2;
34+
m!(x);
35+
36+
let x = 3;
37+
assert_eq!(m2!(), (2, 0));
38+
assert_eq!(m3!(), (2, 1));
39+
40+
let x = 4;
41+
m!(x);
42+
assert_eq!(m2!(), (4, 0));
43+
assert_eq!(m3!(), (4, 1));
2144
}

0 commit comments

Comments
 (0)