File tree Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,16 @@ macro_rules! ignored_expr {
2222 ( ) => ( 1 , 2 ) //~ ERROR macro expansion ignores token `,`
2323}
2424
25+ macro_rules! ignored_pat {
26+ ( ) => ( 1 , 2 ) //~ ERROR macro expansion ignores token `,`
27+ }
28+
2529ignored_item ! ( )
2630
2731fn main ( ) {
2832 ignored_expr ! ( )
33+ match 1 {
34+ ignored_pat ! ( ) => ( ) ,
35+ _ => ( ) ,
36+ }
2937}
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( macro_rules) ]
12+
13+ macro_rules! foo ( ( ) => ( x ) )
14+
15+ fn main ( ) {
16+ let foo ! ( ) = 2 ;
17+ x + 1 ; //~ ERROR unresolved name `x`
18+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( macro_rules) ]
12+
13+ macro_rules! mypat(
14+ ( ) => (
15+ Some ( 'y' )
16+ )
17+ )
18+
19+ macro_rules! char_x(
20+ ( ) => (
21+ 'x'
22+ )
23+ )
24+
25+ macro_rules! some(
26+ ( $x: pat) => (
27+ Some ( $x)
28+ )
29+ )
30+
31+ macro_rules! indirect(
32+ ( ) => (
33+ some!( char_x!( ) )
34+ )
35+ )
36+
37+ macro_rules! ident_pat(
38+ ( $x: ident) => (
39+ $x
40+ )
41+ )
42+
43+ fn f ( c : Option < char > ) -> uint {
44+ match c {
45+ Some ( 'x' ) => 1 ,
46+ mypat ! ( ) => 2 ,
47+ _ => 3 ,
48+ }
49+ }
50+
51+ pub fn main ( ) {
52+ assert_eq ! ( 1 , f( Some ( 'x' ) ) ) ;
53+ assert_eq ! ( 2 , f( Some ( 'y' ) ) ) ;
54+ assert_eq ! ( 3 , f( None ) ) ;
55+
56+ assert_eq ! ( 1 , match Some ( 'x' ) {
57+ Some ( char_x!( ) ) => 1 ,
58+ _ => 2 ,
59+ } ) ;
60+
61+ assert_eq ! ( 1 , match Some ( 'x' ) {
62+ some!( char_x!( ) ) => 1 ,
63+ _ => 2 ,
64+ } ) ;
65+
66+ assert_eq ! ( 1 , match Some ( 'x' ) {
67+ indirect!( ) => 1 ,
68+ _ => 2 ,
69+ } ) ;
70+
71+ assert_eq ! ( 3 , {
72+ let ident_pat!( x) = 2 ;
73+ x+1
74+ } ) ;
75+ }
You can’t perform that action at this time.
0 commit comments