@@ -10,7 +10,7 @@ struct Struct;
10
10
11
11
impl Trait for Struct {
12
12
cfg_match ! {
13
- cfg ( feature = "blah" ) => {
13
+ feature = "blah" => {
14
14
fn blah( & self ) {
15
15
unimplemented!( ) ;
16
16
}
@@ -47,21 +47,21 @@ fn matches_leading_pipe() {
47
47
#[ test]
48
48
fn cfg_match_basic ( ) {
49
49
cfg_match ! {
50
- cfg ( target_pointer_width = "64" ) => { fn f0_( ) -> bool { true } }
50
+ target_pointer_width = "64" => { fn f0_( ) -> bool { true } }
51
51
}
52
52
53
53
cfg_match ! {
54
- cfg ( unix) => { fn f1_( ) -> bool { true } }
55
- cfg ( any( target_os = "macos" , target_os = "linux" ) ) => { fn f1_( ) -> bool { false } }
54
+ unix => { fn f1_( ) -> bool { true } }
55
+ any( target_os = "macos" , target_os = "linux" ) => { fn f1_( ) -> bool { false } }
56
56
}
57
57
58
58
cfg_match ! {
59
- cfg ( target_pointer_width = "32" ) => { fn f2_( ) -> bool { false } }
60
- cfg ( target_pointer_width = "64" ) => { fn f2_( ) -> bool { true } }
59
+ target_pointer_width = "32" => { fn f2_( ) -> bool { false } }
60
+ target_pointer_width = "64" => { fn f2_( ) -> bool { true } }
61
61
}
62
62
63
63
cfg_match ! {
64
- cfg ( target_pointer_width = "16" ) => { fn f3_( ) -> i32 { 1 } }
64
+ target_pointer_width = "16" => { fn f3_( ) -> i32 { 1 } }
65
65
_ => { fn f3_( ) -> i32 { 2 } }
66
66
}
67
67
@@ -83,7 +83,7 @@ fn cfg_match_basic() {
83
83
#[ test]
84
84
fn cfg_match_debug_assertions ( ) {
85
85
cfg_match ! {
86
- cfg ( debug_assertions) => {
86
+ debug_assertions => {
87
87
assert!( cfg!( debug_assertions) ) ;
88
88
assert_eq!( 4 , 2 +2 ) ;
89
89
}
@@ -98,13 +98,13 @@ fn cfg_match_debug_assertions() {
98
98
#[ test]
99
99
fn cfg_match_no_duplication_on_64 ( ) {
100
100
cfg_match ! {
101
- cfg ( windows) => {
101
+ windows => {
102
102
fn foo( ) { }
103
103
}
104
- cfg ( unix) => {
104
+ unix => {
105
105
fn foo( ) { }
106
106
}
107
- cfg ( target_pointer_width = "64" ) => {
107
+ target_pointer_width = "64" => {
108
108
fn foo( ) { }
109
109
}
110
110
}
@@ -114,34 +114,34 @@ fn cfg_match_no_duplication_on_64() {
114
114
#[ test]
115
115
fn cfg_match_options ( ) {
116
116
cfg_match ! {
117
- cfg ( test) => {
117
+ test => {
118
118
use core:: option:: Option as Option2 ;
119
119
fn works1( ) -> Option2 <u32 > { Some ( 1 ) }
120
120
}
121
121
_ => { fn works1( ) -> Option <u32 > { None } }
122
122
}
123
123
124
124
cfg_match ! {
125
- cfg ( feature = "foo" ) => { fn works2( ) -> bool { false } }
126
- cfg ( test) => { fn works2( ) -> bool { true } }
125
+ feature = "foo" => { fn works2( ) -> bool { false } }
126
+ test => { fn works2( ) -> bool { true } }
127
127
_ => { fn works2( ) -> bool { false } }
128
128
}
129
129
130
130
cfg_match ! {
131
- cfg ( feature = "foo" ) => { fn works3( ) -> bool { false } }
131
+ feature = "foo" => { fn works3( ) -> bool { false } }
132
132
_ => { fn works3( ) -> bool { true } }
133
133
}
134
134
135
135
cfg_match ! {
136
- cfg ( test) => {
136
+ test => {
137
137
use core:: option:: Option as Option3 ;
138
138
fn works4( ) -> Option3 <u32 > { Some ( 1 ) }
139
139
}
140
140
}
141
141
142
142
cfg_match ! {
143
- cfg ( feature = "foo" ) => { fn works5( ) -> bool { false } }
144
- cfg ( test) => { fn works5( ) -> bool { true } }
143
+ feature = "foo" => { fn works5( ) -> bool { false } }
144
+ test => { fn works5( ) -> bool { true } }
145
145
}
146
146
147
147
assert ! ( works1( ) . is_some( ) ) ;
@@ -154,7 +154,7 @@ fn cfg_match_options() {
154
154
#[ test]
155
155
fn cfg_match_two_functions ( ) {
156
156
cfg_match ! {
157
- cfg ( target_pointer_width = "64" ) => {
157
+ target_pointer_width = "64" => {
158
158
fn foo1( ) { }
159
159
fn bar1( ) { }
160
160
}
@@ -178,7 +178,7 @@ fn cfg_match_two_functions() {
178
178
179
179
fn _accepts_expressions ( ) -> i32 {
180
180
cfg_match ! {
181
- cfg ( unix) => { 1 }
181
+ unix => { 1 }
182
182
_ => { 2 }
183
183
}
184
184
}
@@ -189,7 +189,18 @@ fn _allows_stmt_expr_attributes() {
189
189
let one = 1 ;
190
190
let two = 2 ;
191
191
cfg_match ! {
192
- cfg ( unix) => { one * two; }
192
+ unix => { one * two; }
193
193
_ => { one + two; }
194
194
}
195
195
}
196
+
197
+ fn _expression ( ) {
198
+ let _ = cfg_match ! ( {
199
+ windows => {
200
+ " XP"
201
+ }
202
+ _ => {
203
+ ""
204
+ }
205
+ } ) ;
206
+ }
0 commit comments