Skip to content

Commit 44c166e

Browse files
committed
Add Cargo revision and values to the check-cfg macro test
1 parent 7899368 commit 44c166e

5 files changed

+100
-15
lines changed

tests/ui/check-cfg/auxiliary/cfg_macro.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@ macro_rules! my_lib_macro {
99
$crate::my_lib_func()
1010
};
1111
}
12+
13+
#[macro_export]
14+
macro_rules! my_lib_macro_value {
15+
() => {
16+
#[cfg(panic = "UNEXPECTED_VALUE")]
17+
$crate::my_lib_func()
18+
};
19+
}
20+
21+
#[macro_export]
22+
macro_rules! my_lib_macro_feature {
23+
() => {
24+
#[cfg(feature = "UNEXPECTED_FEATURE")]
25+
$crate::my_lib_func()
26+
};
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
warning: unexpected `cfg` condition name: `my_lib_cfg`
2+
--> $DIR/report-in-external-macros.rs:13:5
3+
|
4+
LL | cfg_macro::my_lib_macro!();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`, `test`, `ub_checks`, `unix`, and `windows`
8+
= help: consider using a Cargo feature instead
9+
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
10+
[lints.rust]
11+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(my_lib_cfg)'] }
12+
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(my_lib_cfg)");` to the top of the `build.rs`
13+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
14+
= note: `#[warn(unexpected_cfgs)]` on by default
15+
= note: this warning originates in the macro `cfg_macro::my_lib_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
17+
warning: unexpected `cfg` condition value: `UNEXPECTED_VALUE`
18+
--> $DIR/report-in-external-macros.rs:16:5
19+
|
20+
LL | cfg_macro::my_lib_macro_value!();
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= note: expected values for `panic` are: `abort` and `unwind`
24+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
25+
= note: this warning originates in the macro `cfg_macro::my_lib_macro_value` (in Nightly builds, run with -Z macro-backtrace for more info)
26+
27+
warning: unexpected `cfg` condition value: `UNEXPECTED_FEATURE`
28+
--> $DIR/report-in-external-macros.rs:19:5
29+
|
30+
LL | cfg_macro::my_lib_macro_feature!();
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
|
33+
= note: no expected values for `feature`
34+
= help: consider adding `UNEXPECTED_FEATURE` as a feature in `Cargo.toml`
35+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
36+
= note: this warning originates in the macro `cfg_macro::my_lib_macro_feature` (in Nightly builds, run with -Z macro-backtrace for more info)
37+
38+
warning: 3 warnings emitted
39+

tests/ui/check-cfg/report-in-external-macros.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33

44
//@ check-pass
55
//@ no-auto-check-cfg
6+
//@ revisions: cargo rustc
7+
//@ [rustc]unset-rustc-env:CARGO_CRATE_NAME
8+
//@ [cargo]rustc-env:CARGO_CRATE_NAME=foo
69
//@ aux-crate: cfg_macro=cfg_macro.rs
7-
//@ compile-flags: --check-cfg=cfg()
10+
//@ compile-flags: --check-cfg=cfg(feature,values())
811

912
fn main() {
1013
cfg_macro::my_lib_macro!();
1114
//~^ WARNING unexpected `cfg` condition name
15+
16+
cfg_macro::my_lib_macro_value!();
17+
//~^ WARNING unexpected `cfg` condition value
18+
19+
cfg_macro::my_lib_macro_feature!();
20+
//~^ WARNING unexpected `cfg` condition value
1221
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
warning: unexpected `cfg` condition name: `my_lib_cfg`
2+
--> $DIR/report-in-external-macros.rs:13:5
3+
|
4+
LL | cfg_macro::my_lib_macro!();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`, `test`, `ub_checks`, `unix`, and `windows`
8+
= help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)`
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
10+
= note: `#[warn(unexpected_cfgs)]` on by default
11+
= note: this warning originates in the macro `cfg_macro::my_lib_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
13+
warning: unexpected `cfg` condition value: `UNEXPECTED_VALUE`
14+
--> $DIR/report-in-external-macros.rs:16:5
15+
|
16+
LL | cfg_macro::my_lib_macro_value!();
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
|
19+
= note: expected values for `panic` are: `abort` and `unwind`
20+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
21+
= note: this warning originates in the macro `cfg_macro::my_lib_macro_value` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
warning: unexpected `cfg` condition value: `UNEXPECTED_FEATURE`
24+
--> $DIR/report-in-external-macros.rs:19:5
25+
|
26+
LL | cfg_macro::my_lib_macro_feature!();
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
|
29+
= note: no expected values for `feature`
30+
= help: to expect this configuration use `--check-cfg=cfg(feature, values("UNEXPECTED_FEATURE"))`
31+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
32+
= note: this warning originates in the macro `cfg_macro::my_lib_macro_feature` (in Nightly builds, run with -Z macro-backtrace for more info)
33+
34+
warning: 3 warnings emitted
35+

tests/ui/check-cfg/report-in-external-macros.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)