-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #136016 - Urgau:check-cfg-allow-test-improv, r=jieyouxu
Improve check-cfg expected names diagnostic This PR improves the check-cfg `allow-same-level` test by ~~normalizing it's output and by~~ adding more context to the test. It also filters the well known cfgs from the `expected names are` note, as to reduce the size of the diagnostic. Users can still find the full list on the [rustc book](https://doc.rust-lang.org/nightly/rustc/check-cfg.html#well-known-names-and-values), which is reinforced for Cargo users by adding a note in the Cargo check-cfg specific section. Fixes #135995 r? `@jieyouxu`
- Loading branch information
Showing
25 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
// 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 | ||
|
||
#[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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
warning: unexpected `cfg` condition name: `FALSE` | ||
--> $DIR/allow-same-level.rs:8:7 | ||
--> $DIR/allow-same-level.rs:15: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: 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:20: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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.