Skip to content

Commit 3257f81

Browse files
authored
Rollup merge of #94772 - Urgau:check-cfg-miri, r=petrochenkov
Add miri to the well known conditional compilation names and values This pull request adds `miri` to the list of well known names and values of the conditional compilation checking (`--check-cfg`). This was brought up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/RFC.203013.3A.20Checking.20conditional.20compilation.20at.20compile.20time/near/274513827) when discussing about the future of `--check-cfg`. r? `@petrochenkov`
2 parents f7b1fcf + 6781016 commit 3257f81

File tree

6 files changed

+52
-7
lines changed

6 files changed

+52
-7
lines changed

compiler/rustc_session/src/config.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ impl CrateCheckConfig {
10721072
// NOTE: This should be kept in sync with `default_configuration` and
10731073
// `fill_well_known_values`
10741074
const WELL_KNOWN_NAMES: &[Symbol] = &[
1075+
// rustc
10751076
sym::unix,
10761077
sym::windows,
10771078
sym::target_os,
@@ -1091,9 +1092,12 @@ impl CrateCheckConfig {
10911092
sym::debug_assertions,
10921093
sym::proc_macro,
10931094
sym::test,
1095+
sym::feature,
1096+
// rustdoc
10941097
sym::doc,
10951098
sym::doctest,
1096-
sym::feature,
1099+
// miri
1100+
sym::miri,
10971101
];
10981102

10991103
// We only insert well-known names if `names()` was activated
@@ -1128,13 +1132,14 @@ impl CrateCheckConfig {
11281132

11291133
// No-values
11301134
for name in [
1135+
sym::doc,
1136+
sym::miri,
11311137
sym::unix,
1132-
sym::windows,
1133-
sym::debug_assertions,
1134-
sym::proc_macro,
11351138
sym::test,
1136-
sym::doc,
11371139
sym::doctest,
1140+
sym::windows,
1141+
sym::proc_macro,
1142+
sym::debug_assertions,
11381143
sym::target_thread_local,
11391144
] {
11401145
self.values_valid.entry(name).or_default();

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ symbols! {
892892
minnumf32,
893893
minnumf64,
894894
mips_target_feature,
895+
miri,
895896
misc,
896897
mmx_reg,
897898
modifiers,

src/bootstrap/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
193193
(None, "bootstrap", None),
194194
(Some(Mode::Rustc), "parallel_compiler", None),
195195
(Some(Mode::ToolRustc), "parallel_compiler", None),
196-
(Some(Mode::Std), "miri", None),
197196
(Some(Mode::Std), "stdarch_intel_sde", None),
198197
(Some(Mode::Std), "no_fp_fmt_parse", None),
199198
(Some(Mode::Std), "no_global_oom_handling", None),

src/test/ui/check-cfg/well-known-names.rs

+6
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ fn unix_misspell() {}
2424
#[cfg(unix)]
2525
fn unix() {}
2626

27+
#[cfg(miri)]
28+
fn miri() {}
29+
30+
#[cfg(doc)]
31+
fn doc() {}
32+
2733
fn main() {}

src/test/ui/check-cfg/well-known-values.rs

+14
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,18 @@ fn unix_with_value() {}
2525
#[cfg(unix)]
2626
fn unix() {}
2727

28+
#[cfg(miri = "miri")]
29+
//~^ WARNING unexpected `cfg` condition value
30+
fn miri_with_value() {}
31+
32+
#[cfg(miri)]
33+
fn miri() {}
34+
35+
#[cfg(doc = "linux")]
36+
//~^ WARNING unexpected `cfg` condition value
37+
fn doc_with_value() {}
38+
39+
#[cfg(doc)]
40+
fn doc() {}
41+
2842
fn main() {}

src/test/ui/check-cfg/well-known-values.stderr

+21-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,25 @@ LL | #[cfg(unix = "aa")]
2929
|
3030
= note: no expected value for `unix`
3131

32-
warning: 3 warnings emitted
32+
warning: unexpected `cfg` condition value
33+
--> $DIR/well-known-values.rs:28:7
34+
|
35+
LL | #[cfg(miri = "miri")]
36+
| ^^^^---------
37+
| |
38+
| help: remove the value
39+
|
40+
= note: no expected value for `miri`
41+
42+
warning: unexpected `cfg` condition value
43+
--> $DIR/well-known-values.rs:35:7
44+
|
45+
LL | #[cfg(doc = "linux")]
46+
| ^^^----------
47+
| |
48+
| help: remove the value
49+
|
50+
= note: no expected value for `doc`
51+
52+
warning: 5 warnings emitted
3353

0 commit comments

Comments
 (0)