File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ //@ run-pass
2+ //@ rustc-env:RUSTC_OVERRIDE_VERSION_STRING=1.50.3
3+
4+ #![ feature( cfg_version) ]
5+
6+ #[ cfg( version( "1.49.0" ) ) ]
7+ const ON_1_49_0 : bool = true ;
8+ #[ cfg( version( "1.50" ) ) ]
9+ const ON_1_50_0 : bool = true ;
10+ #[ cfg( not( version( "1.51" ) ) ) ]
11+ const ON_1_51_0 : bool = false ;
12+
13+ // This one uses the wrong syntax, so doesn't eval to true
14+ #[ warn( unexpected_cfgs) ]
15+ #[ cfg( not( version = "1.48.0" ) ) ] //~ WARN unexpected `cfg` condition name: `version`
16+ const ON_1_48_0 : bool = false ;
17+
18+ fn main ( ) {
19+ assert ! ( !ON_1_48_0 ) ;
20+ assert ! ( ON_1_49_0 ) ;
21+ assert ! ( ON_1_50_0 ) ;
22+ assert ! ( !ON_1_51_0 ) ;
23+ assert ! ( cfg!( version( "1.1" ) ) ) ;
24+ assert ! ( cfg!( version( "1.49" ) ) ) ;
25+ assert ! ( cfg!( version( "1.50.0" ) ) ) ;
26+ assert ! ( cfg!( version( "1.50.3" ) ) ) ;
27+ assert ! ( !cfg!( version( "1.50.4" ) ) ) ;
28+ assert ! ( !cfg!( version( "1.51" ) ) ) ;
29+ assert ! ( !cfg!( version( "1.100" ) ) ) ;
30+ }
Original file line number Diff line number Diff line change 1+ warning: unexpected `cfg` condition name: `version`
2+ --> $DIR/cfg-version-expand.rs:15:11
3+ |
4+ LL | #[cfg(not(version = "1.48.0"))]
5+ | ^^^^^^^^^^^^^^^^^^
6+ |
7+ = help: expected names are: `FALSE` and `test` and 31 more
8+ = help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))`
9+ = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
10+ = note: `#[warn(unexpected_cfgs)]` on by default
11+
12+ warning: 1 warning emitted
13+
You can’t perform that action at this time.
0 commit comments