Skip to content

Commit ee1ee7f

Browse files
committed
make tests hygienic...
... and possibly totally pointless. Specifically, fixing these to make their macros hygienic may mean that they no longer test the thing that they were supposed to test.
1 parent 235ca18 commit ee1ee7f

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/test/run-pass/issue-8851.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,28 @@
1010

1111
#![feature(macro_rules)]
1212

13+
// after fixing #9384 and implementing hygiene for match bindings,
14+
// this now fails because the insertion of the 'y' into the match
15+
// doesn't cause capture. Making this macro hygienic (as I've done)
16+
// could very well make this test case completely pointless....
17+
1318
enum T {
1419
A(int),
1520
B(uint)
1621
}
1722

1823
macro_rules! test(
19-
($e:expr) => (
24+
($id:ident, $e:expr) => (
2025
fn foo(t: T) -> int {
2126
match t {
22-
A(y) => $e,
23-
B(y) => $e
27+
A($id) => $e,
28+
B($id) => $e
2429
}
2530
}
2631
)
2732
)
2833

29-
test!(10 + (y as int))
34+
test!(y, 10 + (y as int))
3035

3136
pub fn main() {
3237
foo(A(20));

src/test/run-pass/typeck-macro-interaction-issue-8852.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,24 @@ enum T {
1515
B(f64)
1616
}
1717

18+
// after fixing #9384 and implementing hygiene for match bindings,
19+
// this now fails because the insertion of the 'y' into the match
20+
// doesn't cause capture. Making this macro hygienic (as I've done)
21+
// could very well make this test case completely pointless....
22+
1823
macro_rules! test(
19-
($e:expr) => (
24+
($id1:ident, $id2:ident, $e:expr) => (
2025
fn foo(a:T, b:T) -> T {
2126
match (a, b) {
22-
(A(x), A(y)) => A($e),
23-
(B(x), B(y)) => B($e),
27+
(A($id1), A($id2)) => A($e),
28+
(B($id1), B($id2)) => B($e),
2429
_ => fail!()
2530
}
2631
}
2732
)
2833
)
2934

30-
test!(x + y)
35+
test!(x,y,x + y)
3136

3237
pub fn main() {
3338
foo(A(1), A(2));

0 commit comments

Comments
 (0)