File tree 4 files changed +64
-1
lines changed
compiler/rustc_interface/src
4 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -173,12 +173,21 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
173
173
let expected_values = check_cfg
174
174
. expecteds
175
175
. entry ( ident. name . to_string ( ) )
176
+ . and_modify ( |expected_values| match expected_values {
177
+ ExpectedValues :: Some ( _) => { }
178
+ ExpectedValues :: Any => {
179
+ // handle the case where names(...) was done
180
+ // before values by changing to a list
181
+ * expected_values =
182
+ ExpectedValues :: Some ( FxHashSet :: default ( ) ) ;
183
+ }
184
+ } )
176
185
. or_insert_with ( || {
177
186
ExpectedValues :: Some ( FxHashSet :: default ( ) )
178
187
} ) ;
179
188
180
189
let ExpectedValues :: Some ( expected_values) = expected_values else {
181
- bug ! ( "shoudn't be possible " )
190
+ bug ! ( "`expected_values` should be a list a values " )
182
191
} ;
183
192
184
193
for val in values {
Original file line number Diff line number Diff line change
1
+ warning: unexpected `cfg` condition value
2
+ --> $DIR/order-independant.rs:8:7
3
+ |
4
+ LL | #[cfg(a)]
5
+ | ^- help: specify a config value: `= "b"`
6
+ |
7
+ = note: expected values for `a` are: `b`
8
+ = note: `#[warn(unexpected_cfgs)]` on by default
9
+
10
+ warning: unexpected `cfg` condition value
11
+ --> $DIR/order-independant.rs:12:7
12
+ |
13
+ LL | #[cfg(a = "unk")]
14
+ | ^^^^^^^^^
15
+ |
16
+ = note: expected values for `a` are: `b`
17
+
18
+ warning: 2 warnings emitted
19
+
Original file line number Diff line number Diff line change
1
+ warning: unexpected `cfg` condition value
2
+ --> $DIR/order-independant.rs:8:7
3
+ |
4
+ LL | #[cfg(a)]
5
+ | ^- help: specify a config value: `= "b"`
6
+ |
7
+ = note: expected values for `a` are: `b`
8
+ = note: `#[warn(unexpected_cfgs)]` on by default
9
+
10
+ warning: unexpected `cfg` condition value
11
+ --> $DIR/order-independant.rs:12:7
12
+ |
13
+ LL | #[cfg(a = "unk")]
14
+ | ^^^^^^^^^
15
+ |
16
+ = note: expected values for `a` are: `b`
17
+
18
+ warning: 2 warnings emitted
19
+
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+ // revisions: names_before names_after
3
+ // compile-flags: -Z unstable-options
4
+ // compile-flags: --check-cfg=names(names_before,names_after)
5
+ // [names_before]compile-flags: --check-cfg=names(a) --check-cfg=values(a,"b")
6
+ // [names_after]compile-flags: --check-cfg=values(a,"b") --check-cfg=names(a)
7
+
8
+ #[ cfg( a) ]
9
+ //~^ WARNING unexpected `cfg` condition value
10
+ fn my_cfg ( ) { }
11
+
12
+ #[ cfg( a = "unk" ) ]
13
+ //~^ WARNING unexpected `cfg` condition value
14
+ fn my_cfg ( ) { }
15
+
16
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments