Improve check-cfg allow-same-level
test
https://github.com/rust-lang/rust/issues/135995
This commit is contained in:
parent
6a64e3b897
commit
c08cc61bdd
2 changed files with 27 additions and 5 deletions
|
@ -1,12 +1,25 @@
|
|||
// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
|
||||
// This test check that #[allow(unexpected_cfgs)] **doesn't work**
|
||||
// when put on the same level as the #[cfg] attribute.
|
||||
//
|
||||
// It should work, but due to interactions between how #[cfg]s are
|
||||
// expanded, the lint machinery and the check-cfg impl, we
|
||||
// miss the #[allow], althrough we probably shoudln't.
|
||||
//
|
||||
// cf. https://github.com/rust-lang/rust/issues/124735
|
||||
//
|
||||
//@ check-pass
|
||||
//@ no-auto-check-cfg
|
||||
//@ compile-flags: --check-cfg=cfg()
|
||||
//@ compile-flags: --check-cfg=cfg() --cfg=unknown_but_active_cfg
|
||||
//@ normalize-stderr: "expected names are: .*" -> "..."
|
||||
|
||||
#[allow(unexpected_cfgs)]
|
||||
#[cfg(FALSE)]
|
||||
//~^ WARNING unexpected `cfg` condition name
|
||||
fn bar() {}
|
||||
|
||||
#[allow(unexpected_cfgs)]
|
||||
#[cfg(unknown_but_active_cfg)]
|
||||
//~^ WARNING unexpected `cfg` condition name
|
||||
fn bar() {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
warning: unexpected `cfg` condition name: `FALSE`
|
||||
--> $DIR/allow-same-level.rs:8:7
|
||||
--> $DIR/allow-same-level.rs:16:7
|
||||
|
|
||||
LL | #[cfg(FALSE)]
|
||||
| ^^^^^
|
||||
|
|
||||
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
|
||||
= help: ...
|
||||
= help: to expect this configuration use `--check-cfg=cfg(FALSE)`
|
||||
= 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
|
||||
|
||||
warning: 1 warning emitted
|
||||
warning: unexpected `cfg` condition name: `unknown_but_active_cfg`
|
||||
--> $DIR/allow-same-level.rs:21:7
|
||||
|
|
||||
LL | #[cfg(unknown_but_active_cfg)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: to expect this configuration use `--check-cfg=cfg(unknown_but_active_cfg)`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue