Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 53e9d43

Browse files
committedMar 11, 2025·
-Zunsigned-char=unsigned|signed|default flag for c_char->u8/i8 selection override
1 parent 2b4694a commit 53e9d43

24 files changed

+175
-53
lines changed
 

‎compiler/rustc_session/src/config.rs

+37-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2323
use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION};
2424
use rustc_span::source_map::FilePathMapping;
2525
use rustc_span::{
26-
FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol, sym,
26+
FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol, kw, sym,
2727
};
2828
use rustc_target::spec::{
2929
FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTuple,
@@ -2931,13 +2931,13 @@ pub(crate) mod dep_tracking {
29312931
};
29322932

29332933
use super::{
2934-
AutoDiff, BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions,
2935-
CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug, FunctionReturn,
2936-
InliningThreshold, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
2937-
LtoCli, MirStripDebugInfo, NextSolverConfig, OomStrategy, OptLevel, OutFileName,
2938-
OutputType, OutputTypes, PatchableFunctionEntry, Polonius, RemapPathScopeComponents,
2939-
ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
2940-
SymbolManglingVersion, WasiExecModel,
2934+
AutoDiff, BranchProtection, CCharType, CFGuard, CFProtection, CollapseMacroDebuginfo,
2935+
CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug,
2936+
FunctionReturn, InliningThreshold, InstrumentCoverage, InstrumentXRay, LinkerPluginLto,
2937+
LocationDetail, LtoCli, MirStripDebugInfo, NextSolverConfig, OomStrategy, OptLevel,
2938+
OutFileName, OutputType, OutputTypes, PatchableFunctionEntry, Polonius,
2939+
RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind,
2940+
SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
29412941
};
29422942
use crate::lint;
29432943
use crate::utils::NativeLib;
@@ -3040,6 +3040,7 @@ pub(crate) mod dep_tracking {
30403040
FunctionReturn,
30413041
WasmCAbi,
30423042
Align,
3043+
CCharType,
30433044
);
30443045

30453046
impl<T1, T2> DepTrackingHash for (T1, T2)
@@ -3314,3 +3315,31 @@ impl MirIncludeSpans {
33143315
self == MirIncludeSpans::On
33153316
}
33163317
}
3318+
3319+
/// The different settings that the `-Zc-char-type` flag can have.
3320+
#[derive(Clone, Copy, PartialEq, Hash, Debug, Default)]
3321+
pub enum CCharType {
3322+
/// Use default signed/unsigned c_char according to target configuration
3323+
#[default]
3324+
Default,
3325+
3326+
/// Set c_char to signed i8
3327+
Signed,
3328+
3329+
/// Set c_char to unsigned u8
3330+
Unsigned,
3331+
}
3332+
3333+
impl CCharType {
3334+
pub const fn desc_symbol(&self) -> Symbol {
3335+
match *self {
3336+
Self::Default => kw::Default,
3337+
Self::Signed => sym::signed,
3338+
Self::Unsigned => sym::unsigned,
3339+
}
3340+
}
3341+
3342+
pub const fn all() -> [Symbol; 3] {
3343+
[Self::Unsigned.desc_symbol(), Self::Signed.desc_symbol(), Self::Default.desc_symbol()]
3344+
}
3345+
}

‎compiler/rustc_session/src/config/cfg.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_span::{Symbol, sym};
3232
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target};
3333

3434
use crate::Session;
35-
use crate::config::{CrateType, FmtDebug};
35+
use crate::config::{CCharType, CrateType, FmtDebug};
3636

3737
/// The parsed `--cfg` options that define the compilation environment of the
3838
/// crate, used to drive conditional compilation.
@@ -144,6 +144,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
144144
| (sym::target_has_atomic_load_store, Some(_))
145145
| (sym::target_thread_local, None) => disallow(cfg, "--target"),
146146
(sym::fmt_debug, None | Some(_)) => disallow(cfg, "-Z fmt-debug"),
147+
(sym::c_char_type, None | Some(_)) => disallow(cfg, "-Z c-char-type"),
147148
(sym::emscripten_wasm_eh, None | Some(_)) => disallow(cfg, "-Z emscripten_wasm_eh"),
148149
_ => {}
149150
}
@@ -306,6 +307,8 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
306307
ins_none!(sym::contract_checks);
307308
}
308309

310+
ins_sym!(sym::c_char_type, sess.opts.unstable_opts.c_char_type.desc_symbol());
311+
309312
ret
310313
}
311314

@@ -470,5 +473,7 @@ impl CheckCfg {
470473

471474
ins!(sym::unix, no_values);
472475
ins!(sym::windows, no_values);
476+
477+
ins!(sym::c_char_type, empty_values).extend(CCharType::all());
473478
}
474479
}

‎compiler/rustc_session/src/options.rs

+13
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ mod desc {
794794
pub(crate) const parse_mir_include_spans: &str =
795795
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
796796
pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 2^29";
797+
pub(crate) const parse_c_char_type: &str = "one of `default`, `unsigned`, `signed`";
797798
}
798799

799800
pub mod parse {
@@ -954,6 +955,16 @@ pub mod parse {
954955
true
955956
}
956957

958+
pub(crate) fn parse_c_char_type(slot: &mut CCharType, v: Option<&str>) -> bool {
959+
*slot = match v {
960+
Some("unsigned") => CCharType::Unsigned,
961+
Some("signed") => CCharType::Signed,
962+
Some("default") => CCharType::Default,
963+
_ => return false,
964+
};
965+
true
966+
}
967+
957968
pub(crate) fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
958969
if let Some(v) = v {
959970
ld.line = false;
@@ -2099,6 +2110,8 @@ options! {
20992110
"emit noalias metadata for box (default: yes)"),
21002111
branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED],
21012112
"set options for branch target identification and pointer authentication on AArch64"),
2113+
c_char_type: CCharType = (CCharType::default(), parse_c_char_type, [TRACKED TARGET_MODIFIER],
2114+
"Make c_char type unsigned [default|signed|unsigned]"),
21022115
cf_protection: CFProtection = (CFProtection::None, parse_cfprotection, [TRACKED],
21032116
"instrument control-flow architecture protection"),
21042117
check_cfg_all_expected: bool = (false, parse_bool, [UNTRACKED],

‎compiler/rustc_span/src/symbol.rs

+3
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ symbols! {
557557
btreeset_iter,
558558
builtin_syntax,
559559
c,
560+
c_char_type,
560561
c_dash_variadic,
561562
c_str,
562563
c_str_literals,
@@ -1855,6 +1856,7 @@ symbols! {
18551856
shr_assign,
18561857
sig_dfl,
18571858
sig_ign,
1859+
signed,
18581860
simd,
18591861
simd_add,
18601862
simd_and,
@@ -2169,6 +2171,7 @@ symbols! {
21692171
unsafe_fields,
21702172
unsafe_no_drop_flag,
21712173
unsafe_pin_internals,
2174+
unsigned,
21722175
unsize,
21732176
unsized_const_param_ty,
21742177
unsized_const_params,

‎library/core/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ check-cfg = [
3838
# and to stdarch `core_arch` crate which messes-up with Cargo list
3939
# of declared features, we therefor expect any feature cfg
4040
'cfg(feature, values(any()))',
41+
'cfg(c_char_type, values(any()))'
4142
]

‎library/core/src/ffi/primitives.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ mod c_char_definition {
105105
// architecture defaults). As we only have a target for userspace apps so there are no
106106
// special cases for L4Re below.
107107
// https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240
108-
if #[cfg(all(
108+
if #[cfg(any(c_char_type = "unsigned", all(
109+
not(c_char_type = "signed"),
109110
not(windows),
110111
not(target_vendor = "apple"),
111112
not(target_os = "vita"),
@@ -122,7 +123,7 @@ mod c_char_definition {
122123
target_arch = "s390x",
123124
target_arch = "xtensa",
124125
)
125-
))] {
126+
)))] {
126127
pub(super) type c_char = u8;
127128
} else {
128129
// On every other target, c_char is signed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: unexpected `--cfg c_char_type="unsigned"` flag
2+
|
3+
= note: config `c_char_type` is only supposed to be controlled by `-Z c-char-type`
4+
= note: manually setting a built-in cfg can and does create incoherent behaviors
5+
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
6+
7+
error: aborting due to 1 previous error
8+

‎tests/ui/cfg/disallowed-cli-cfgs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//@ revisions: target_thread_local_ relocation_model_
99
//@ revisions: fmt_debug_
1010
//@ revisions: emscripten_wasm_eh_
11+
//@ revisions: c_char_type_
1112

1213
//@ [overflow_checks_]compile-flags: --cfg overflow_checks
1314
//@ [debug_assertions_]compile-flags: --cfg debug_assertions
@@ -35,5 +36,6 @@
3536
//@ [relocation_model_]compile-flags: --cfg relocation_model="a"
3637
//@ [fmt_debug_]compile-flags: --cfg fmt_debug="shallow"
3738
//@ [emscripten_wasm_eh_]compile-flags: --cfg emscripten_wasm_eh
39+
//@ [c_char_type_]compile-flags: --cfg c_char_type="unsigned"
3840

3941
fn main() {}

‎tests/ui/check-cfg/cargo-build-script.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo`
44
LL | #[cfg(has_foo)]
55
| ^^^^^^^
66
|
7-
= help: expected names are: `has_bar` and 31 more
7+
= help: expected names are: `has_bar` and 32 more
88
= help: consider using a Cargo feature instead
99
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
1010
[lints.rust]

‎tests/ui/check-cfg/cargo-feature.none.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
2727
|
28-
= help: expected names are: `docsrs`, `feature`, and `test` and 31 more
28+
= help: expected names are: `docsrs`, `feature`, and `test` and 32 more
2929
= help: consider using a Cargo feature instead
3030
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
3131
[lints.rust]

‎tests/ui/check-cfg/cargo-feature.some.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
2727
|
28-
= help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 31 more
28+
= help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 32 more
2929
= help: consider using a Cargo feature instead
3030
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
3131
[lints.rust]

‎tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value`
44
LL | #[cfg(value)]
55
| ^^^^^
66
|
7-
= help: expected names are: `bar`, `bee`, `cow`, and `foo` and 31 more
7+
= help: expected names are: `bar`, `bee`, `cow`, and `foo` and 32 more
88
= help: to expect this configuration use `--check-cfg=cfg(value)`
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

‎tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value`
44
LL | #[cfg(my_value)]
55
| ^^^^^^^^
66
|
7-
= help: expected names are: `bar` and `foo` and 31 more
7+
= help: expected names are: `bar` and `foo` and 32 more
88
= help: to expect this configuration use `--check-cfg=cfg(my_value)`
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

‎tests/ui/check-cfg/exhaustive-names-values.feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44
LL | #[cfg(unknown_key = "value")]
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `feature` and 31 more
7+
= help: expected names are: `feature` and 32 more
88
= help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))`
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

‎tests/ui/check-cfg/exhaustive-names-values.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44
LL | #[cfg(unknown_key = "value")]
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `feature` and 31 more
7+
= help: expected names are: `feature` and 32 more
88
= help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))`
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

‎tests/ui/check-cfg/mix.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu`
4444
LL | #[cfg_attr(uu, unix)]
4545
| ^^
4646
|
47-
= help: expected names are: `feature` and 31 more
47+
= help: expected names are: `feature` and 32 more
4848
= help: to expect this configuration use `--check-cfg=cfg(uu)`
4949
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
5050

‎tests/ui/check-cfg/raw-keywords.edition2015.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false`
1414
LL | #[cfg(r#false)]
1515
| ^^^^^^^
1616
|
17-
= help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 31 more
17+
= help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 32 more
1818
= help: to expect this configuration use `--check-cfg=cfg(r#false)`
1919
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2020

‎tests/ui/check-cfg/raw-keywords.edition2021.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false`
1414
LL | #[cfg(r#false)]
1515
| ^^^^^^^
1616
|
17-
= help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 31 more
17+
= help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 32 more
1818
= help: to expect this configuration use `--check-cfg=cfg(r#false)`
1919
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2020

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg`
44
LL | cfg_macro::my_lib_macro!();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `feature` and 31 more
7+
= help: expected names are: `feature` and 32 more
88
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
99
= help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
1010
= help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg`
44
LL | cfg_macro::my_lib_macro!();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `feature` and 31 more
7+
= help: expected names are: `feature` and 32 more
88
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
99
= help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
1010
= help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)`

‎tests/ui/check-cfg/well-known-names.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ warning: unexpected `cfg` condition name: `list_all_well_known_cfgs`
44
LL | #[cfg(list_all_well_known_cfgs)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `clippy`
7+
= help: expected names are: `c_char_type`
8+
`clippy`
89
`contract_checks`
910
`debug_assertions`
1011
`doc`

‎tests/ui/check-cfg/well-known-values.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
// diagnostic prints the list of expected values.
2727
#[cfg(any(
2828
// tidy-alphabetical-start
29+
c_char_type = "_UNEXPECTED_VALUE",
30+
//~^ WARN unexpected `cfg` condition value
2931
clippy = "_UNEXPECTED_VALUE",
3032
//~^ WARN unexpected `cfg` condition value
3133
debug_assertions = "_UNEXPECTED_VALUE",

‎tests/ui/check-cfg/well-known-values.stderr

+38-29
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
22
--> $DIR/well-known-values.rs:29:5
33
|
4+
LL | c_char_type = "_UNEXPECTED_VALUE",
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: expected values for `c_char_type` are: `default`, `signed`, and `unsigned`
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: `#[warn(unexpected_cfgs)]` on by default
10+
11+
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
12+
--> $DIR/well-known-values.rs:31:5
13+
|
414
LL | clippy = "_UNEXPECTED_VALUE",
515
| ^^^^^^----------------------
616
| |
717
| help: remove the value
818
|
919
= note: no expected value for `clippy`
1020
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
11-
= note: `#[warn(unexpected_cfgs)]` on by default
1221

1322
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
14-
--> $DIR/well-known-values.rs:31:5
23+
--> $DIR/well-known-values.rs:33:5
1524
|
1625
LL | debug_assertions = "_UNEXPECTED_VALUE",
1726
| ^^^^^^^^^^^^^^^^----------------------
@@ -22,7 +31,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE",
2231
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2332

2433
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
25-
--> $DIR/well-known-values.rs:33:5
34+
--> $DIR/well-known-values.rs:35:5
2635
|
2736
LL | doc = "_UNEXPECTED_VALUE",
2837
| ^^^----------------------
@@ -33,7 +42,7 @@ LL | doc = "_UNEXPECTED_VALUE",
3342
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
3443

3544
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
36-
--> $DIR/well-known-values.rs:35:5
45+
--> $DIR/well-known-values.rs:37:5
3746
|
3847
LL | doctest = "_UNEXPECTED_VALUE",
3948
| ^^^^^^^----------------------
@@ -44,7 +53,7 @@ LL | doctest = "_UNEXPECTED_VALUE",
4453
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
4554

4655
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
47-
--> $DIR/well-known-values.rs:37:5
56+
--> $DIR/well-known-values.rs:39:5
4857
|
4958
LL | fmt_debug = "_UNEXPECTED_VALUE",
5059
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -53,7 +62,7 @@ LL | fmt_debug = "_UNEXPECTED_VALUE",
5362
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
5463

5564
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
56-
--> $DIR/well-known-values.rs:39:5
65+
--> $DIR/well-known-values.rs:41:5
5766
|
5867
LL | miri = "_UNEXPECTED_VALUE",
5968
| ^^^^----------------------
@@ -64,7 +73,7 @@ LL | miri = "_UNEXPECTED_VALUE",
6473
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
6574

6675
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
67-
--> $DIR/well-known-values.rs:41:5
76+
--> $DIR/well-known-values.rs:43:5
6877
|
6978
LL | overflow_checks = "_UNEXPECTED_VALUE",
7079
| ^^^^^^^^^^^^^^^----------------------
@@ -75,7 +84,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE",
7584
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
7685

7786
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
78-
--> $DIR/well-known-values.rs:43:5
87+
--> $DIR/well-known-values.rs:45:5
7988
|
8089
LL | panic = "_UNEXPECTED_VALUE",
8190
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -84,7 +93,7 @@ LL | panic = "_UNEXPECTED_VALUE",
8493
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
8594

8695
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
87-
--> $DIR/well-known-values.rs:45:5
96+
--> $DIR/well-known-values.rs:47:5
8897
|
8998
LL | proc_macro = "_UNEXPECTED_VALUE",
9099
| ^^^^^^^^^^----------------------
@@ -95,7 +104,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE",
95104
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
96105

97106
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
98-
--> $DIR/well-known-values.rs:47:5
107+
--> $DIR/well-known-values.rs:49:5
99108
|
100109
LL | relocation_model = "_UNEXPECTED_VALUE",
101110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -104,7 +113,7 @@ LL | relocation_model = "_UNEXPECTED_VALUE",
104113
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
105114

106115
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
107-
--> $DIR/well-known-values.rs:49:5
116+
--> $DIR/well-known-values.rs:51:5
108117
|
109118
LL | rustfmt = "_UNEXPECTED_VALUE",
110119
| ^^^^^^^----------------------
@@ -115,7 +124,7 @@ LL | rustfmt = "_UNEXPECTED_VALUE",
115124
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
116125

117126
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
118-
--> $DIR/well-known-values.rs:51:5
127+
--> $DIR/well-known-values.rs:53:5
119128
|
120129
LL | sanitize = "_UNEXPECTED_VALUE",
121130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -124,7 +133,7 @@ LL | sanitize = "_UNEXPECTED_VALUE",
124133
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
125134

126135
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
127-
--> $DIR/well-known-values.rs:53:5
136+
--> $DIR/well-known-values.rs:55:5
128137
|
129138
LL | target_abi = "_UNEXPECTED_VALUE",
130139
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -133,7 +142,7 @@ LL | target_abi = "_UNEXPECTED_VALUE",
133142
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
134143

135144
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
136-
--> $DIR/well-known-values.rs:55:5
145+
--> $DIR/well-known-values.rs:57:5
137146
|
138147
LL | target_arch = "_UNEXPECTED_VALUE",
139148
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -142,7 +151,7 @@ LL | target_arch = "_UNEXPECTED_VALUE",
142151
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
143152

144153
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
145-
--> $DIR/well-known-values.rs:57:5
154+
--> $DIR/well-known-values.rs:59:5
146155
|
147156
LL | target_endian = "_UNEXPECTED_VALUE",
148157
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -151,7 +160,7 @@ LL | target_endian = "_UNEXPECTED_VALUE",
151160
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
152161

153162
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
154-
--> $DIR/well-known-values.rs:59:5
163+
--> $DIR/well-known-values.rs:61:5
155164
|
156165
LL | target_env = "_UNEXPECTED_VALUE",
157166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -160,7 +169,7 @@ LL | target_env = "_UNEXPECTED_VALUE",
160169
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
161170

162171
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
163-
--> $DIR/well-known-values.rs:61:5
172+
--> $DIR/well-known-values.rs:63:5
164173
|
165174
LL | target_family = "_UNEXPECTED_VALUE",
166175
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,7 +178,7 @@ LL | target_family = "_UNEXPECTED_VALUE",
169178
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
170179

171180
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
172-
--> $DIR/well-known-values.rs:65:5
181+
--> $DIR/well-known-values.rs:67:5
173182
|
174183
LL | target_has_atomic = "_UNEXPECTED_VALUE",
175184
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +187,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE",
178187
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
179188

180189
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
181-
--> $DIR/well-known-values.rs:67:5
190+
--> $DIR/well-known-values.rs:69:5
182191
|
183192
LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",
184193
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -187,7 +196,7 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",
187196
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
188197

189198
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
190-
--> $DIR/well-known-values.rs:69:5
199+
--> $DIR/well-known-values.rs:71:5
191200
|
192201
LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE",
193202
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -196,7 +205,7 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE",
196205
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
197206

198207
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
199-
--> $DIR/well-known-values.rs:71:5
208+
--> $DIR/well-known-values.rs:73:5
200209
|
201210
LL | target_os = "_UNEXPECTED_VALUE",
202211
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -205,7 +214,7 @@ LL | target_os = "_UNEXPECTED_VALUE",
205214
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
206215

207216
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
208-
--> $DIR/well-known-values.rs:73:5
217+
--> $DIR/well-known-values.rs:75:5
209218
|
210219
LL | target_pointer_width = "_UNEXPECTED_VALUE",
211220
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -214,7 +223,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE",
214223
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
215224

216225
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
217-
--> $DIR/well-known-values.rs:75:5
226+
--> $DIR/well-known-values.rs:77:5
218227
|
219228
LL | target_thread_local = "_UNEXPECTED_VALUE",
220229
| ^^^^^^^^^^^^^^^^^^^----------------------
@@ -225,7 +234,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE",
225234
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
226235

227236
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
228-
--> $DIR/well-known-values.rs:77:5
237+
--> $DIR/well-known-values.rs:79:5
229238
|
230239
LL | target_vendor = "_UNEXPECTED_VALUE",
231240
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -234,7 +243,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE",
234243
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
235244

236245
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
237-
--> $DIR/well-known-values.rs:79:5
246+
--> $DIR/well-known-values.rs:81:5
238247
|
239248
LL | ub_checks = "_UNEXPECTED_VALUE",
240249
| ^^^^^^^^^----------------------
@@ -245,7 +254,7 @@ LL | ub_checks = "_UNEXPECTED_VALUE",
245254
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
246255

247256
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
248-
--> $DIR/well-known-values.rs:81:5
257+
--> $DIR/well-known-values.rs:83:5
249258
|
250259
LL | unix = "_UNEXPECTED_VALUE",
251260
| ^^^^----------------------
@@ -256,7 +265,7 @@ LL | unix = "_UNEXPECTED_VALUE",
256265
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
257266

258267
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
259-
--> $DIR/well-known-values.rs:83:5
268+
--> $DIR/well-known-values.rs:85:5
260269
|
261270
LL | windows = "_UNEXPECTED_VALUE",
262271
| ^^^^^^^----------------------
@@ -267,7 +276,7 @@ LL | windows = "_UNEXPECTED_VALUE",
267276
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
268277

269278
warning: unexpected `cfg` condition value: `linuz`
270-
--> $DIR/well-known-values.rs:89:7
279+
--> $DIR/well-known-values.rs:91:7
271280
|
272281
LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
273282
| ^^^^^^^^^^^^-------
@@ -277,5 +286,5 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
277286
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
278287
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
279288

280-
warning: 28 warnings emitted
289+
warning: 29 warnings emitted
281290

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//@ build-pass
2+
//@ revisions: unsigned_ signed_ default_
3+
//@ [unsigned_] compile-flags: -Zc-char-type=unsigned
4+
//@ [signed_] compile-flags: -Zc-char-type=signed
5+
//@ [default_] compile-flags: -Zc-char-type=default
6+
7+
#![no_core]
8+
#![crate_type = "rlib"]
9+
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)]
10+
#![stable(feature = "test", since = "1.0.0")]
11+
12+
#[lang="sized"]
13+
trait Sized {}
14+
#[lang = "copy"]
15+
trait Copy {}
16+
impl Copy for bool {}
17+
18+
#[stable(feature = "test", since = "1.0.0")]
19+
#[rustc_const_stable(feature = "test", since = "1.0.0")]
20+
#[rustc_intrinsic]
21+
const unsafe fn unreachable() -> !;
22+
23+
#[rustc_builtin_macro]
24+
macro_rules! cfg {
25+
($($cfg:tt)*) => {};
26+
}
27+
28+
const fn do_or_die(cond: bool) {
29+
if cond {
30+
} else {
31+
unsafe { unreachable() }
32+
}
33+
}
34+
35+
macro_rules! assert {
36+
($x:expr $(,)?) => {
37+
const _: () = do_or_die($x);
38+
};
39+
}
40+
41+
fn main() {
42+
#[cfg(unsigned_)]
43+
assert!(cfg!(c_char_type = "unsigned"));
44+
#[cfg(signed_)]
45+
assert!(cfg!(c_char_type = "signed"));
46+
#[cfg(default_)]
47+
assert!(cfg!(c_char_type = "default"));
48+
}

0 commit comments

Comments
 (0)
Please sign in to comment.