Skip to content

Commit bfa45ac

Browse files
Add regression test
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
1 parent 8e400f9 commit bfa45ac

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// https://github.com/rust-lang/rust/issues/143977
2+
// Check that features are available when an attribute is applied to a crate
3+
4+
#![cfg(version("1.0"))]
5+
//~^ ERROR `cfg(version)` is experimental and subject to change
6+
7+
// Using invalid value `does_not_exist`,
8+
// so we don't accidentally configure out the crate for any certain OS
9+
#![cfg(not(target(os = "does_not_exist")))]
10+
//~^ ERROR compact `cfg(target(..))` is experimental and subject to change
11+
//~| WARN unexpected `cfg` condition value: `does_not_exist`
12+
13+
fn main() {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error[E0658]: `cfg(version)` is experimental and subject to change
2+
--> $DIR/cfg-crate-features.rs:4:8
3+
|
4+
LL | #![cfg(version("1.0"))]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
8+
= help: add `#![feature(cfg_version)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
12+
--> $DIR/cfg-crate-features.rs:9:12
13+
|
14+
LL | #![cfg(not(target(os = "does_not_exist")))]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
18+
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
warning: unexpected `cfg` condition value: `does_not_exist`
22+
--> $DIR/cfg-crate-features.rs:9:19
23+
|
24+
LL | #![cfg(not(target(os = "does_not_exist")))]
25+
| ^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, and `uefi` and 9 more
28+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
29+
= note: `#[warn(unexpected_cfgs)]` on by default
30+
31+
error: aborting due to 2 previous errors; 1 warning emitted
32+
33+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)