File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( macro_rules) ]
12
12
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
+
13
18
enum T {
14
19
A ( int ) ,
15
20
B ( uint )
16
21
}
17
22
18
23
macro_rules! test(
19
- ( $e: expr) => (
24
+ ( $id : ident , $ e: expr) => (
20
25
fn foo( t: T ) -> int {
21
26
match t {
22
- A ( y ) => $e,
23
- B ( y ) => $e
27
+ A ( $id ) => $e,
28
+ B ( $id ) => $e
24
29
}
25
30
}
26
31
)
27
32
)
28
33
29
- test ! ( 10 + ( y as int) )
34
+ test ! ( y , 10 + ( y as int) )
30
35
31
36
pub fn main ( ) {
32
37
foo ( A ( 20 ) ) ;
Original file line number Diff line number Diff line change @@ -15,19 +15,24 @@ enum T {
15
15
B ( f64 )
16
16
}
17
17
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
+
18
23
macro_rules! test(
19
- ( $e: expr) => (
24
+ ( $id1 : ident , $id2 : ident , $ e: expr) => (
20
25
fn foo( a: T , b: T ) -> T {
21
26
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) ,
24
29
_ => fail!( )
25
30
}
26
31
}
27
32
)
28
33
)
29
34
30
- test ! ( x + y)
35
+ test ! ( x, y , x + y)
31
36
32
37
pub fn main ( ) {
33
38
foo ( A ( 1 ) , A ( 2 ) ) ;
You can’t perform that action at this time.
0 commit comments