Skip to content

Commit c08cc61

Browse files
committed
Improve check-cfg allow-same-level test
rust-lang#135995
1 parent 6a64e3b commit c08cc61

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

Diff for: tests/ui/check-cfg/allow-same-level.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
1+
// This test check that #[allow(unexpected_cfgs)] **doesn't work**
2+
// when put on the same level as the #[cfg] attribute.
3+
//
4+
// It should work, but due to interactions between how #[cfg]s are
5+
// expanded, the lint machinery and the check-cfg impl, we
6+
// miss the #[allow], althrough we probably shoudln't.
7+
//
8+
// cf. https://github.com/rust-lang/rust/issues/124735
29
//
310
//@ check-pass
411
//@ no-auto-check-cfg
5-
//@ compile-flags: --check-cfg=cfg()
12+
//@ compile-flags: --check-cfg=cfg() --cfg=unknown_but_active_cfg
13+
//@ normalize-stderr: "expected names are: .*" -> "..."
614

715
#[allow(unexpected_cfgs)]
816
#[cfg(FALSE)]
917
//~^ WARNING unexpected `cfg` condition name
1018
fn bar() {}
1119

20+
#[allow(unexpected_cfgs)]
21+
#[cfg(unknown_but_active_cfg)]
22+
//~^ WARNING unexpected `cfg` condition name
23+
fn bar() {}
24+
1225
fn main() {}

Diff for: tests/ui/check-cfg/allow-same-level.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
warning: unexpected `cfg` condition name: `FALSE`
2-
--> $DIR/allow-same-level.rs:8:7
2+
--> $DIR/allow-same-level.rs:16:7
33
|
44
LL | #[cfg(FALSE)]
55
| ^^^^^
66
|
7-
= 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`
7+
= help: ...
88
= help: to expect this configuration use `--check-cfg=cfg(FALSE)`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

12-
warning: 1 warning emitted
12+
warning: unexpected `cfg` condition name: `unknown_but_active_cfg`
13+
--> $DIR/allow-same-level.rs:21:7
14+
|
15+
LL | #[cfg(unknown_but_active_cfg)]
16+
| ^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= help: to expect this configuration use `--check-cfg=cfg(unknown_but_active_cfg)`
19+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
20+
21+
warning: 2 warnings emitted
1322

0 commit comments

Comments
 (0)