Skip to content

Commit 88b9edc

Browse files
committedAug 28, 2024··
fmt-debug option
Allows disabling `fmt::Debug` derive and debug formatting.
·
1.90.01.82.0
1 parent 100fde5 commit 88b9edc

38 files changed

+285
-56
lines changed
 

‎compiler/rustc_ast_lowering/src/format.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use std::borrow::Cow;
44
use rustc_ast::visit::Visitor;
55
use rustc_ast::*;
66
use rustc_data_structures::fx::FxIndexMap;
7+
use rustc_hir as hir;
8+
use rustc_session::config::FmtDebug;
79
use rustc_span::symbol::{kw, Ident};
810
use rustc_span::{sym, Span, Symbol};
9-
use {rustc_ast as ast, rustc_hir as hir};
1011

1112
use super::LoweringContext;
1213

@@ -243,7 +244,10 @@ fn make_argument<'hir>(
243244
hir::LangItem::FormatArgument,
244245
match ty {
245246
Format(Display) => sym::new_display,
246-
Format(Debug) => sym::new_debug,
247+
Format(Debug) => match ctx.tcx.sess.opts.unstable_opts.fmt_debug {
248+
FmtDebug::Full | FmtDebug::Shallow => sym::new_debug,
249+
FmtDebug::None => sym::new_debug_noop,
250+
},
247251
Format(LowerExp) => sym::new_lower_exp,
248252
Format(UpperExp) => sym::new_upper_exp,
249253
Format(Octal) => sym::new_octal,

‎compiler/rustc_builtin_macros/src/deriving/debug.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_ast::{self as ast, EnumDef, MetaItem};
22
use rustc_expand::base::{Annotatable, ExtCtxt};
3+
use rustc_session::config::FmtDebug;
34
use rustc_span::symbol::{sym, Ident, Symbol};
45
use rustc_span::Span;
56
use thin_vec::{thin_vec, ThinVec};
@@ -49,6 +50,11 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
4950
// We want to make sure we have the ctxt set so that we can use unstable methods
5051
let span = cx.with_def_site_ctxt(span);
5152

53+
let fmt_detail = cx.sess.opts.unstable_opts.fmt_debug;
54+
if fmt_detail == FmtDebug::None {
55+
return BlockOrExpr::new_expr(cx.expr_ok(span, cx.expr_tuple(span, ThinVec::new())));
56+
}
57+
5258
let (ident, vdata, fields) = match substr.fields {
5359
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
5460
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
@@ -61,6 +67,13 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
6167
let name = cx.expr_str(span, ident.name);
6268
let fmt = substr.nonselflike_args[0].clone();
6369

70+
// Fieldless enums have been special-cased earlier
71+
if fmt_detail == FmtDebug::Shallow {
72+
let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
73+
let expr = cx.expr_call_global(span, fn_path_write_str, thin_vec![fmt, name]);
74+
return BlockOrExpr::new_expr(expr);
75+
}
76+
6477
// Struct and tuples are similar enough that we use the same code for both,
6578
// with some extra pieces for structs due to the field names.
6679
let (is_struct, args_per_field) = match vdata {

‎compiler/rustc_feature/src/builtin_attrs.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const GATED_CFGS: &[GatedCfg] = &[
3737
(sym::relocation_model, sym::cfg_relocation_model, cfg_fn!(cfg_relocation_model)),
3838
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
3939
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
40+
// this is consistent with naming of the compiler flag it's for
41+
(sym::fmt_debug, sym::fmt_debug, cfg_fn!(fmt_debug)),
4042
];
4143

4244
/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.

‎compiler/rustc_feature/src/unstable.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ declare_features! (
470470
(unstable, ffi_const, "1.45.0", Some(58328)),
471471
/// Allows the use of `#[ffi_pure]` on foreign functions.
472472
(unstable, ffi_pure, "1.45.0", Some(58329)),
473+
/// Controlling the behavior of fmt::Debug
474+
(unstable, fmt_debug, "CURRENT_RUSTC_VERSION", Some(129709)),
473475
/// Allows using `#[repr(align(...))]` on function items
474476
(unstable, fn_align, "1.53.0", Some(82232)),
475477
/// Support delegating implementation of functions to other already implemented functions.

‎compiler/rustc_interface/src/tests.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use rustc_errors::{registry, ColorConfig};
1010
use rustc_session::config::{
1111
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
1212
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
13-
ErrorOutputType, ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold,
14-
Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail,
15-
LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey,
16-
PacRet, Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip,
17-
SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
13+
ErrorOutputType, ExternEntry, ExternLocation, Externs, FmtDebug, FunctionReturn,
14+
InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
15+
LinkerPluginLto, LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName,
16+
OutputType, OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry, Polonius,
17+
ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
1818
};
1919
use rustc_session::lint::Level;
2020
use rustc_session::search_paths::SearchPath;
@@ -780,6 +780,7 @@ fn test_unstable_options_tracking_hash() {
780780
tracked!(fewer_names, Some(true));
781781
tracked!(fixed_x18, true);
782782
tracked!(flatten_format_args, false);
783+
tracked!(fmt_debug, FmtDebug::Shallow);
783784
tracked!(force_unstable_if_unmarked, true);
784785
tracked!(fuel, Some(("abc".to_string(), 99)));
785786
tracked!(function_return, FunctionReturn::ThunkExtern);

‎compiler/rustc_session/src/config.rs‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ use rustc_feature::UnstableFeatures;
2222
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2323
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
2424
use rustc_span::source_map::FilePathMapping;
25-
use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
25+
use rustc_span::{
26+
sym, FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol,
27+
};
2628
use rustc_target::spec::{
2729
FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple,
2830
};
@@ -402,6 +404,23 @@ impl LocationDetail {
402404
}
403405
}
404406

407+
/// Values for the `-Z fmt-debug` flag.
408+
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
409+
pub enum FmtDebug {
410+
/// Derive fully-featured implementation
411+
Full,
412+
/// Print only type name, without fields
413+
Shallow,
414+
/// `#[derive(Debug)]` and `{:?}` are no-ops
415+
None,
416+
}
417+
418+
impl FmtDebug {
419+
pub(crate) fn all() -> [Symbol; 3] {
420+
[sym::full, sym::none, sym::shallow]
421+
}
422+
}
423+
405424
#[derive(Clone, PartialEq, Hash, Debug)]
406425
pub enum SwitchWithOptPath {
407426
Enabled(Option<PathBuf>),
@@ -2994,7 +3013,7 @@ pub(crate) mod dep_tracking {
29943013

29953014
use super::{
29963015
BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions,
2997-
CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FunctionReturn,
3016+
CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug, FunctionReturn,
29983017
InliningThreshold, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
29993018
LtoCli, NextSolverConfig, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes,
30003019
PatchableFunctionEntry, Polonius, RemapPathScopeComponents, ResolveDocLinks,
@@ -3088,6 +3107,7 @@ pub(crate) mod dep_tracking {
30883107
OutputType,
30893108
RealFileName,
30903109
LocationDetail,
3110+
FmtDebug,
30913111
BranchProtection,
30923112
OomStrategy,
30933113
LanguageIdentifier,

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_span::symbol::{sym, Symbol};
3131
use rustc_target::abi::Align;
3232
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target, TargetTriple, TARGETS};
3333

34-
use crate::config::CrateType;
34+
use crate::config::{CrateType, FmtDebug};
3535
use crate::Session;
3636

3737
/// The parsed `--cfg` options that define the compilation environment of the
@@ -142,6 +142,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
142142
| (sym::target_has_atomic_equal_alignment, Some(_))
143143
| (sym::target_has_atomic_load_store, Some(_))
144144
| (sym::target_thread_local, None) => disallow(cfg, "--target"),
145+
(sym::fmt_debug, None | Some(_)) => disallow(cfg, "-Z fmt-debug"),
145146
_ => {}
146147
}
147148
}
@@ -179,6 +180,20 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
179180
ins_none!(sym::debug_assertions);
180181
}
181182

183+
if sess.is_nightly_build() {
184+
match sess.opts.unstable_opts.fmt_debug {
185+
FmtDebug::Full => {
186+
ins_sym!(sym::fmt_debug, sym::full);
187+
}
188+
FmtDebug::Shallow => {
189+
ins_sym!(sym::fmt_debug, sym::shallow);
190+
}
191+
FmtDebug::None => {
192+
ins_sym!(sym::fmt_debug, sym::none);
193+
}
194+
}
195+
}
196+
182197
if sess.overflow_checks() {
183198
ins_none!(sym::overflow_checks);
184199
}
@@ -326,6 +341,8 @@ impl CheckCfg {
326341

327342
ins!(sym::debug_assertions, no_values);
328343

344+
ins!(sym::fmt_debug, empty_values).extend(FmtDebug::all());
345+
329346
// These four are never set by rustc, but we set them anyway; they
330347
// should not trigger the lint because `cargo clippy`, `cargo doc`,
331348
// `cargo test`, `cargo miri run` and `cargo fmt` (respectively)

‎compiler/rustc_session/src/options.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ mod desc {
408408
pub const parse_linker_plugin_lto: &str =
409409
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
410410
pub const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
411+
pub const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
411412
pub const parse_switch_with_opt_path: &str =
412413
"an optional path to the profiling data output directory";
413414
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
@@ -589,6 +590,16 @@ mod parse {
589590
}
590591
}
591592

593+
pub(crate) fn parse_fmt_debug(opt: &mut FmtDebug, v: Option<&str>) -> bool {
594+
*opt = match v {
595+
Some("full") => FmtDebug::Full,
596+
Some("shallow") => FmtDebug::Shallow,
597+
Some("none") => FmtDebug::None,
598+
_ => return false,
599+
};
600+
true
601+
}
602+
592603
pub(crate) fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
593604
if let Some(v) = v {
594605
ld.line = false;
@@ -1724,6 +1735,9 @@ options! {
17241735
flatten_format_args: bool = (true, parse_bool, [TRACKED],
17251736
"flatten nested format_args!() and literals into a simplified format_args!() call \
17261737
(default: yes)"),
1738+
fmt_debug: FmtDebug = (FmtDebug::Full, parse_fmt_debug, [TRACKED],
1739+
"how detailed `#[derive(Debug)]` should be. `full` prints types recursively, \
1740+
`shallow` prints only type names, `none` prints nothing and disables `{:?}`. (default: `full`)"),
17271741
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
17281742
"force all crates to be `rustc_private` unstable (default: no)"),
17291743
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],

‎compiler/rustc_span/src/symbol.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ symbols! {
535535
cfg_attr_multi,
536536
cfg_doctest,
537537
cfg_eval,
538+
cfg_fmt_debug,
538539
cfg_hide,
539540
cfg_overflow_checks,
540541
cfg_panic,
@@ -894,6 +895,7 @@ symbols! {
894895
fmaf32,
895896
fmaf64,
896897
fmt,
898+
fmt_debug,
897899
fmul_algebraic,
898900
fmul_fast,
899901
fn_align,
@@ -937,6 +939,7 @@ symbols! {
937939
fs_create_dir,
938940
fsub_algebraic,
939941
fsub_fast,
942+
full,
940943
fundamental,
941944
fused_iterator,
942945
future,
@@ -1280,6 +1283,7 @@ symbols! {
12801283
new_binary,
12811284
new_const,
12821285
new_debug,
1286+
new_debug_noop,
12831287
new_display,
12841288
new_lower_exp,
12851289
new_lower_hex,
@@ -1714,6 +1718,7 @@ symbols! {
17141718
semitransparent,
17151719
sha512_sm_x86,
17161720
shadow_call_stack,
1721+
shallow,
17171722
shl,
17181723
shl_assign,
17191724
shorter_tail_lifetimes,

‎library/core/src/fmt/rt.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ impl<'a> Argument<'a> {
118118
Self::new(x, Debug::fmt)
119119
}
120120
#[inline(always)]
121+
pub fn new_debug_noop<'b, T: Debug>(x: &'b T) -> Argument<'_> {
122+
Self::new(x, |_, _| Ok(()))
123+
}
124+
#[inline(always)]
121125
pub fn new_octal<'b, T: Octal>(x: &'b T) -> Argument<'_> {
122126
Self::new(x, Octal::fmt)
123127
}

‎src/doc/rustc/src/check-cfg.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ the need to specify them manually.
9999
Well known names and values are implicitly added as long as at least one `--check-cfg` argument
100100
is present.
101101
102-
As of `2024-05-06T`, the list of known names is as follows:
102+
As of `2024-08-20T`, the list of known names is as follows:
103103
104104
<!--- See CheckCfg::fill_well_known in compiler/rustc_session/src/config.rs -->
105105
106106
- `clippy`
107107
- `debug_assertions`
108108
- `doc`
109109
- `doctest`
110+
- `fmt_debug`
110111
- `miri`
111112
- `overflow_checks`
112113
- `panic`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# `fmt-debug`
2+
3+
The tracking issue for this feature is: [#129709](https://github.com/rust-lang/rust/issues/129709).
4+
5+
------------------------
6+
7+
Option `-Z fmt-debug=val` controls verbosity of derived `Debug` implementations
8+
and debug formatting in format strings (`{:?}`).
9+
10+
* `full``#[derive(Debug)]` prints types recursively. This is the default behavior.
11+
12+
* `shallow``#[derive(Debug)]` prints only the type name, or name of a variant of a fieldless enums. Details of the `Debug` implementation are not stable and may change in the future. Behavior of custom `fmt::Debug` implementations is not affected.
13+
14+
* `none``#[derive(Debug)]` does not print anything at all. `{:?}` in formatting strings has no effect.
15+
This option may reduce size of binaries, and remove occurrences of type names in the binary that are not removed by striping symbols. However, it may also cause `panic!` and `assert!` messages to be incomplete.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: unexpected `--cfg fmt_debug="shallow"` flag
2+
|
3+
= note: config `fmt_debug` is only supposed to be controlled by `-Z fmt-debug`
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‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//@ revisions: target_pointer_width_ target_vendor_ target_has_atomic_
77
//@ revisions: target_has_atomic_equal_alignment_ target_has_atomic_load_store_
88
//@ revisions: target_thread_local_ relocation_model_
9+
//@ revisions: fmt_debug_
910

1011
//@ [overflow_checks_]compile-flags: --cfg overflow_checks
1112
//@ [debug_assertions_]compile-flags: --cfg debug_assertions
@@ -31,5 +32,6 @@
3132
//@ [target_has_atomic_load_store_]compile-flags: --cfg target_has_atomic_load_store="32"
3233
//@ [target_thread_local_]compile-flags: --cfg target_thread_local
3334
//@ [relocation_model_]compile-flags: --cfg relocation_model="a"
35+
//@ [fmt_debug_]compile-flags: --cfg fmt_debug="shallow"
3436

3537
fn main() {}

‎tests/ui/check-cfg/allow-same-level.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `FALSE`
44
LL | #[cfg(FALSE)]
55
| ^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
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

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

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `has_bar`, `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`
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `has_bar`, `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`
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‎

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`
28+
= 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`
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‎

Lines changed: 1 addition & 1 deletion
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`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`
28+
= help: expected names are: `CONFIG_NVME`, `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`
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‎

Lines changed: 1 addition & 1 deletion
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`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `foo`, `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`
7+
= help: expected names are: `bar`, `bee`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `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`
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‎

Lines changed: 1 addition & 1 deletion
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`, `clippy`, `debug_assertions`, `doc`, `doctest`, `foo`, `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`
7+
= help: expected names are: `bar`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `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`
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/cfg-value-for-cfg-name.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `linux`
44
LL | #[cfg(linux)]
55
| ^^^^^ help: found config with similar value: `target_os = "linux"`
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(linux)`
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/compact-names.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `target_architecture`
44
LL | #[cfg(target(os = "linux", architecture = "arm"))]
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))`
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.empty_cfg.stderr‎

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
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.feature.stderr‎

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`
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`
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‎

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`
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`
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.stderr‎

Lines changed: 1 addition & 1 deletion
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: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu`
4444
LL | #[cfg_attr(uu, test)]
4545
| ^^
4646
|
47-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `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`
47+
= 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`
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/stmt-no-ice.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `crossbeam_loom`
44
LL | #[cfg(crossbeam_loom)]
55
| ^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
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`, `test`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(crossbeam_loom)`
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/well-known-names.stderr‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ warning: unexpected `cfg` condition name: `features`
1818
LL | #[cfg(features = "foo")]
1919
| ^^^^^^^^^^^^^^^^
2020
|
21-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `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`
21+
= 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`, `test`, `ub_checks`, `unix`, and `windows`
2222
= help: to expect this configuration use `--check-cfg=cfg(features, values("foo"))`
2323
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2424

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![feature(cfg_target_has_atomic_equal_alignment)]
1717
#![feature(cfg_target_thread_local)]
1818
#![feature(cfg_ub_checks)]
19+
#![feature(fmt_debug)]
1920

2021
// This part makes sure that none of the well known names are
2122
// unexpected.
@@ -33,6 +34,8 @@
3334
//~^ WARN unexpected `cfg` condition value
3435
doctest = "_UNEXPECTED_VALUE",
3536
//~^ WARN unexpected `cfg` condition value
37+
fmt_debug = "_UNEXPECTED_VALUE",
38+
//~^ WARN unexpected `cfg` condition value
3639
miri = "_UNEXPECTED_VALUE",
3740
//~^ WARN unexpected `cfg` condition value
3841
overflow_checks = "_UNEXPECTED_VALUE",

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

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
2-
--> $DIR/well-known-values.rs:28:5
2+
--> $DIR/well-known-values.rs:29:5
33
|
44
LL | clippy = "_UNEXPECTED_VALUE",
55
| ^^^^^^----------------------
@@ -11,7 +11,7 @@ LL | clippy = "_UNEXPECTED_VALUE",
1111
= note: `#[warn(unexpected_cfgs)]` on by default
1212

1313
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
14-
--> $DIR/well-known-values.rs:30:5
14+
--> $DIR/well-known-values.rs:31:5
1515
|
1616
LL | debug_assertions = "_UNEXPECTED_VALUE",
1717
| ^^^^^^^^^^^^^^^^----------------------
@@ -22,7 +22,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE",
2222
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2323

2424
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
25-
--> $DIR/well-known-values.rs:32:5
25+
--> $DIR/well-known-values.rs:33:5
2626
|
2727
LL | doc = "_UNEXPECTED_VALUE",
2828
| ^^^----------------------
@@ -33,7 +33,7 @@ LL | doc = "_UNEXPECTED_VALUE",
3333
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
3434

3535
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
36-
--> $DIR/well-known-values.rs:34:5
36+
--> $DIR/well-known-values.rs:35:5
3737
|
3838
LL | doctest = "_UNEXPECTED_VALUE",
3939
| ^^^^^^^----------------------
@@ -44,7 +44,16 @@ LL | doctest = "_UNEXPECTED_VALUE",
4444
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
4545

4646
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
47-
--> $DIR/well-known-values.rs:36:5
47+
--> $DIR/well-known-values.rs:37:5
48+
|
49+
LL | fmt_debug = "_UNEXPECTED_VALUE",
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51+
|
52+
= note: expected values for `fmt_debug` are: `full`, `none`, and `shallow`
53+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
54+
55+
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
56+
--> $DIR/well-known-values.rs:39:5
4857
|
4958
LL | miri = "_UNEXPECTED_VALUE",
5059
| ^^^^----------------------
@@ -55,7 +64,7 @@ LL | miri = "_UNEXPECTED_VALUE",
5564
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
5665

5766
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
58-
--> $DIR/well-known-values.rs:38:5
67+
--> $DIR/well-known-values.rs:41:5
5968
|
6069
LL | overflow_checks = "_UNEXPECTED_VALUE",
6170
| ^^^^^^^^^^^^^^^----------------------
@@ -66,7 +75,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE",
6675
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
6776

6877
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
69-
--> $DIR/well-known-values.rs:40:5
78+
--> $DIR/well-known-values.rs:43:5
7079
|
7180
LL | panic = "_UNEXPECTED_VALUE",
7281
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -75,7 +84,7 @@ LL | panic = "_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:42:5
87+
--> $DIR/well-known-values.rs:45:5
7988
|
8089
LL | proc_macro = "_UNEXPECTED_VALUE",
8190
| ^^^^^^^^^^----------------------
@@ -86,7 +95,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE",
8695
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
8796

8897
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
89-
--> $DIR/well-known-values.rs:44:5
98+
--> $DIR/well-known-values.rs:47:5
9099
|
91100
LL | relocation_model = "_UNEXPECTED_VALUE",
92101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -95,7 +104,7 @@ LL | relocation_model = "_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:46:5
107+
--> $DIR/well-known-values.rs:49:5
99108
|
100109
LL | rustfmt = "_UNEXPECTED_VALUE",
101110
| ^^^^^^^----------------------
@@ -106,7 +115,7 @@ LL | rustfmt = "_UNEXPECTED_VALUE",
106115
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
107116

108117
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
109-
--> $DIR/well-known-values.rs:48:5
118+
--> $DIR/well-known-values.rs:51:5
110119
|
111120
LL | sanitize = "_UNEXPECTED_VALUE",
112121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -115,7 +124,7 @@ LL | sanitize = "_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:50:5
127+
--> $DIR/well-known-values.rs:53:5
119128
|
120129
LL | target_abi = "_UNEXPECTED_VALUE",
121130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -124,7 +133,7 @@ LL | target_abi = "_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:52:5
136+
--> $DIR/well-known-values.rs:55:5
128137
|
129138
LL | target_arch = "_UNEXPECTED_VALUE",
130139
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -133,7 +142,7 @@ LL | target_arch = "_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:54:5
145+
--> $DIR/well-known-values.rs:57:5
137146
|
138147
LL | target_endian = "_UNEXPECTED_VALUE",
139148
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -142,7 +151,7 @@ LL | target_endian = "_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:56:5
154+
--> $DIR/well-known-values.rs:59:5
146155
|
147156
LL | target_env = "_UNEXPECTED_VALUE",
148157
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -151,7 +160,7 @@ LL | target_env = "_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:58:5
163+
--> $DIR/well-known-values.rs:61:5
155164
|
156165
LL | target_family = "_UNEXPECTED_VALUE",
157166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -160,7 +169,7 @@ LL | target_family = "_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:60:5
172+
--> $DIR/well-known-values.rs:63:5
164173
|
165174
LL | target_feature = "_UNEXPECTED_VALUE",
166175
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,7 +178,7 @@ LL | target_feature = "_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:62:5
181+
--> $DIR/well-known-values.rs:65: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:64:5
190+
--> $DIR/well-known-values.rs:67: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:66:5
199+
--> $DIR/well-known-values.rs:69: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:68:5
208+
--> $DIR/well-known-values.rs:71: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:70:5
217+
--> $DIR/well-known-values.rs:73: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:72:5
226+
--> $DIR/well-known-values.rs:75: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:74:5
237+
--> $DIR/well-known-values.rs:77: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:76:5
246+
--> $DIR/well-known-values.rs:79:5
238247
|
239248
LL | test = "_UNEXPECTED_VALUE",
240249
| ^^^^----------------------
@@ -245,7 +254,7 @@ LL | test = "_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:78:5
257+
--> $DIR/well-known-values.rs:81:5
249258
|
250259
LL | ub_checks = "_UNEXPECTED_VALUE",
251260
| ^^^^^^^^^----------------------
@@ -256,7 +265,7 @@ LL | ub_checks = "_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:80:5
268+
--> $DIR/well-known-values.rs:83:5
260269
|
261270
LL | unix = "_UNEXPECTED_VALUE",
262271
| ^^^^----------------------
@@ -267,7 +276,7 @@ LL | unix = "_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: `_UNEXPECTED_VALUE`
270-
--> $DIR/well-known-values.rs:82:5
279+
--> $DIR/well-known-values.rs:85:5
271280
|
272281
LL | windows = "_UNEXPECTED_VALUE",
273282
| ^^^^^^^----------------------
@@ -278,7 +287,7 @@ LL | windows = "_UNEXPECTED_VALUE",
278287
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
279288

280289
warning: unexpected `cfg` condition value: `linuz`
281-
--> $DIR/well-known-values.rs:88:7
290+
--> $DIR/well-known-values.rs:91:7
282291
|
283292
LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
284293
| ^^^^^^^^^^^^-------
@@ -288,5 +297,5 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
288297
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
289298
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
290299

291-
warning: 29 warnings emitted
300+
warning: 30 warnings emitted
292301

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[cfg(fmt_debug = "full")]
2+
//~^ ERROR is experimental
3+
fn main() {
4+
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: `cfg(fmt_debug)` is experimental and subject to change
2+
--> $DIR/feature-gate-fmt-debug.rs:1:7
3+
|
4+
LL | #[cfg(fmt_debug = "full")]
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #129709 <https://github.com/rust-lang/rust/issues/129709> for more information
8+
= help: add `#![feature(fmt_debug)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.

‎tests/ui/fmt/fmt_debug/full.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -Zfmt-debug=full
2+
//@ run-pass
3+
#![feature(fmt_debug)]
4+
#![allow(dead_code)]
5+
#![allow(unused)]
6+
7+
#[derive(Debug)]
8+
struct Foo {
9+
bar: u32,
10+
}
11+
12+
fn main() {
13+
let s = format!("Still works: {:?} '{:?}'", cfg!(fmt_debug = "full"), Foo { bar: 1 });
14+
assert_eq!("Still works: true 'Foo { bar: 1 }'", s);
15+
}

‎tests/ui/fmt/fmt_debug/invalid.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ compile-flags: -Zfmt-debug=invalid-value
2+
//@ failure-status: 1
3+
fn main() {
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `invalid-value` for unstable option `fmt-debug` - either `full`, `shallow`, or `none` was expected
2+

‎tests/ui/fmt/fmt_debug/none.rs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ compile-flags: -Zfmt-debug=none
2+
//@ run-pass
3+
#![feature(fmt_debug)]
4+
#![allow(dead_code)]
5+
#![allow(unused)]
6+
7+
#[derive(Debug)]
8+
struct Foo {
9+
bar: u32,
10+
}
11+
12+
#[derive(Debug)]
13+
enum Baz {
14+
Quz,
15+
}
16+
17+
#[cfg(fmt_debug = "full")]
18+
compile_error!("nope");
19+
20+
#[cfg(fmt_debug = "none")]
21+
struct Custom;
22+
23+
impl std::fmt::Debug for Custom {
24+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25+
f.write_str("custom_fmt")
26+
}
27+
}
28+
29+
fn main() {
30+
let c = Custom;
31+
let s = format!("Debug is '{:?}', '{:#?}', and '{c:?}'", Foo { bar: 1 }, Baz::Quz);
32+
assert_eq!("Debug is '', '', and ''", s);
33+
34+
let f = 3.0;
35+
let s = format_args!("{:?}x{:#?}y{f:?}", 1234, "can't debug this").to_string();
36+
assert_eq!("xy", s);
37+
}

‎tests/ui/fmt/fmt_debug/shallow.rs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ compile-flags: -Zfmt-debug=shallow
2+
//@ run-pass
3+
#![feature(fmt_debug)]
4+
#![allow(dead_code)]
5+
#![allow(unused)]
6+
7+
#[derive(Debug)]
8+
struct Foo {
9+
bar: u32,
10+
bomb: Bomb,
11+
}
12+
13+
#[derive(Debug)]
14+
enum Baz {
15+
Quz,
16+
}
17+
18+
struct Bomb;
19+
20+
impl std::fmt::Debug for Bomb {
21+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22+
panic!()
23+
}
24+
}
25+
26+
fn main() {
27+
let s = format!("Debug is '{:?}' and '{:#?}'", Foo { bar: 1, bomb: Bomb }, Baz::Quz);
28+
assert_eq!("Debug is 'Foo' and 'Quz'", s);
29+
30+
let f = 3.0;
31+
let s = format_args!("{:?}{:#?}{f:?}", 1234, cfg!(fmt_debug = "shallow")).to_string();
32+
assert_eq!("1234true3.0", s);
33+
}

0 commit comments

Comments
 (0)
Please sign in to comment.