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 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+
1318enum T {
1419 A ( int ) ,
1520 B ( uint )
1621}
1722
1823macro_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
3136pub fn main ( ) {
3237 foo ( A ( 20 ) ) ;
Original file line number Diff line number Diff 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+
1823macro_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
3237pub fn main ( ) {
3338 foo ( A ( 1 ) , A ( 2 ) ) ;
You can’t perform that action at this time.
0 commit comments