Add regression test

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
Jonathan Brouwer 2025-07-15 19:07:49 +02:00
parent 8e400f97e5
commit bfa45ac78b
No known key found for this signature in database
GPG key ID: 13619B051B673C52
2 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,13 @@
// https://github.com/rust-lang/rust/issues/143977
// Check that features are available when an attribute is applied to a crate
#![cfg(version("1.0"))]
//~^ ERROR `cfg(version)` is experimental and subject to change
// Using invalid value `does_not_exist`,
// so we don't accidentally configure out the crate for any certain OS
#![cfg(not(target(os = "does_not_exist")))]
//~^ ERROR compact `cfg(target(..))` is experimental and subject to change
//~| WARN unexpected `cfg` condition value: `does_not_exist`
fn main() {}

View file

@ -0,0 +1,33 @@
error[E0658]: `cfg(version)` is experimental and subject to change
--> $DIR/cfg-crate-features.rs:4:8
|
LL | #![cfg(version("1.0"))]
| ^^^^^^^^^^^^^^
|
= note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
= help: add `#![feature(cfg_version)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
--> $DIR/cfg-crate-features.rs:9:12
|
LL | #![cfg(not(target(os = "does_not_exist")))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
warning: unexpected `cfg` condition value: `does_not_exist`
--> $DIR/cfg-crate-features.rs:9:19
|
LL | #![cfg(not(target(os = "does_not_exist")))]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`.