authorbors <bors@rust-lang.org> 2024-08-29 20:45:00 UTC
committerbors <bors@rust-lang.org> 2024-08-29 20:45:00 UTC
log0d634185dfddefe09047881175f35c65d68dcff1
treec85fc78596b0d89063efefc1e1f3437e51c7e15e
parent784d444733d65c3d305ce5edcbb41e3d0d0aee2e
parent9c7ae1d4d88b5212eabff72441b7d316e52df164

Auto merge of #129750 - GuillaumeGomez:rollup-gphsb7y, r=GuillaumeGomez

Rollup of 7 pull requests Successful merges: - #123940 (debug-fmt-detail option) - #128166 (Improved `checked_isqrt` and `isqrt` methods) - #128970 (Add `-Zlint-llvm-ir`) - #129316 (riscv64imac: allow shadow call stack sanitizer) - #129690 (Add `needs-unwind` compiletest directive to `libtest-thread-limit` and replace some `Path` with `path` in `run-make`) - #129732 (Add `unreachable_pub`, round 3) - #129743 (Fix rustdoc clippy lints) r? `@ghost` `@rustbot` modify labels: rollup

141 files changed, 1587 insertions(+), 644 deletions(-)

compiler/rustc_ast_lowering/src/format.rs+6-2
......@@ -4,9 +4,10 @@ use std::borrow::Cow;
44use rustc_ast::visit::Visitor;
55use rustc_ast::*;
66use rustc_data_structures::fx::FxIndexMap;
7use rustc_hir as hir;
8use rustc_session::config::FmtDebug;
79use rustc_span::symbol::{kw, Ident};
810use rustc_span::{sym, Span, Symbol};
9use {rustc_ast as ast, rustc_hir as hir};
1011
1112use 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+13
......@@ -1,5 +1,6 @@
11use rustc_ast::{self as ast, EnumDef, MetaItem};
22use rustc_expand::base::{Annotatable, ExtCtxt};
3use rustc_session::config::FmtDebug;
34use rustc_span::symbol::{sym, Ident, Symbol};
45use rustc_span::Span;
56use 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_codegen_llvm/src/back/write.rs+1
......@@ -571,6 +571,7 @@ pub(crate) unsafe fn llvm_optimize(
571571 cgcx.opts.cg.linker_plugin_lto.enabled(),
572572 config.no_prepopulate_passes,
573573 config.verify_llvm_ir,
574 config.lint_llvm_ir,
574575 using_thin_buffers,
575576 config.merge_functions,
576577 unroll_loops,
compiler/rustc_codegen_llvm/src/llvm/ffi.rs+1
......@@ -2225,6 +2225,7 @@ unsafe extern "C" {
22252225 IsLinkerPluginLTO: bool,
22262226 NoPrepopulatePasses: bool,
22272227 VerifyIR: bool,
2228 LintIR: bool,
22282229 UseThinLTOBuffers: bool,
22292230 MergeFunctions: bool,
22302231 UnrollLoops: bool,
compiler/rustc_codegen_ssa/src/back/write.rs+2
......@@ -112,6 +112,7 @@ pub struct ModuleConfig {
112112 // Miscellaneous flags. These are mostly copied from command-line
113113 // options.
114114 pub verify_llvm_ir: bool,
115 pub lint_llvm_ir: bool,
115116 pub no_prepopulate_passes: bool,
116117 pub no_builtins: bool,
117118 pub time_module: bool,
......@@ -237,6 +238,7 @@ impl ModuleConfig {
237238 bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(),
238239
239240 verify_llvm_ir: sess.verify_llvm_ir(),
241 lint_llvm_ir: sess.opts.unstable_opts.lint_llvm_ir,
240242 no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
241243 no_builtins: no_builtins || sess.target.no_builtins,
242244
compiler/rustc_feature/src/builtin_attrs.rs+2
......@@ -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+2
......@@ -471,6 +471,8 @@ declare_features! (
471471 (unstable, ffi_const, "1.45.0", Some(58328)),
472472 /// Allows the use of `#[ffi_pure]` on foreign functions.
473473 (unstable, ffi_pure, "1.45.0", Some(58329)),
474 /// Controlling the behavior of fmt::Debug
475 (unstable, fmt_debug, "CURRENT_RUSTC_VERSION", Some(129709)),
474476 /// Allows using `#[repr(align(...))]` on function items
475477 (unstable, fn_align, "1.53.0", Some(82232)),
476478 /// Support delegating implementation of functions to other already implemented functions.
compiler/rustc_interface/src/tests.rs+7-5
......@@ -10,11 +10,11 @@ use rustc_errors::{registry, ColorConfig};
1010use 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};
1919use rustc_session::lint::Level;
2020use 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);
......@@ -794,6 +795,7 @@ fn test_unstable_options_tracking_hash() {
794795 tracked!(instrument_xray, Some(InstrumentXRay::default()));
795796 tracked!(link_directives, false);
796797 tracked!(link_only, true);
798 tracked!(lint_llvm_ir, true);
797799 tracked!(llvm_module_flag, vec![("bar".to_string(), 123, "max".to_string())]);
798800 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
799801 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp+8-1
......@@ -713,7 +713,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
713713 LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
714714 LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
715715 bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
716 bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops,
716 bool LintIR, bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops,
717717 bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
718718 bool EmitLifetimeMarkers, LLVMRustSanitizerOptions *SanitizerOptions,
719719 const char *PGOGenPath, const char *PGOUsePath, bool InstrumentCoverage,
......@@ -842,6 +842,13 @@ extern "C" LLVMRustResult LLVMRustOptimize(
842842 });
843843 }
844844
845 if (LintIR) {
846 PipelineStartEPCallbacks.push_back(
847 [](ModulePassManager &MPM, OptimizationLevel Level) {
848 MPM.addPass(createModuleToFunctionPassAdaptor(LintPass()));
849 });
850 }
851
845852 if (InstrumentGCOV) {
846853 PipelineStartEPCallbacks.push_back(
847854 [](ModulePassManager &MPM, OptimizationLevel Level) {
compiler/rustc_macros/src/diagnostics/mod.rs+3-3
......@@ -55,7 +55,7 @@ use synstructure::Structure;
5555///
5656/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
5757/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
58pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
58pub(super) fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
5959 s.underscore_const(true);
6060 DiagnosticDerive::new(s).into_tokens()
6161}
......@@ -102,7 +102,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
102102///
103103/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
104104/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
105pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
105pub(super) fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
106106 s.underscore_const(true);
107107 LintDiagnosticDerive::new(s).into_tokens()
108108}
......@@ -153,7 +153,7 @@ pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
153153///
154154/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
155155/// ```
156pub fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
156pub(super) fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
157157 s.underscore_const(true);
158158 SubdiagnosticDerive::new().into_tokens(s)
159159}
compiler/rustc_macros/src/lib.rs+1
......@@ -6,6 +6,7 @@
66#![feature(proc_macro_diagnostic)]
77#![feature(proc_macro_span)]
88#![feature(proc_macro_tracked_env)]
9#![warn(unreachable_pub)]
910// tidy-alphabetical-end
1011
1112use proc_macro::TokenStream;
compiler/rustc_macros/src/lift.rs+1-1
......@@ -1,7 +1,7 @@
11use quote::quote;
22use syn::parse_quote;
33
4pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
4pub(super) fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
55 s.add_bounds(synstructure::AddBounds::Generics);
66 s.bind_with(|_| synstructure::BindStyle::Move);
77 s.underscore_const(true);
compiler/rustc_macros/src/query.rs+1-1
......@@ -307,7 +307,7 @@ fn add_query_desc_cached_impl(
307307 });
308308}
309309
310pub fn rustc_queries(input: TokenStream) -> TokenStream {
310pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
311311 let queries = parse_macro_input!(input as List<Query>);
312312
313313 let mut query_stream = quote! {};
compiler/rustc_macros/src/serialize.rs+20-8
......@@ -3,7 +3,9 @@ use quote::{quote, quote_spanned};
33use syn::parse_quote;
44use syn::spanned::Spanned;
55
6pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
6pub(super) fn type_decodable_derive(
7 mut s: synstructure::Structure<'_>,
8) -> proc_macro2::TokenStream {
79 let decoder_ty = quote! { __D };
810 let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
911 quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
......@@ -20,7 +22,9 @@ pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
2022 decodable_body(s, decoder_ty)
2123}
2224
23pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
25pub(super) fn meta_decodable_derive(
26 mut s: synstructure::Structure<'_>,
27) -> proc_macro2::TokenStream {
2428 if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
2529 s.add_impl_generic(parse_quote! { 'tcx });
2630 }
......@@ -32,7 +36,7 @@ pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
3236 decodable_body(s, decoder_ty)
3337}
3438
35pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
39pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
3640 let decoder_ty = quote! { __D };
3741 s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_span::SpanDecoder });
3842 s.add_bounds(synstructure::AddBounds::Generics);
......@@ -41,7 +45,9 @@ pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
4145 decodable_body(s, decoder_ty)
4246}
4347
44pub fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
48pub(super) fn decodable_generic_derive(
49 mut s: synstructure::Structure<'_>,
50) -> proc_macro2::TokenStream {
4551 let decoder_ty = quote! { __D };
4652 s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
4753 s.add_bounds(synstructure::AddBounds::Generics);
......@@ -123,7 +129,9 @@ fn decode_field(field: &syn::Field) -> proc_macro2::TokenStream {
123129 quote_spanned! { field_span=> #decode_inner_method(#__decoder) }
124130}
125131
126pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
132pub(super) fn type_encodable_derive(
133 mut s: synstructure::Structure<'_>,
134) -> proc_macro2::TokenStream {
127135 let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
128136 quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
129137 } else if s.ast().generics.type_params().any(|ty| ty.ident == "I") {
......@@ -140,7 +148,9 @@ pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
140148 encodable_body(s, encoder_ty, false)
141149}
142150
143pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
151pub(super) fn meta_encodable_derive(
152 mut s: synstructure::Structure<'_>,
153) -> proc_macro2::TokenStream {
144154 if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
145155 s.add_impl_generic(parse_quote! { 'tcx });
146156 }
......@@ -152,7 +162,7 @@ pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
152162 encodable_body(s, encoder_ty, true)
153163}
154164
155pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
165pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
156166 let encoder_ty = quote! { __E };
157167 s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder });
158168 s.add_bounds(synstructure::AddBounds::Generics);
......@@ -161,7 +171,9 @@ pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
161171 encodable_body(s, encoder_ty, false)
162172}
163173
164pub fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
174pub(super) fn encodable_generic_derive(
175 mut s: synstructure::Structure<'_>,
176) -> proc_macro2::TokenStream {
165177 let encoder_ty = quote! { __E };
166178 s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
167179 s.add_bounds(synstructure::AddBounds::Generics);
compiler/rustc_macros/src/symbols.rs+1-1
......@@ -131,7 +131,7 @@ impl Errors {
131131 }
132132}
133133
134pub fn symbols(input: TokenStream) -> TokenStream {
134pub(super) fn symbols(input: TokenStream) -> TokenStream {
135135 let (mut output, errors) = symbols_with_errors(input);
136136
137137 // If we generated any errors, then report them as compiler_error!() macro calls.
compiler/rustc_macros/src/type_foldable.rs+1-1
......@@ -1,7 +1,7 @@
11use quote::{quote, ToTokens};
22use syn::parse_quote;
33
4pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
4pub(super) fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
55 if let syn::Data::Union(_) = s.ast().data {
66 panic!("cannot derive on union")
77 }
compiler/rustc_macros/src/type_visitable.rs+3-1
......@@ -1,7 +1,9 @@
11use quote::quote;
22use syn::parse_quote;
33
4pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
4pub(super) fn type_visitable_derive(
5 mut s: synstructure::Structure<'_>,
6) -> proc_macro2::TokenStream {
57 if let syn::Data::Union(_) = s.ast().data {
68 panic!("cannot derive on union")
79 }
compiler/rustc_metadata/src/lib.rs+1
......@@ -16,6 +16,7 @@
1616#![feature(proc_macro_internals)]
1717#![feature(rustdoc_internals)]
1818#![feature(trusted_len)]
19#![warn(unreachable_pub)]
1920// tidy-alphabetical-end
2021
2122extern crate proc_macro;
compiler/rustc_metadata/src/rmeta/decoder.rs+5-5
......@@ -56,13 +56,13 @@ impl std::ops::Deref for MetadataBlob {
5656
5757impl MetadataBlob {
5858 /// Runs the [`MemDecoder`] validation and if it passes, constructs a new [`MetadataBlob`].
59 pub fn new(slice: OwnedSlice) -> Result<Self, ()> {
59 pub(crate) fn new(slice: OwnedSlice) -> Result<Self, ()> {
6060 if MemDecoder::new(&slice, 0).is_ok() { Ok(Self(slice)) } else { Err(()) }
6161 }
6262
6363 /// Since this has passed the validation of [`MetadataBlob::new`], this returns bytes which are
6464 /// known to pass the [`MemDecoder`] validation.
65 pub fn bytes(&self) -> &OwnedSlice {
65 pub(crate) fn bytes(&self) -> &OwnedSlice {
6666 &self.0
6767 }
6868}
......@@ -332,12 +332,12 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
332332 }
333333
334334 #[inline]
335 pub fn blob(&self) -> &'a MetadataBlob {
335 pub(crate) fn blob(&self) -> &'a MetadataBlob {
336336 self.blob
337337 }
338338
339339 #[inline]
340 pub fn cdata(&self) -> CrateMetadataRef<'a> {
340 fn cdata(&self) -> CrateMetadataRef<'a> {
341341 debug_assert!(self.cdata.is_some(), "missing CrateMetadata in DecodeContext");
342342 self.cdata.unwrap()
343343 }
......@@ -377,7 +377,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
377377 }
378378
379379 #[inline]
380 pub fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
380 fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
381381 self.opaque.read_raw_bytes(len)
382382 }
383383}
compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs+1-1
......@@ -17,7 +17,7 @@ parameterized_over_tcx! {
1717
1818impl DefPathHashMapRef<'_> {
1919 #[inline]
20 pub fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
20 pub(crate) fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
2121 match *self {
2222 DefPathHashMapRef::OwnedFromMetadata(ref map) => {
2323 map.get(&def_path_hash.local_hash()).unwrap()
compiler/rustc_metadata/src/rmeta/encoder.rs+1-1
......@@ -2309,7 +2309,7 @@ fn encode_root_position(mut file: &File, pos: usize) -> Result<(), std::io::Erro
23092309 Ok(())
23102310}
23112311
2312pub fn provide(providers: &mut Providers) {
2312pub(crate) fn provide(providers: &mut Providers) {
23132313 *providers = Providers {
23142314 doc_link_resolutions: |tcx, def_id| {
23152315 tcx.resolutions(())
compiler/rustc_middle/src/dep_graph/dep_node.rs+3-2
......@@ -61,8 +61,9 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LO
6161use rustc_hir::definitions::DefPathHash;
6262use rustc_hir::{HirId, ItemLocalId, OwnerId};
6363pub use rustc_query_system::dep_graph::dep_node::DepKind;
64pub use rustc_query_system::dep_graph::DepNode;
6465use rustc_query_system::dep_graph::FingerprintStyle;
65pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams};
66pub(crate) use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
6667use rustc_span::symbol::Symbol;
6768
6869use crate::mir::mono::MonoItem;
......@@ -101,7 +102,7 @@ macro_rules! define_dep_nodes {
101102
102103 // This checks that the discriminants of the variants have been assigned consecutively
103104 // from 0 so that they can be used as a dense index.
104 pub const DEP_KIND_VARIANTS: u16 = {
105 pub(crate) const DEP_KIND_VARIANTS: u16 = {
105106 let deps = &[$(dep_kinds::$variant,)*];
106107 let mut i = 0;
107108 while i < deps.len() {
compiler/rustc_middle/src/lib.rs+1
......@@ -62,6 +62,7 @@
6262#![feature(try_blocks)]
6363#![feature(type_alias_impl_trait)]
6464#![feature(yeet_expr)]
65#![warn(unreachable_pub)]
6566// tidy-alphabetical-end
6667
6768#[cfg(test)]
compiler/rustc_middle/src/mir/basic_blocks.rs+2-2
......@@ -18,9 +18,9 @@ pub struct BasicBlocks<'tcx> {
1818}
1919
2020// Typically 95%+ of basic blocks have 4 or fewer predecessors.
21pub type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;
21type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;
2222
23pub type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
23type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
2424
2525#[derive(Clone, Default, Debug)]
2626struct Cache {
compiler/rustc_middle/src/mir/generic_graph.rs+1-1
......@@ -2,7 +2,7 @@ use gsgdt::{Edge, Graph, Node, NodeStyle};
22use rustc_middle::mir::*;
33
44/// Convert an MIR function into a gsgdt Graph
5pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph {
5pub(crate) fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph {
66 let def_id = body.source.def_id();
77 let def_name = graphviz_safe_def_name(def_id);
88 let graph_name = format!("Mir_{def_name}");
compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs+1-1
......@@ -243,7 +243,7 @@ impl hash::Hash for InitMaskMaterialized {
243243}
244244
245245impl InitMaskMaterialized {
246 pub const BLOCK_SIZE: u64 = 64;
246 const BLOCK_SIZE: u64 = 64;
247247
248248 fn new(size: Size, state: bool) -> Self {
249249 let mut m = InitMaskMaterialized { blocks: vec![] };
compiler/rustc_middle/src/mir/mono.rs+1-1
......@@ -396,7 +396,7 @@ impl<'tcx> CodegenUnit<'tcx> {
396396 // The codegen tests rely on items being process in the same order as
397397 // they appear in the file, so for local items, we sort by node_id first
398398 #[derive(PartialEq, Eq, PartialOrd, Ord)]
399 pub struct ItemSortKey<'tcx>(Option<usize>, SymbolName<'tcx>);
399 struct ItemSortKey<'tcx>(Option<usize>, SymbolName<'tcx>);
400400
401401 fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'tcx> {
402402 ItemSortKey(
compiler/rustc_middle/src/ty/context.rs+1-1
......@@ -2190,7 +2190,7 @@ macro_rules! sty_debug_print {
21902190 all_infer: usize,
21912191 }
21922192
2193 pub fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Result {
2193 pub(crate) fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Result {
21942194 let mut total = DebugStat {
21952195 total: 0,
21962196 lt_infer: 0,
compiler/rustc_mir_build/src/check_unsafety.rs+1-1
......@@ -1027,7 +1027,7 @@ impl UnsafeOpKind {
10271027 }
10281028}
10291029
1030pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
1030pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
10311031 // Closures and inline consts are handled by their owner, if it has a body
10321032 // Also, don't safety check custom MIR
10331033 if tcx.is_typeck_child(def.to_def_id()) || tcx.has_attr(def, sym::custom_mir) {
compiler/rustc_mir_build/src/lib.rs+1
......@@ -8,6 +8,7 @@
88#![feature(if_let_guard)]
99#![feature(let_chains)]
1010#![feature(try_blocks)]
11#![warn(unreachable_pub)]
1112// tidy-alphabetical-end
1213
1314mod build;
compiler/rustc_mir_dataflow/src/framework/engine.rs+1-1
......@@ -24,7 +24,7 @@ use crate::errors::{
2424};
2525use crate::framework::BitSetExt;
2626
27pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
27type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
2828
2929/// A dataflow analysis that has converged to fixpoint.
3030#[derive(Clone)]
compiler/rustc_mir_dataflow/src/framework/mod.rs+2-2
......@@ -510,7 +510,7 @@ impl<T: Idx> GenKill<T> for lattice::Dual<BitSet<T>> {
510510
511511// NOTE: DO NOT CHANGE VARIANT ORDER. The derived `Ord` impls rely on the current order.
512512#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
513pub enum Effect {
513enum Effect {
514514 /// The "before" effect (e.g., `apply_before_statement_effect`) for a statement (or
515515 /// terminator).
516516 Before,
......@@ -520,7 +520,7 @@ pub enum Effect {
520520}
521521
522522impl Effect {
523 pub const fn at_index(self, statement_index: usize) -> EffectIndex {
523 const fn at_index(self, statement_index: usize) -> EffectIndex {
524524 EffectIndex { effect: self, statement_index }
525525 }
526526}
compiler/rustc_mir_dataflow/src/lib.rs+1
......@@ -5,6 +5,7 @@
55#![feature(exact_size_is_empty)]
66#![feature(let_chains)]
77#![feature(try_blocks)]
8#![warn(unreachable_pub)]
89// tidy-alphabetical-end
910
1011use rustc_middle::ty;
compiler/rustc_mir_dataflow/src/move_paths/abs_domain.rs+4-4
......@@ -15,12 +15,12 @@ use rustc_middle::mir::{Local, Operand, PlaceElem, ProjectionElem};
1515use rustc_middle::ty::Ty;
1616
1717#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
18pub struct AbstractOperand;
18pub(crate) struct AbstractOperand;
1919#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
20pub struct AbstractType;
21pub type AbstractElem = ProjectionElem<AbstractOperand, AbstractType>;
20pub(crate) struct AbstractType;
21pub(crate) type AbstractElem = ProjectionElem<AbstractOperand, AbstractType>;
2222
23pub trait Lift {
23pub(crate) trait Lift {
2424 type Abstract;
2525 fn lift(&self) -> Self::Abstract;
2626}
compiler/rustc_monomorphize/src/collector.rs+10-6
......@@ -242,12 +242,12 @@ use tracing::{debug, instrument, trace};
242242use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};
243243
244244#[derive(PartialEq)]
245pub enum MonoItemCollectionStrategy {
245pub(crate) enum MonoItemCollectionStrategy {
246246 Eager,
247247 Lazy,
248248}
249249
250pub struct UsageMap<'tcx> {
250pub(crate) struct UsageMap<'tcx> {
251251 // Maps every mono item to the mono items used by it.
252252 used_map: UnordMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
253253
......@@ -306,13 +306,17 @@ impl<'tcx> UsageMap<'tcx> {
306306 assert!(self.used_map.insert(user_item, used_items).is_none());
307307 }
308308
309 pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
309 pub(crate) fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
310310 self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
311311 }
312312
313313 /// Internally iterate over all inlined items used by `item`.
314 pub fn for_each_inlined_used_item<F>(&self, tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>, mut f: F)
315 where
314 pub(crate) fn for_each_inlined_used_item<F>(
315 &self,
316 tcx: TyCtxt<'tcx>,
317 item: MonoItem<'tcx>,
318 mut f: F,
319 ) where
316320 F: FnMut(MonoItem<'tcx>),
317321 {
318322 let used_items = self.used_map.get(&item).unwrap();
......@@ -1615,6 +1619,6 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
16151619 (mono_items, state.usage_map.into_inner())
16161620}
16171621
1618pub fn provide(providers: &mut Providers) {
1622pub(crate) fn provide(providers: &mut Providers) {
16191623 providers.hooks.should_codegen_locally = should_codegen_locally;
16201624}
compiler/rustc_monomorphize/src/errors.rs+9-9
......@@ -8,7 +8,7 @@ use crate::fluent_generated as fluent;
88
99#[derive(Diagnostic)]
1010#[diag(monomorphize_recursion_limit)]
11pub struct RecursionLimit {
11pub(crate) struct RecursionLimit {
1212 #[primary_span]
1313 pub span: Span,
1414 pub shrunk: String,
......@@ -22,13 +22,13 @@ pub struct RecursionLimit {
2222
2323#[derive(Diagnostic)]
2424#[diag(monomorphize_no_optimized_mir)]
25pub struct NoOptimizedMir {
25pub(crate) struct NoOptimizedMir {
2626 #[note]
2727 pub span: Span,
2828 pub crate_name: Symbol,
2929}
3030
31pub struct UnusedGenericParamsHint {
31pub(crate) struct UnusedGenericParamsHint {
3232 pub span: Span,
3333 pub param_spans: Vec<Span>,
3434 pub param_names: Vec<String>,
......@@ -53,7 +53,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for UnusedGenericParamsHint {
5353#[derive(LintDiagnostic)]
5454#[diag(monomorphize_large_assignments)]
5555#[note]
56pub struct LargeAssignmentsLint {
56pub(crate) struct LargeAssignmentsLint {
5757 #[label]
5858 pub span: Span,
5959 pub size: u64,
......@@ -62,7 +62,7 @@ pub struct LargeAssignmentsLint {
6262
6363#[derive(Diagnostic)]
6464#[diag(monomorphize_symbol_already_defined)]
65pub struct SymbolAlreadyDefined {
65pub(crate) struct SymbolAlreadyDefined {
6666 #[primary_span]
6767 pub span: Option<Span>,
6868 pub symbol: String,
......@@ -70,13 +70,13 @@ pub struct SymbolAlreadyDefined {
7070
7171#[derive(Diagnostic)]
7272#[diag(monomorphize_couldnt_dump_mono_stats)]
73pub struct CouldntDumpMonoStats {
73pub(crate) struct CouldntDumpMonoStats {
7474 pub error: String,
7575}
7676
7777#[derive(Diagnostic)]
7878#[diag(monomorphize_encountered_error_while_instantiating)]
79pub struct EncounteredErrorWhileInstantiating {
79pub(crate) struct EncounteredErrorWhileInstantiating {
8080 #[primary_span]
8181 pub span: Span,
8282 pub formatted_item: String,
......@@ -85,10 +85,10 @@ pub struct EncounteredErrorWhileInstantiating {
8585#[derive(Diagnostic)]
8686#[diag(monomorphize_start_not_found)]
8787#[help]
88pub struct StartNotFound;
88pub(crate) struct StartNotFound;
8989
9090#[derive(Diagnostic)]
9191#[diag(monomorphize_unknown_cgu_collection_mode)]
92pub struct UnknownCguCollectionMode<'a> {
92pub(crate) struct UnknownCguCollectionMode<'a> {
9393 pub mode: &'a str,
9494}
compiler/rustc_monomorphize/src/lib.rs+1
......@@ -1,5 +1,6 @@
11// tidy-alphabetical-start
22#![feature(array_windows)]
3#![warn(unreachable_pub)]
34// tidy-alphabetical-end
45
56use rustc_hir::lang_items::LangItem;
compiler/rustc_monomorphize/src/partitioning.rs+1-1
......@@ -1300,7 +1300,7 @@ fn dump_mono_items_stats<'tcx>(
13001300 Ok(())
13011301}
13021302
1303pub fn provide(providers: &mut Providers) {
1303pub(crate) fn provide(providers: &mut Providers) {
13041304 providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
13051305
13061306 providers.is_codegened_item = |tcx, def_id| {
compiler/rustc_monomorphize/src/polymorphize.rs+1-1
......@@ -19,7 +19,7 @@ use tracing::{debug, instrument};
1919use crate::errors::UnusedGenericParamsHint;
2020
2121/// Provide implementations of queries relating to polymorphization analysis.
22pub fn provide(providers: &mut Providers) {
22pub(crate) fn provide(providers: &mut Providers) {
2323 providers.unused_generic_params = unused_generic_params;
2424}
2525
compiler/rustc_next_trait_solver/src/lib.rs+4
......@@ -4,6 +4,10 @@
44//! but were uplifted in the process of making the new trait solver generic.
55//! So if you got to this crate from the old solver, it's totally normal.
66
7// tidy-alphabetical-start
8#![warn(unreachable_pub)]
9// tidy-alphabetical-end
10
711pub mod canonicalizer;
812pub mod coherence;
913pub mod delegate;
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs+3-3
......@@ -92,7 +92,7 @@ where
9292#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
9393#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
9494// FIXME: This can be made crate-private once `EvalCtxt` also lives in this crate.
95pub struct NestedGoals<I: Interner> {
95struct NestedGoals<I: Interner> {
9696 /// These normalizes-to goals are treated specially during the evaluation
9797 /// loop. In each iteration we take the RHS of the projection, replace it with
9898 /// a fresh inference variable, and only after evaluating that goal do we
......@@ -109,11 +109,11 @@ pub struct NestedGoals<I: Interner> {
109109}
110110
111111impl<I: Interner> NestedGoals<I> {
112 pub fn new() -> Self {
112 fn new() -> Self {
113113 Self { normalizes_to_goals: Vec::new(), goals: Vec::new() }
114114 }
115115
116 pub fn is_empty(&self) -> bool {
116 fn is_empty(&self) -> bool {
117117 self.normalizes_to_goals.is_empty() && self.goals.is_empty()
118118 }
119119}
compiler/rustc_next_trait_solver/src/solve/inspect/build.rs+28-21
......@@ -222,13 +222,13 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
222222 self.state.as_deref_mut()
223223 }
224224
225 pub fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
225 pub(crate) fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
226226 let mut nested = ProofTreeBuilder { state: self.state.take(), _infcx: PhantomData };
227227 nested.enter_probe();
228228 nested
229229 }
230230
231 pub fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
231 pub(crate) fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
232232 match *self.state? {
233233 DebugSolver::GoalEvaluation(wip_goal_evaluation) => {
234234 Some(wip_goal_evaluation.finalize())
......@@ -237,22 +237,22 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
237237 }
238238 }
239239
240 pub fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
240 pub(crate) fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
241241 match generate_proof_tree {
242242 GenerateProofTree::No => ProofTreeBuilder::new_noop(),
243243 GenerateProofTree::Yes => ProofTreeBuilder::new_root(),
244244 }
245245 }
246246
247 pub fn new_root() -> ProofTreeBuilder<D> {
247 fn new_root() -> ProofTreeBuilder<D> {
248248 ProofTreeBuilder::new(DebugSolver::Root)
249249 }
250250
251 pub fn new_noop() -> ProofTreeBuilder<D> {
251 fn new_noop() -> ProofTreeBuilder<D> {
252252 ProofTreeBuilder { state: None, _infcx: PhantomData }
253253 }
254254
255 pub fn is_noop(&self) -> bool {
255 pub(crate) fn is_noop(&self) -> bool {
256256 self.state.is_none()
257257 }
258258
......@@ -272,7 +272,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
272272 })
273273 }
274274
275 pub fn new_canonical_goal_evaluation(
275 pub(crate) fn new_canonical_goal_evaluation(
276276 &mut self,
277277 goal: CanonicalInput<I>,
278278 ) -> ProofTreeBuilder<D> {
......@@ -284,7 +284,10 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
284284 })
285285 }
286286
287 pub fn canonical_goal_evaluation(&mut self, canonical_goal_evaluation: ProofTreeBuilder<D>) {
287 pub(crate) fn canonical_goal_evaluation(
288 &mut self,
289 canonical_goal_evaluation: ProofTreeBuilder<D>,
290 ) {
288291 if let Some(this) = self.as_mut() {
289292 match (this, *canonical_goal_evaluation.state.unwrap()) {
290293 (
......@@ -299,7 +302,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
299302 }
300303 }
301304
302 pub fn canonical_goal_evaluation_overflow(&mut self) {
305 pub(crate) fn canonical_goal_evaluation_overflow(&mut self) {
303306 if let Some(this) = self.as_mut() {
304307 match this {
305308 DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
......@@ -310,7 +313,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
310313 }
311314 }
312315
313 pub fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
316 pub(crate) fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
314317 if let Some(this) = self.as_mut() {
315318 match this {
316319 DebugSolver::Root => *this = *goal_evaluation.state.unwrap(),
......@@ -322,7 +325,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
322325 }
323326 }
324327
325 pub fn new_goal_evaluation_step(
328 pub(crate) fn new_goal_evaluation_step(
326329 &mut self,
327330 var_values: ty::CanonicalVarValues<I>,
328331 instantiated_goal: QueryInput<I, I::Predicate>,
......@@ -340,7 +343,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
340343 })
341344 }
342345
343 pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
346 pub(crate) fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
344347 if let Some(this) = self.as_mut() {
345348 match (this, *goal_evaluation_step.state.unwrap()) {
346349 (
......@@ -354,7 +357,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
354357 }
355358 }
356359
357 pub fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
360 pub(crate) fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
358361 match self.as_mut() {
359362 None => {}
360363 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
......@@ -364,7 +367,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
364367 }
365368 }
366369
367 pub fn enter_probe(&mut self) {
370 fn enter_probe(&mut self) {
368371 match self.as_mut() {
369372 None => {}
370373 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
......@@ -381,7 +384,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
381384 }
382385 }
383386
384 pub fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
387 pub(crate) fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
385388 match self.as_mut() {
386389 None => {}
387390 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
......@@ -392,7 +395,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
392395 }
393396 }
394397
395 pub fn probe_final_state(&mut self, delegate: &D, max_input_universe: ty::UniverseIndex) {
398 pub(crate) fn probe_final_state(
399 &mut self,
400 delegate: &D,
401 max_input_universe: ty::UniverseIndex,
402 ) {
396403 match self.as_mut() {
397404 None => {}
398405 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
......@@ -409,7 +416,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
409416 }
410417 }
411418
412 pub fn add_normalizes_to_goal(
419 pub(crate) fn add_normalizes_to_goal(
413420 &mut self,
414421 delegate: &D,
415422 max_input_universe: ty::UniverseIndex,
......@@ -423,7 +430,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
423430 );
424431 }
425432
426 pub fn add_goal(
433 pub(crate) fn add_goal(
427434 &mut self,
428435 delegate: &D,
429436 max_input_universe: ty::UniverseIndex,
......@@ -469,7 +476,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
469476 }
470477 }
471478
472 pub fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
479 pub(crate) fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
473480 match self.as_mut() {
474481 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
475482 state
......@@ -482,7 +489,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
482489 }
483490 }
484491
485 pub fn finish_probe(mut self) -> ProofTreeBuilder<D> {
492 pub(crate) fn finish_probe(mut self) -> ProofTreeBuilder<D> {
486493 match self.as_mut() {
487494 None => {}
488495 Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
......@@ -497,7 +504,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
497504 self
498505 }
499506
500 pub fn query_result(&mut self, result: QueryResult<I>) {
507 pub(crate) fn query_result(&mut self, result: QueryResult<I>) {
501508 if let Some(this) = self.as_mut() {
502509 match this {
503510 DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs+2-2
......@@ -97,7 +97,7 @@ where
9797/// Checks whether each generic argument is simply a unique generic placeholder.
9898///
9999/// FIXME: Interner argument is needed to constrain the `I` parameter.
100pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
100fn uses_unique_placeholders_ignoring_regions<I: Interner>(
101101 _cx: I,
102102 args: I::GenericArgs,
103103) -> Result<(), NotUniqueParam<I>> {
......@@ -130,7 +130,7 @@ pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
130130}
131131
132132// FIXME: This should check for dupes and non-params first, then infer vars.
133pub enum NotUniqueParam<I: Interner> {
133enum NotUniqueParam<I: Interner> {
134134 DuplicateParam(I::GenericArg),
135135 NotParam(I::GenericArg),
136136}
compiler/rustc_parse/src/errors.rs+35-35
......@@ -260,7 +260,7 @@ pub(crate) struct NotAsNegationOperator {
260260}
261261
262262#[derive(Subdiagnostic)]
263pub enum NotAsNegationOperatorSub {
263pub(crate) enum NotAsNegationOperatorSub {
264264 #[suggestion(
265265 parse_unexpected_token_after_not_default,
266266 style = "verbose",
......@@ -424,7 +424,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
424424#[derive(Diagnostic)]
425425#[diag(parse_ternary_operator)]
426426#[help]
427pub struct TernaryOperator {
427pub(crate) struct TernaryOperator {
428428 #[primary_span]
429429 pub span: Span,
430430}
......@@ -1088,7 +1088,7 @@ pub(crate) enum ExpectedIdentifierFound {
10881088}
10891089
10901090impl ExpectedIdentifierFound {
1091 pub fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
1091 pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
10921092 (match token_descr {
10931093 Some(TokenDescription::ReservedIdentifier) => {
10941094 ExpectedIdentifierFound::ReservedIdentifier
......@@ -1659,7 +1659,7 @@ pub(crate) struct SelfArgumentPointer {
16591659
16601660#[derive(Diagnostic)]
16611661#[diag(parse_unexpected_token_after_dot)]
1662pub struct UnexpectedTokenAfterDot<'a> {
1662pub(crate) struct UnexpectedTokenAfterDot<'a> {
16631663 #[primary_span]
16641664 pub span: Span,
16651665 pub actual: Cow<'a, str>,
......@@ -1928,7 +1928,7 @@ pub(crate) enum UnexpectedTokenAfterStructName {
19281928}
19291929
19301930impl UnexpectedTokenAfterStructName {
1931 pub fn new(span: Span, token: Token) -> Self {
1931 pub(crate) fn new(span: Span, token: Token) -> Self {
19321932 match TokenDescription::from_token(&token) {
19331933 Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
19341934 Some(TokenDescription::Keyword) => Self::Keyword { span, token },
......@@ -2006,7 +2006,7 @@ pub(crate) enum TopLevelOrPatternNotAllowed {
20062006
20072007#[derive(Diagnostic)]
20082008#[diag(parse_cannot_be_raw_ident)]
2009pub struct CannotBeRawIdent {
2009pub(crate) struct CannotBeRawIdent {
20102010 #[primary_span]
20112011 pub span: Span,
20122012 pub ident: Symbol,
......@@ -2014,14 +2014,14 @@ pub struct CannotBeRawIdent {
20142014
20152015#[derive(Diagnostic)]
20162016#[diag(parse_keyword_lifetime)]
2017pub struct KeywordLifetime {
2017pub(crate) struct KeywordLifetime {
20182018 #[primary_span]
20192019 pub span: Span,
20202020}
20212021
20222022#[derive(Diagnostic)]
20232023#[diag(parse_invalid_label)]
2024pub struct InvalidLabel {
2024pub(crate) struct InvalidLabel {
20252025 #[primary_span]
20262026 pub span: Span,
20272027 pub name: Symbol,
......@@ -2029,7 +2029,7 @@ pub struct InvalidLabel {
20292029
20302030#[derive(Diagnostic)]
20312031#[diag(parse_cr_doc_comment)]
2032pub struct CrDocComment {
2032pub(crate) struct CrDocComment {
20332033 #[primary_span]
20342034 pub span: Span,
20352035 pub block: bool,
......@@ -2037,14 +2037,14 @@ pub struct CrDocComment {
20372037
20382038#[derive(Diagnostic)]
20392039#[diag(parse_no_digits_literal, code = E0768)]
2040pub struct NoDigitsLiteral {
2040pub(crate) struct NoDigitsLiteral {
20412041 #[primary_span]
20422042 pub span: Span,
20432043}
20442044
20452045#[derive(Diagnostic)]
20462046#[diag(parse_invalid_digit_literal)]
2047pub struct InvalidDigitLiteral {
2047pub(crate) struct InvalidDigitLiteral {
20482048 #[primary_span]
20492049 pub span: Span,
20502050 pub base: u32,
......@@ -2052,14 +2052,14 @@ pub struct InvalidDigitLiteral {
20522052
20532053#[derive(Diagnostic)]
20542054#[diag(parse_empty_exponent_float)]
2055pub struct EmptyExponentFloat {
2055pub(crate) struct EmptyExponentFloat {
20562056 #[primary_span]
20572057 pub span: Span,
20582058}
20592059
20602060#[derive(Diagnostic)]
20612061#[diag(parse_float_literal_unsupported_base)]
2062pub struct FloatLiteralUnsupportedBase {
2062pub(crate) struct FloatLiteralUnsupportedBase {
20632063 #[primary_span]
20642064 pub span: Span,
20652065 pub base: &'static str,
......@@ -2068,7 +2068,7 @@ pub struct FloatLiteralUnsupportedBase {
20682068#[derive(Diagnostic)]
20692069#[diag(parse_unknown_prefix)]
20702070#[note]
2071pub struct UnknownPrefix<'a> {
2071pub(crate) struct UnknownPrefix<'a> {
20722072 #[primary_span]
20732073 #[label]
20742074 pub span: Span,
......@@ -2079,12 +2079,12 @@ pub struct UnknownPrefix<'a> {
20792079
20802080#[derive(Subdiagnostic)]
20812081#[note(parse_macro_expands_to_adt_field)]
2082pub struct MacroExpandsToAdtField<'a> {
2082pub(crate) struct MacroExpandsToAdtField<'a> {
20832083 pub adt_ty: &'a str,
20842084}
20852085
20862086#[derive(Subdiagnostic)]
2087pub enum UnknownPrefixSugg {
2087pub(crate) enum UnknownPrefixSugg {
20882088 #[suggestion(
20892089 parse_suggestion_br,
20902090 code = "br",
......@@ -2114,7 +2114,7 @@ pub enum UnknownPrefixSugg {
21142114
21152115#[derive(Diagnostic)]
21162116#[diag(parse_too_many_hashes)]
2117pub struct TooManyHashes {
2117pub(crate) struct TooManyHashes {
21182118 #[primary_span]
21192119 pub span: Span,
21202120 pub num: u32,
......@@ -2122,7 +2122,7 @@ pub struct TooManyHashes {
21222122
21232123#[derive(Diagnostic)]
21242124#[diag(parse_unknown_start_of_token)]
2125pub struct UnknownTokenStart {
2125pub(crate) struct UnknownTokenStart {
21262126 #[primary_span]
21272127 pub span: Span,
21282128 pub escaped: String,
......@@ -2135,7 +2135,7 @@ pub struct UnknownTokenStart {
21352135}
21362136
21372137#[derive(Subdiagnostic)]
2138pub enum TokenSubstitution {
2138pub(crate) enum TokenSubstitution {
21392139 #[suggestion(
21402140 parse_sugg_quotes,
21412141 code = "{suggestion}",
......@@ -2168,16 +2168,16 @@ pub enum TokenSubstitution {
21682168
21692169#[derive(Subdiagnostic)]
21702170#[note(parse_note_repeats)]
2171pub struct UnknownTokenRepeat {
2171pub(crate) struct UnknownTokenRepeat {
21722172 pub repeats: usize,
21732173}
21742174
21752175#[derive(Subdiagnostic)]
21762176#[help(parse_help_null)]
2177pub struct UnknownTokenNull;
2177pub(crate) struct UnknownTokenNull;
21782178
21792179#[derive(Diagnostic)]
2180pub enum UnescapeError {
2180pub(crate) enum UnescapeError {
21812181 #[diag(parse_invalid_unicode_escape)]
21822182 #[help]
21832183 InvalidUnicodeEscape {
......@@ -2322,7 +2322,7 @@ pub enum UnescapeError {
23222322}
23232323
23242324#[derive(Subdiagnostic)]
2325pub enum MoreThanOneCharSugg {
2325pub(crate) enum MoreThanOneCharSugg {
23262326 #[suggestion(
23272327 parse_consider_normalized,
23282328 code = "{normalized}",
......@@ -2370,7 +2370,7 @@ pub enum MoreThanOneCharSugg {
23702370}
23712371
23722372#[derive(Subdiagnostic)]
2373pub enum MoreThanOneCharNote {
2373pub(crate) enum MoreThanOneCharNote {
23742374 #[note(parse_followed_by)]
23752375 AllCombining {
23762376 #[primary_span]
......@@ -2388,7 +2388,7 @@ pub enum MoreThanOneCharNote {
23882388}
23892389
23902390#[derive(Subdiagnostic)]
2391pub enum NoBraceUnicodeSub {
2391pub(crate) enum NoBraceUnicodeSub {
23922392 #[suggestion(
23932393 parse_use_braces,
23942394 code = "{suggestion}",
......@@ -2703,7 +2703,7 @@ pub(crate) struct InvalidDynKeyword {
27032703}
27042704
27052705#[derive(Subdiagnostic)]
2706pub enum HelpUseLatestEdition {
2706pub(crate) enum HelpUseLatestEdition {
27072707 #[help(parse_help_set_edition_cargo)]
27082708 #[note(parse_note_edition_guide)]
27092709 Cargo { edition: Edition },
......@@ -2713,7 +2713,7 @@ pub enum HelpUseLatestEdition {
27132713}
27142714
27152715impl HelpUseLatestEdition {
2716 pub fn new() -> Self {
2716 pub(crate) fn new() -> Self {
27172717 let edition = LATEST_STABLE_EDITION;
27182718 if rustc_session::utils::was_invoked_from_cargo() {
27192719 Self::Cargo { edition }
......@@ -2725,7 +2725,7 @@ impl HelpUseLatestEdition {
27252725
27262726#[derive(Diagnostic)]
27272727#[diag(parse_box_syntax_removed)]
2728pub struct BoxSyntaxRemoved {
2728pub(crate) struct BoxSyntaxRemoved {
27292729 #[primary_span]
27302730 pub span: Span,
27312731 #[subdiagnostic]
......@@ -2738,7 +2738,7 @@ pub struct BoxSyntaxRemoved {
27382738 applicability = "machine-applicable",
27392739 style = "verbose"
27402740)]
2741pub struct AddBoxNew {
2741pub(crate) struct AddBoxNew {
27422742 #[suggestion_part(code = "Box::new(")]
27432743 pub box_kw_and_lo: Span,
27442744 #[suggestion_part(code = ")")]
......@@ -3190,7 +3190,7 @@ pub(crate) struct DotDotRangeAttribute {
31903190#[derive(Diagnostic)]
31913191#[diag(parse_invalid_attr_unsafe)]
31923192#[note]
3193pub struct InvalidAttrUnsafe {
3193pub(crate) struct InvalidAttrUnsafe {
31943194 #[primary_span]
31953195 #[label]
31963196 pub span: Span,
......@@ -3199,7 +3199,7 @@ pub struct InvalidAttrUnsafe {
31993199
32003200#[derive(Diagnostic)]
32013201#[diag(parse_unsafe_attr_outside_unsafe)]
3202pub struct UnsafeAttrOutsideUnsafe {
3202pub(crate) struct UnsafeAttrOutsideUnsafe {
32033203 #[primary_span]
32043204 #[label]
32053205 pub span: Span,
......@@ -3212,7 +3212,7 @@ pub struct UnsafeAttrOutsideUnsafe {
32123212 parse_unsafe_attr_outside_unsafe_suggestion,
32133213 applicability = "machine-applicable"
32143214)]
3215pub struct UnsafeAttrOutsideUnsafeSuggestion {
3215pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
32163216 #[suggestion_part(code = "unsafe(")]
32173217 pub left: Span,
32183218 #[suggestion_part(code = ")")]
......@@ -3221,7 +3221,7 @@ pub struct UnsafeAttrOutsideUnsafeSuggestion {
32213221
32223222#[derive(Diagnostic)]
32233223#[diag(parse_binder_before_modifiers)]
3224pub struct BinderBeforeModifiers {
3224pub(crate) struct BinderBeforeModifiers {
32253225 #[primary_span]
32263226 pub binder_span: Span,
32273227 #[label]
......@@ -3230,7 +3230,7 @@ pub struct BinderBeforeModifiers {
32303230
32313231#[derive(Diagnostic)]
32323232#[diag(parse_binder_and_polarity)]
3233pub struct BinderAndPolarity {
3233pub(crate) struct BinderAndPolarity {
32343234 #[primary_span]
32353235 pub polarity_span: Span,
32363236 #[label]
......@@ -3240,7 +3240,7 @@ pub struct BinderAndPolarity {
32403240
32413241#[derive(Diagnostic)]
32423242#[diag(parse_modifiers_and_polarity)]
3243pub struct PolarityAndModifiers {
3243pub(crate) struct PolarityAndModifiers {
32443244 #[primary_span]
32453245 pub polarity_span: Span,
32463246 #[label]
compiler/rustc_parse/src/lib.rs+1
......@@ -11,6 +11,7 @@
1111#![feature(if_let_guard)]
1212#![feature(iter_intersperse)]
1313#![feature(let_chains)]
14#![warn(unreachable_pub)]
1415// tidy-alphabetical-end
1516
1617use std::path::Path;
compiler/rustc_parse_format/src/lib.rs+1
......@@ -13,6 +13,7 @@
1313 html_playground_url = "https://play.rust-lang.org/",
1414 test(attr(deny(warnings)))
1515)]
16#![warn(unreachable_pub)]
1617// tidy-alphabetical-end
1718
1819use std::{iter, str, string};
compiler/rustc_passes/src/debugger_visualizer.rs+1-1
......@@ -95,6 +95,6 @@ fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualize
9595 visitor.visualizers
9696}
9797
98pub fn provide(providers: &mut Providers) {
98pub(crate) fn provide(providers: &mut Providers) {
9999 providers.debugger_visualizers = debugger_visualizers;
100100}
compiler/rustc_passes/src/diagnostic_items.rs+1-1
......@@ -90,7 +90,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
9090 items
9191}
9292
93pub fn provide(providers: &mut Providers) {
93pub(crate) fn provide(providers: &mut Providers) {
9494 providers.diagnostic_items = diagnostic_items;
9595 providers.all_diagnostic_items = all_diagnostic_items;
9696}
compiler/rustc_passes/src/errors.rs+183-183
......@@ -18,41 +18,41 @@ use crate::lang_items::Duplicate;
1818
1919#[derive(LintDiagnostic)]
2020#[diag(passes_incorrect_do_not_recommend_location)]
21pub struct IncorrectDoNotRecommendLocation;
21pub(crate) struct IncorrectDoNotRecommendLocation;
2222
2323#[derive(LintDiagnostic)]
2424#[diag(passes_outer_crate_level_attr)]
25pub struct OuterCrateLevelAttr;
25pub(crate) struct OuterCrateLevelAttr;
2626
2727#[derive(LintDiagnostic)]
2828#[diag(passes_inner_crate_level_attr)]
29pub struct InnerCrateLevelAttr;
29pub(crate) struct InnerCrateLevelAttr;
3030
3131#[derive(LintDiagnostic)]
3232#[diag(passes_ignored_attr_with_macro)]
33pub struct IgnoredAttrWithMacro<'a> {
33pub(crate) struct IgnoredAttrWithMacro<'a> {
3434 pub sym: &'a str,
3535}
3636
3737#[derive(LintDiagnostic)]
3838#[diag(passes_ignored_attr)]
39pub struct IgnoredAttr<'a> {
39pub(crate) struct IgnoredAttr<'a> {
4040 pub sym: &'a str,
4141}
4242
4343#[derive(LintDiagnostic)]
4444#[diag(passes_inline_ignored_function_prototype)]
45pub struct IgnoredInlineAttrFnProto;
45pub(crate) struct IgnoredInlineAttrFnProto;
4646
4747#[derive(LintDiagnostic)]
4848#[diag(passes_inline_ignored_constants)]
4949#[warning]
5050#[note]
51pub struct IgnoredInlineAttrConstants;
51pub(crate) struct IgnoredInlineAttrConstants;
5252
5353#[derive(Diagnostic)]
5454#[diag(passes_inline_not_fn_or_closure, code = E0518)]
55pub struct InlineNotFnOrClosure {
55pub(crate) struct InlineNotFnOrClosure {
5656 #[primary_span]
5757 pub attr_span: Span,
5858 #[label]
......@@ -61,7 +61,7 @@ pub struct InlineNotFnOrClosure {
6161
6262#[derive(Diagnostic)]
6363#[diag(passes_coverage_not_fn_or_closure, code = E0788)]
64pub struct CoverageNotFnOrClosure {
64pub(crate) struct CoverageNotFnOrClosure {
6565 #[primary_span]
6666 pub attr_span: Span,
6767 #[label]
......@@ -70,11 +70,11 @@ pub struct CoverageNotFnOrClosure {
7070
7171#[derive(LintDiagnostic)]
7272#[diag(passes_optimize_not_fn_or_closure)]
73pub struct OptimizeNotFnOrClosure;
73pub(crate) struct OptimizeNotFnOrClosure;
7474
7575#[derive(Diagnostic)]
7676#[diag(passes_should_be_applied_to_fn)]
77pub struct AttrShouldBeAppliedToFn {
77pub(crate) struct AttrShouldBeAppliedToFn {
7878 #[primary_span]
7979 pub attr_span: Span,
8080 #[label]
......@@ -84,7 +84,7 @@ pub struct AttrShouldBeAppliedToFn {
8484
8585#[derive(Diagnostic)]
8686#[diag(passes_should_be_applied_to_fn_or_unit_struct)]
87pub struct AttrShouldBeAppliedToFnOrUnitStruct {
87pub(crate) struct AttrShouldBeAppliedToFnOrUnitStruct {
8888 #[primary_span]
8989 pub attr_span: Span,
9090 #[label]
......@@ -93,7 +93,7 @@ pub struct AttrShouldBeAppliedToFnOrUnitStruct {
9393
9494#[derive(Diagnostic)]
9595#[diag(passes_should_be_applied_to_fn, code = E0739)]
96pub struct TrackedCallerWrongLocation {
96pub(crate) struct TrackedCallerWrongLocation {
9797 #[primary_span]
9898 pub attr_span: Span,
9999 #[label]
......@@ -103,7 +103,7 @@ pub struct TrackedCallerWrongLocation {
103103
104104#[derive(Diagnostic)]
105105#[diag(passes_should_be_applied_to_struct_enum, code = E0701)]
106pub struct NonExhaustiveWrongLocation {
106pub(crate) struct NonExhaustiveWrongLocation {
107107 #[primary_span]
108108 pub attr_span: Span,
109109 #[label]
......@@ -112,7 +112,7 @@ pub struct NonExhaustiveWrongLocation {
112112
113113#[derive(Diagnostic)]
114114#[diag(passes_should_be_applied_to_trait)]
115pub struct AttrShouldBeAppliedToTrait {
115pub(crate) struct AttrShouldBeAppliedToTrait {
116116 #[primary_span]
117117 pub attr_span: Span,
118118 #[label]
......@@ -121,11 +121,11 @@ pub struct AttrShouldBeAppliedToTrait {
121121
122122#[derive(LintDiagnostic)]
123123#[diag(passes_target_feature_on_statement)]
124pub struct TargetFeatureOnStatement;
124pub(crate) struct TargetFeatureOnStatement;
125125
126126#[derive(Diagnostic)]
127127#[diag(passes_should_be_applied_to_static)]
128pub struct AttrShouldBeAppliedToStatic {
128pub(crate) struct AttrShouldBeAppliedToStatic {
129129 #[primary_span]
130130 pub attr_span: Span,
131131 #[label]
......@@ -134,7 +134,7 @@ pub struct AttrShouldBeAppliedToStatic {
134134
135135#[derive(Diagnostic)]
136136#[diag(passes_doc_expect_str)]
137pub struct DocExpectStr<'a> {
137pub(crate) struct DocExpectStr<'a> {
138138 #[primary_span]
139139 pub attr_span: Span,
140140 pub attr_name: &'a str,
......@@ -142,7 +142,7 @@ pub struct DocExpectStr<'a> {
142142
143143#[derive(Diagnostic)]
144144#[diag(passes_doc_alias_empty)]
145pub struct DocAliasEmpty<'a> {
145pub(crate) struct DocAliasEmpty<'a> {
146146 #[primary_span]
147147 pub span: Span,
148148 pub attr_str: &'a str,
......@@ -150,7 +150,7 @@ pub struct DocAliasEmpty<'a> {
150150
151151#[derive(Diagnostic)]
152152#[diag(passes_doc_alias_bad_char)]
153pub struct DocAliasBadChar<'a> {
153pub(crate) struct DocAliasBadChar<'a> {
154154 #[primary_span]
155155 pub span: Span,
156156 pub attr_str: &'a str,
......@@ -159,7 +159,7 @@ pub struct DocAliasBadChar<'a> {
159159
160160#[derive(Diagnostic)]
161161#[diag(passes_doc_alias_start_end)]
162pub struct DocAliasStartEnd<'a> {
162pub(crate) struct DocAliasStartEnd<'a> {
163163 #[primary_span]
164164 pub span: Span,
165165 pub attr_str: &'a str,
......@@ -167,7 +167,7 @@ pub struct DocAliasStartEnd<'a> {
167167
168168#[derive(Diagnostic)]
169169#[diag(passes_doc_alias_bad_location)]
170pub struct DocAliasBadLocation<'a> {
170pub(crate) struct DocAliasBadLocation<'a> {
171171 #[primary_span]
172172 pub span: Span,
173173 pub attr_str: &'a str,
......@@ -176,7 +176,7 @@ pub struct DocAliasBadLocation<'a> {
176176
177177#[derive(Diagnostic)]
178178#[diag(passes_doc_alias_not_an_alias)]
179pub struct DocAliasNotAnAlias<'a> {
179pub(crate) struct DocAliasNotAnAlias<'a> {
180180 #[primary_span]
181181 pub span: Span,
182182 pub attr_str: &'a str,
......@@ -184,42 +184,42 @@ pub struct DocAliasNotAnAlias<'a> {
184184
185185#[derive(LintDiagnostic)]
186186#[diag(passes_doc_alias_duplicated)]
187pub struct DocAliasDuplicated {
187pub(crate) struct DocAliasDuplicated {
188188 #[label]
189189 pub first_defn: Span,
190190}
191191
192192#[derive(Diagnostic)]
193193#[diag(passes_doc_alias_not_string_literal)]
194pub struct DocAliasNotStringLiteral {
194pub(crate) struct DocAliasNotStringLiteral {
195195 #[primary_span]
196196 pub span: Span,
197197}
198198
199199#[derive(Diagnostic)]
200200#[diag(passes_doc_alias_malformed)]
201pub struct DocAliasMalformed {
201pub(crate) struct DocAliasMalformed {
202202 #[primary_span]
203203 pub span: Span,
204204}
205205
206206#[derive(Diagnostic)]
207207#[diag(passes_doc_keyword_empty_mod)]
208pub struct DocKeywordEmptyMod {
208pub(crate) struct DocKeywordEmptyMod {
209209 #[primary_span]
210210 pub span: Span,
211211}
212212
213213#[derive(Diagnostic)]
214214#[diag(passes_doc_keyword_not_mod)]
215pub struct DocKeywordNotMod {
215pub(crate) struct DocKeywordNotMod {
216216 #[primary_span]
217217 pub span: Span,
218218}
219219
220220#[derive(Diagnostic)]
221221#[diag(passes_doc_keyword_invalid_ident)]
222pub struct DocKeywordInvalidIdent {
222pub(crate) struct DocKeywordInvalidIdent {
223223 #[primary_span]
224224 pub span: Span,
225225 pub doc_keyword: Symbol,
......@@ -227,14 +227,14 @@ pub struct DocKeywordInvalidIdent {
227227
228228#[derive(Diagnostic)]
229229#[diag(passes_doc_fake_variadic_not_valid)]
230pub struct DocFakeVariadicNotValid {
230pub(crate) struct DocFakeVariadicNotValid {
231231 #[primary_span]
232232 pub span: Span,
233233}
234234
235235#[derive(Diagnostic)]
236236#[diag(passes_doc_keyword_only_impl)]
237pub struct DocKeywordOnlyImpl {
237pub(crate) struct DocKeywordOnlyImpl {
238238 #[primary_span]
239239 pub span: Span,
240240}
......@@ -242,7 +242,7 @@ pub struct DocKeywordOnlyImpl {
242242#[derive(Diagnostic)]
243243#[diag(passes_doc_inline_conflict)]
244244#[help]
245pub struct DocKeywordConflict {
245pub(crate) struct DocKeywordConflict {
246246 #[primary_span]
247247 pub spans: MultiSpan,
248248}
......@@ -250,7 +250,7 @@ pub struct DocKeywordConflict {
250250#[derive(LintDiagnostic)]
251251#[diag(passes_doc_inline_only_use)]
252252#[note]
253pub struct DocInlineOnlyUse {
253pub(crate) struct DocInlineOnlyUse {
254254 #[label]
255255 pub attr_span: Span,
256256 #[label(passes_not_a_use_item_label)]
......@@ -260,7 +260,7 @@ pub struct DocInlineOnlyUse {
260260#[derive(LintDiagnostic)]
261261#[diag(passes_doc_masked_only_extern_crate)]
262262#[note]
263pub struct DocMaskedOnlyExternCrate {
263pub(crate) struct DocMaskedOnlyExternCrate {
264264 #[label]
265265 pub attr_span: Span,
266266 #[label(passes_not_an_extern_crate_label)]
......@@ -269,7 +269,7 @@ pub struct DocMaskedOnlyExternCrate {
269269
270270#[derive(LintDiagnostic)]
271271#[diag(passes_doc_masked_not_extern_crate_self)]
272pub struct DocMaskedNotExternCrateSelf {
272pub(crate) struct DocMaskedNotExternCrateSelf {
273273 #[label]
274274 pub attr_span: Span,
275275 #[label(passes_extern_crate_self_label)]
......@@ -278,7 +278,7 @@ pub struct DocMaskedNotExternCrateSelf {
278278
279279#[derive(Diagnostic)]
280280#[diag(passes_doc_attr_not_crate_level)]
281pub struct DocAttrNotCrateLevel<'a> {
281pub(crate) struct DocAttrNotCrateLevel<'a> {
282282 #[primary_span]
283283 pub span: Span,
284284 pub attr_name: &'a str,
......@@ -286,25 +286,25 @@ pub struct DocAttrNotCrateLevel<'a> {
286286
287287#[derive(LintDiagnostic)]
288288#[diag(passes_doc_test_unknown)]
289pub struct DocTestUnknown {
289pub(crate) struct DocTestUnknown {
290290 pub path: String,
291291}
292292
293293#[derive(LintDiagnostic)]
294294#[diag(passes_doc_test_literal)]
295pub struct DocTestLiteral;
295pub(crate) struct DocTestLiteral;
296296
297297#[derive(LintDiagnostic)]
298298#[diag(passes_doc_test_takes_list)]
299pub struct DocTestTakesList;
299pub(crate) struct DocTestTakesList;
300300
301301#[derive(LintDiagnostic)]
302302#[diag(passes_doc_cfg_hide_takes_list)]
303pub struct DocCfgHideTakesList;
303pub(crate) struct DocCfgHideTakesList;
304304
305305#[derive(LintDiagnostic)]
306306#[diag(passes_doc_test_unknown_any)]
307pub struct DocTestUnknownAny {
307pub(crate) struct DocTestUnknownAny {
308308 pub path: String,
309309}
310310
......@@ -312,7 +312,7 @@ pub struct DocTestUnknownAny {
312312#[diag(passes_doc_test_unknown_spotlight)]
313313#[note]
314314#[note(passes_no_op_note)]
315pub struct DocTestUnknownSpotlight {
315pub(crate) struct DocTestUnknownSpotlight {
316316 pub path: String,
317317 #[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
318318 pub span: Span,
......@@ -320,7 +320,7 @@ pub struct DocTestUnknownSpotlight {
320320
321321#[derive(LintDiagnostic)]
322322#[diag(passes_doc_test_unknown_include)]
323pub struct DocTestUnknownInclude {
323pub(crate) struct DocTestUnknownInclude {
324324 pub path: String,
325325 pub value: String,
326326 pub inner: &'static str,
......@@ -330,11 +330,11 @@ pub struct DocTestUnknownInclude {
330330
331331#[derive(LintDiagnostic)]
332332#[diag(passes_doc_invalid)]
333pub struct DocInvalid;
333pub(crate) struct DocInvalid;
334334
335335#[derive(Diagnostic)]
336336#[diag(passes_pass_by_value)]
337pub struct PassByValue {
337pub(crate) struct PassByValue {
338338 #[primary_span]
339339 pub attr_span: Span,
340340 #[label]
......@@ -343,7 +343,7 @@ pub struct PassByValue {
343343
344344#[derive(Diagnostic)]
345345#[diag(passes_allow_incoherent_impl)]
346pub struct AllowIncoherentImpl {
346pub(crate) struct AllowIncoherentImpl {
347347 #[primary_span]
348348 pub attr_span: Span,
349349 #[label]
......@@ -352,7 +352,7 @@ pub struct AllowIncoherentImpl {
352352
353353#[derive(Diagnostic)]
354354#[diag(passes_has_incoherent_inherent_impl)]
355pub struct HasIncoherentInherentImpl {
355pub(crate) struct HasIncoherentInherentImpl {
356356 #[primary_span]
357357 pub attr_span: Span,
358358 #[label]
......@@ -361,35 +361,35 @@ pub struct HasIncoherentInherentImpl {
361361
362362#[derive(Diagnostic)]
363363#[diag(passes_both_ffi_const_and_pure, code = E0757)]
364pub struct BothFfiConstAndPure {
364pub(crate) struct BothFfiConstAndPure {
365365 #[primary_span]
366366 pub attr_span: Span,
367367}
368368
369369#[derive(Diagnostic)]
370370#[diag(passes_ffi_pure_invalid_target, code = E0755)]
371pub struct FfiPureInvalidTarget {
371pub(crate) struct FfiPureInvalidTarget {
372372 #[primary_span]
373373 pub attr_span: Span,
374374}
375375
376376#[derive(Diagnostic)]
377377#[diag(passes_ffi_const_invalid_target, code = E0756)]
378pub struct FfiConstInvalidTarget {
378pub(crate) struct FfiConstInvalidTarget {
379379 #[primary_span]
380380 pub attr_span: Span,
381381}
382382
383383#[derive(LintDiagnostic)]
384384#[diag(passes_must_use_no_effect)]
385pub struct MustUseNoEffect {
385pub(crate) struct MustUseNoEffect {
386386 pub article: &'static str,
387387 pub target: rustc_hir::Target,
388388}
389389
390390#[derive(Diagnostic)]
391391#[diag(passes_must_not_suspend)]
392pub struct MustNotSuspend {
392pub(crate) struct MustNotSuspend {
393393 #[primary_span]
394394 pub attr_span: Span,
395395 #[label]
......@@ -399,7 +399,7 @@ pub struct MustNotSuspend {
399399#[derive(LintDiagnostic)]
400400#[diag(passes_cold)]
401401#[warning]
402pub struct Cold {
402pub(crate) struct Cold {
403403 #[label]
404404 pub span: Span,
405405 pub on_crate: bool,
......@@ -408,7 +408,7 @@ pub struct Cold {
408408#[derive(LintDiagnostic)]
409409#[diag(passes_link)]
410410#[warning]
411pub struct Link {
411pub(crate) struct Link {
412412 #[label]
413413 pub span: Option<Span>,
414414}
......@@ -416,7 +416,7 @@ pub struct Link {
416416#[derive(LintDiagnostic)]
417417#[diag(passes_link_name)]
418418#[warning]
419pub struct LinkName<'a> {
419pub(crate) struct LinkName<'a> {
420420 #[help]
421421 pub attr_span: Option<Span>,
422422 #[label]
......@@ -426,7 +426,7 @@ pub struct LinkName<'a> {
426426
427427#[derive(Diagnostic)]
428428#[diag(passes_no_link)]
429pub struct NoLink {
429pub(crate) struct NoLink {
430430 #[primary_span]
431431 pub attr_span: Span,
432432 #[label]
......@@ -435,7 +435,7 @@ pub struct NoLink {
435435
436436#[derive(Diagnostic)]
437437#[diag(passes_export_name)]
438pub struct ExportName {
438pub(crate) struct ExportName {
439439 #[primary_span]
440440 pub attr_span: Span,
441441 #[label]
......@@ -444,7 +444,7 @@ pub struct ExportName {
444444
445445#[derive(Diagnostic)]
446446#[diag(passes_rustc_layout_scalar_valid_range_not_struct)]
447pub struct RustcLayoutScalarValidRangeNotStruct {
447pub(crate) struct RustcLayoutScalarValidRangeNotStruct {
448448 #[primary_span]
449449 pub attr_span: Span,
450450 #[label]
......@@ -453,14 +453,14 @@ pub struct RustcLayoutScalarValidRangeNotStruct {
453453
454454#[derive(Diagnostic)]
455455#[diag(passes_rustc_layout_scalar_valid_range_arg)]
456pub struct RustcLayoutScalarValidRangeArg {
456pub(crate) struct RustcLayoutScalarValidRangeArg {
457457 #[primary_span]
458458 pub attr_span: Span,
459459}
460460
461461#[derive(Diagnostic)]
462462#[diag(passes_rustc_legacy_const_generics_only)]
463pub struct RustcLegacyConstGenericsOnly {
463pub(crate) struct RustcLegacyConstGenericsOnly {
464464 #[primary_span]
465465 pub attr_span: Span,
466466 #[label]
......@@ -469,7 +469,7 @@ pub struct RustcLegacyConstGenericsOnly {
469469
470470#[derive(Diagnostic)]
471471#[diag(passes_rustc_legacy_const_generics_index)]
472pub struct RustcLegacyConstGenericsIndex {
472pub(crate) struct RustcLegacyConstGenericsIndex {
473473 #[primary_span]
474474 pub attr_span: Span,
475475 #[label]
......@@ -478,7 +478,7 @@ pub struct RustcLegacyConstGenericsIndex {
478478
479479#[derive(Diagnostic)]
480480#[diag(passes_rustc_legacy_const_generics_index_exceed)]
481pub struct RustcLegacyConstGenericsIndexExceed {
481pub(crate) struct RustcLegacyConstGenericsIndexExceed {
482482 #[primary_span]
483483 #[label]
484484 pub span: Span,
......@@ -487,14 +487,14 @@ pub struct RustcLegacyConstGenericsIndexExceed {
487487
488488#[derive(Diagnostic)]
489489#[diag(passes_rustc_legacy_const_generics_index_negative)]
490pub struct RustcLegacyConstGenericsIndexNegative {
490pub(crate) struct RustcLegacyConstGenericsIndexNegative {
491491 #[primary_span]
492492 pub invalid_args: Vec<Span>,
493493}
494494
495495#[derive(Diagnostic)]
496496#[diag(passes_rustc_dirty_clean)]
497pub struct RustcDirtyClean {
497pub(crate) struct RustcDirtyClean {
498498 #[primary_span]
499499 pub span: Span,
500500}
......@@ -502,7 +502,7 @@ pub struct RustcDirtyClean {
502502#[derive(LintDiagnostic)]
503503#[diag(passes_link_section)]
504504#[warning]
505pub struct LinkSection {
505pub(crate) struct LinkSection {
506506 #[label]
507507 pub span: Span,
508508}
......@@ -511,7 +511,7 @@ pub struct LinkSection {
511511#[diag(passes_no_mangle_foreign)]
512512#[warning]
513513#[note]
514pub struct NoMangleForeign {
514pub(crate) struct NoMangleForeign {
515515 #[label]
516516 pub span: Span,
517517 #[suggestion(code = "", applicability = "machine-applicable")]
......@@ -522,32 +522,32 @@ pub struct NoMangleForeign {
522522#[derive(LintDiagnostic)]
523523#[diag(passes_no_mangle)]
524524#[warning]
525pub struct NoMangle {
525pub(crate) struct NoMangle {
526526 #[label]
527527 pub span: Span,
528528}
529529
530530#[derive(Diagnostic)]
531531#[diag(passes_repr_ident, code = E0565)]
532pub struct ReprIdent {
532pub(crate) struct ReprIdent {
533533 #[primary_span]
534534 pub span: Span,
535535}
536536
537537#[derive(Diagnostic)]
538538#[diag(passes_repr_conflicting, code = E0566)]
539pub struct ReprConflicting {
539pub(crate) struct ReprConflicting {
540540 #[primary_span]
541541 pub hint_spans: Vec<Span>,
542542}
543543
544544#[derive(LintDiagnostic)]
545545#[diag(passes_repr_conflicting, code = E0566)]
546pub struct ReprConflictingLint;
546pub(crate) struct ReprConflictingLint;
547547
548548#[derive(Diagnostic)]
549549#[diag(passes_used_static)]
550pub struct UsedStatic {
550pub(crate) struct UsedStatic {
551551 #[primary_span]
552552 pub attr_span: Span,
553553 #[label]
......@@ -557,14 +557,14 @@ pub struct UsedStatic {
557557
558558#[derive(Diagnostic)]
559559#[diag(passes_used_compiler_linker)]
560pub struct UsedCompilerLinker {
560pub(crate) struct UsedCompilerLinker {
561561 #[primary_span]
562562 pub spans: Vec<Span>,
563563}
564564
565565#[derive(Diagnostic)]
566566#[diag(passes_allow_internal_unstable)]
567pub struct AllowInternalUnstable {
567pub(crate) struct AllowInternalUnstable {
568568 #[primary_span]
569569 pub attr_span: Span,
570570 #[label]
......@@ -573,7 +573,7 @@ pub struct AllowInternalUnstable {
573573
574574#[derive(Diagnostic)]
575575#[diag(passes_debug_visualizer_placement)]
576pub struct DebugVisualizerPlacement {
576pub(crate) struct DebugVisualizerPlacement {
577577 #[primary_span]
578578 pub span: Span,
579579}
......@@ -583,14 +583,14 @@ pub struct DebugVisualizerPlacement {
583583#[note(passes_note_1)]
584584#[note(passes_note_2)]
585585#[note(passes_note_3)]
586pub struct DebugVisualizerInvalid {
586pub(crate) struct DebugVisualizerInvalid {
587587 #[primary_span]
588588 pub span: Span,
589589}
590590
591591#[derive(Diagnostic)]
592592#[diag(passes_debug_visualizer_unreadable)]
593pub struct DebugVisualizerUnreadable<'a> {
593pub(crate) struct DebugVisualizerUnreadable<'a> {
594594 #[primary_span]
595595 pub span: Span,
596596 pub file: &'a Path,
......@@ -599,7 +599,7 @@ pub struct DebugVisualizerUnreadable<'a> {
599599
600600#[derive(Diagnostic)]
601601#[diag(passes_rustc_allow_const_fn_unstable)]
602pub struct RustcAllowConstFnUnstable {
602pub(crate) struct RustcAllowConstFnUnstable {
603603 #[primary_span]
604604 pub attr_span: Span,
605605 #[label]
......@@ -608,7 +608,7 @@ pub struct RustcAllowConstFnUnstable {
608608
609609#[derive(Diagnostic)]
610610#[diag(passes_rustc_safe_intrinsic)]
611pub struct RustcSafeIntrinsic {
611pub(crate) struct RustcSafeIntrinsic {
612612 #[primary_span]
613613 pub attr_span: Span,
614614 #[label]
......@@ -617,7 +617,7 @@ pub struct RustcSafeIntrinsic {
617617
618618#[derive(Diagnostic)]
619619#[diag(passes_rustc_std_internal_symbol)]
620pub struct RustcStdInternalSymbol {
620pub(crate) struct RustcStdInternalSymbol {
621621 #[primary_span]
622622 pub attr_span: Span,
623623 #[label]
......@@ -626,7 +626,7 @@ pub struct RustcStdInternalSymbol {
626626
627627#[derive(Diagnostic)]
628628#[diag(passes_rustc_pub_transparent)]
629pub struct RustcPubTransparent {
629pub(crate) struct RustcPubTransparent {
630630 #[primary_span]
631631 pub attr_span: Span,
632632 #[label]
......@@ -635,28 +635,28 @@ pub struct RustcPubTransparent {
635635
636636#[derive(Diagnostic)]
637637#[diag(passes_link_ordinal)]
638pub struct LinkOrdinal {
638pub(crate) struct LinkOrdinal {
639639 #[primary_span]
640640 pub attr_span: Span,
641641}
642642
643643#[derive(Diagnostic)]
644644#[diag(passes_confusables)]
645pub struct Confusables {
645pub(crate) struct Confusables {
646646 #[primary_span]
647647 pub attr_span: Span,
648648}
649649
650650#[derive(Diagnostic)]
651651#[diag(passes_coroutine_on_non_closure)]
652pub struct CoroutineOnNonClosure {
652pub(crate) struct CoroutineOnNonClosure {
653653 #[primary_span]
654654 pub span: Span,
655655}
656656
657657#[derive(Diagnostic)]
658658#[diag(passes_linkage)]
659pub struct Linkage {
659pub(crate) struct Linkage {
660660 #[primary_span]
661661 pub attr_span: Span,
662662 #[label]
......@@ -690,23 +690,23 @@ pub(crate) struct IncorrectMetaItemSuggestion {
690690
691691#[derive(Diagnostic)]
692692#[diag(passes_stability_promotable)]
693pub struct StabilityPromotable {
693pub(crate) struct StabilityPromotable {
694694 #[primary_span]
695695 pub attr_span: Span,
696696}
697697
698698#[derive(LintDiagnostic)]
699699#[diag(passes_deprecated)]
700pub struct Deprecated;
700pub(crate) struct Deprecated;
701701
702702#[derive(LintDiagnostic)]
703703#[diag(passes_macro_use)]
704pub struct MacroUse {
704pub(crate) struct MacroUse {
705705 pub name: Symbol,
706706}
707707
708708#[derive(LintDiagnostic)]
709pub enum MacroExport {
709pub(crate) enum MacroExport {
710710 #[diag(passes_macro_export)]
711711 Normal,
712712
......@@ -722,7 +722,7 @@ pub enum MacroExport {
722722}
723723
724724#[derive(Subdiagnostic)]
725pub enum UnusedNote {
725pub(crate) enum UnusedNote {
726726 #[note(passes_unused_empty_lints_note)]
727727 EmptyList { name: Symbol },
728728 #[note(passes_unused_no_lints_note)]
......@@ -733,7 +733,7 @@ pub enum UnusedNote {
733733
734734#[derive(LintDiagnostic)]
735735#[diag(passes_unused)]
736pub struct Unused {
736pub(crate) struct Unused {
737737 #[suggestion(code = "", applicability = "machine-applicable")]
738738 pub attr_span: Span,
739739 #[subdiagnostic]
......@@ -742,7 +742,7 @@ pub struct Unused {
742742
743743#[derive(Diagnostic)]
744744#[diag(passes_non_exported_macro_invalid_attrs, code = E0518)]
745pub struct NonExportedMacroInvalidAttrs {
745pub(crate) struct NonExportedMacroInvalidAttrs {
746746 #[primary_span]
747747 #[label]
748748 pub attr_span: Span,
......@@ -750,14 +750,14 @@ pub struct NonExportedMacroInvalidAttrs {
750750
751751#[derive(Diagnostic)]
752752#[diag(passes_may_dangle)]
753pub struct InvalidMayDangle {
753pub(crate) struct InvalidMayDangle {
754754 #[primary_span]
755755 pub attr_span: Span,
756756}
757757
758758#[derive(LintDiagnostic)]
759759#[diag(passes_unused_duplicate)]
760pub struct UnusedDuplicate {
760pub(crate) struct UnusedDuplicate {
761761 #[suggestion(code = "", applicability = "machine-applicable")]
762762 pub this: Span,
763763 #[note]
......@@ -768,7 +768,7 @@ pub struct UnusedDuplicate {
768768
769769#[derive(Diagnostic)]
770770#[diag(passes_unused_multiple)]
771pub struct UnusedMultiple {
771pub(crate) struct UnusedMultiple {
772772 #[primary_span]
773773 #[suggestion(code = "", applicability = "machine-applicable")]
774774 pub this: Span,
......@@ -779,7 +779,7 @@ pub struct UnusedMultiple {
779779
780780#[derive(Diagnostic)]
781781#[diag(passes_rustc_lint_opt_ty)]
782pub struct RustcLintOptTy {
782pub(crate) struct RustcLintOptTy {
783783 #[primary_span]
784784 pub attr_span: Span,
785785 #[label]
......@@ -788,7 +788,7 @@ pub struct RustcLintOptTy {
788788
789789#[derive(Diagnostic)]
790790#[diag(passes_rustc_lint_opt_deny_field_access)]
791pub struct RustcLintOptDenyFieldAccess {
791pub(crate) struct RustcLintOptDenyFieldAccess {
792792 #[primary_span]
793793 pub attr_span: Span,
794794 #[label]
......@@ -797,7 +797,7 @@ pub struct RustcLintOptDenyFieldAccess {
797797
798798#[derive(Diagnostic)]
799799#[diag(passes_collapse_debuginfo)]
800pub struct CollapseDebuginfo {
800pub(crate) struct CollapseDebuginfo {
801801 #[primary_span]
802802 pub attr_span: Span,
803803 #[label]
......@@ -806,14 +806,14 @@ pub struct CollapseDebuginfo {
806806
807807#[derive(LintDiagnostic)]
808808#[diag(passes_deprecated_annotation_has_no_effect)]
809pub struct DeprecatedAnnotationHasNoEffect {
809pub(crate) struct DeprecatedAnnotationHasNoEffect {
810810 #[suggestion(applicability = "machine-applicable", code = "")]
811811 pub span: Span,
812812}
813813
814814#[derive(Diagnostic)]
815815#[diag(passes_unknown_external_lang_item, code = E0264)]
816pub struct UnknownExternLangItem {
816pub(crate) struct UnknownExternLangItem {
817817 #[primary_span]
818818 pub span: Span,
819819 pub lang_item: Symbol,
......@@ -821,25 +821,25 @@ pub struct UnknownExternLangItem {
821821
822822#[derive(Diagnostic)]
823823#[diag(passes_missing_panic_handler)]
824pub struct MissingPanicHandler;
824pub(crate) struct MissingPanicHandler;
825825
826826#[derive(Diagnostic)]
827827#[diag(passes_panic_unwind_without_std)]
828828#[help]
829829#[note]
830pub struct PanicUnwindWithoutStd;
830pub(crate) struct PanicUnwindWithoutStd;
831831
832832#[derive(Diagnostic)]
833833#[diag(passes_missing_lang_item)]
834834#[note]
835835#[help]
836pub struct MissingLangItem {
836pub(crate) struct MissingLangItem {
837837 pub name: Symbol,
838838}
839839
840840#[derive(Diagnostic)]
841841#[diag(passes_lang_item_fn_with_track_caller)]
842pub struct LangItemWithTrackCaller {
842pub(crate) struct LangItemWithTrackCaller {
843843 #[primary_span]
844844 pub attr_span: Span,
845845 pub name: Symbol,
......@@ -849,7 +849,7 @@ pub struct LangItemWithTrackCaller {
849849
850850#[derive(Diagnostic)]
851851#[diag(passes_lang_item_fn_with_target_feature)]
852pub struct LangItemWithTargetFeature {
852pub(crate) struct LangItemWithTargetFeature {
853853 #[primary_span]
854854 pub attr_span: Span,
855855 pub name: Symbol,
......@@ -859,7 +859,7 @@ pub struct LangItemWithTargetFeature {
859859
860860#[derive(Diagnostic)]
861861#[diag(passes_lang_item_on_incorrect_target, code = E0718)]
862pub struct LangItemOnIncorrectTarget {
862pub(crate) struct LangItemOnIncorrectTarget {
863863 #[primary_span]
864864 #[label]
865865 pub span: Span,
......@@ -870,14 +870,14 @@ pub struct LangItemOnIncorrectTarget {
870870
871871#[derive(Diagnostic)]
872872#[diag(passes_unknown_lang_item, code = E0522)]
873pub struct UnknownLangItem {
873pub(crate) struct UnknownLangItem {
874874 #[primary_span]
875875 #[label]
876876 pub span: Span,
877877 pub name: Symbol,
878878}
879879
880pub struct InvalidAttrAtCrateLevel {
880pub(crate) struct InvalidAttrAtCrateLevel {
881881 pub span: Span,
882882 pub sugg_span: Option<Span>,
883883 pub name: Symbol,
......@@ -885,7 +885,7 @@ pub struct InvalidAttrAtCrateLevel {
885885}
886886
887887#[derive(Clone, Copy)]
888pub struct ItemFollowingInnerAttr {
888pub(crate) struct ItemFollowingInnerAttr {
889889 pub span: Span,
890890 pub kind: &'static str,
891891}
......@@ -916,7 +916,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
916916
917917#[derive(Diagnostic)]
918918#[diag(passes_duplicate_diagnostic_item_in_crate)]
919pub struct DuplicateDiagnosticItemInCrate {
919pub(crate) struct DuplicateDiagnosticItemInCrate {
920920 #[primary_span]
921921 pub duplicate_span: Option<Span>,
922922 #[note(passes_diagnostic_item_first_defined)]
......@@ -930,7 +930,7 @@ pub struct DuplicateDiagnosticItemInCrate {
930930
931931#[derive(Diagnostic)]
932932#[diag(passes_layout_abi)]
933pub struct LayoutAbi {
933pub(crate) struct LayoutAbi {
934934 #[primary_span]
935935 pub span: Span,
936936 pub abi: String,
......@@ -938,7 +938,7 @@ pub struct LayoutAbi {
938938
939939#[derive(Diagnostic)]
940940#[diag(passes_layout_align)]
941pub struct LayoutAlign {
941pub(crate) struct LayoutAlign {
942942 #[primary_span]
943943 pub span: Span,
944944 pub align: String,
......@@ -946,7 +946,7 @@ pub struct LayoutAlign {
946946
947947#[derive(Diagnostic)]
948948#[diag(passes_layout_size)]
949pub struct LayoutSize {
949pub(crate) struct LayoutSize {
950950 #[primary_span]
951951 pub span: Span,
952952 pub size: String,
......@@ -954,7 +954,7 @@ pub struct LayoutSize {
954954
955955#[derive(Diagnostic)]
956956#[diag(passes_layout_homogeneous_aggregate)]
957pub struct LayoutHomogeneousAggregate {
957pub(crate) struct LayoutHomogeneousAggregate {
958958 #[primary_span]
959959 pub span: Span,
960960 pub homogeneous_aggregate: String,
......@@ -962,7 +962,7 @@ pub struct LayoutHomogeneousAggregate {
962962
963963#[derive(Diagnostic)]
964964#[diag(passes_layout_of)]
965pub struct LayoutOf {
965pub(crate) struct LayoutOf {
966966 #[primary_span]
967967 pub span: Span,
968968 pub normalized_ty: String,
......@@ -971,14 +971,14 @@ pub struct LayoutOf {
971971
972972#[derive(Diagnostic)]
973973#[diag(passes_layout_invalid_attribute)]
974pub struct LayoutInvalidAttribute {
974pub(crate) struct LayoutInvalidAttribute {
975975 #[primary_span]
976976 pub span: Span,
977977}
978978
979979#[derive(Diagnostic)]
980980#[diag(passes_abi_of)]
981pub struct AbiOf {
981pub(crate) struct AbiOf {
982982 #[primary_span]
983983 pub span: Span,
984984 pub fn_name: Symbol,
......@@ -987,7 +987,7 @@ pub struct AbiOf {
987987
988988#[derive(Diagnostic)]
989989#[diag(passes_abi_ne)]
990pub struct AbiNe {
990pub(crate) struct AbiNe {
991991 #[primary_span]
992992 pub span: Span,
993993 pub left: String,
......@@ -996,14 +996,14 @@ pub struct AbiNe {
996996
997997#[derive(Diagnostic)]
998998#[diag(passes_abi_invalid_attribute)]
999pub struct AbiInvalidAttribute {
999pub(crate) struct AbiInvalidAttribute {
10001000 #[primary_span]
10011001 pub span: Span,
10021002}
10031003
10041004#[derive(Diagnostic)]
10051005#[diag(passes_unrecognized_field)]
1006pub struct UnrecognizedField {
1006pub(crate) struct UnrecognizedField {
10071007 #[primary_span]
10081008 pub span: Span,
10091009 pub name: Symbol,
......@@ -1011,7 +1011,7 @@ pub struct UnrecognizedField {
10111011
10121012#[derive(Diagnostic)]
10131013#[diag(passes_feature_stable_twice, code = E0711)]
1014pub struct FeatureStableTwice {
1014pub(crate) struct FeatureStableTwice {
10151015 #[primary_span]
10161016 pub span: Span,
10171017 pub feature: Symbol,
......@@ -1021,7 +1021,7 @@ pub struct FeatureStableTwice {
10211021
10221022#[derive(Diagnostic)]
10231023#[diag(passes_feature_previously_declared, code = E0711)]
1024pub struct FeaturePreviouslyDeclared<'a, 'b> {
1024pub(crate) struct FeaturePreviouslyDeclared<'a, 'b> {
10251025 #[primary_span]
10261026 pub span: Span,
10271027 pub feature: Symbol,
......@@ -1029,7 +1029,7 @@ pub struct FeaturePreviouslyDeclared<'a, 'b> {
10291029 pub prev_declared: &'b str,
10301030}
10311031
1032pub struct BreakNonLoop<'a> {
1032pub(crate) struct BreakNonLoop<'a> {
10331033 pub span: Span,
10341034 pub head: Option<Span>,
10351035 pub kind: &'a str,
......@@ -1084,7 +1084,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
10841084
10851085#[derive(Diagnostic)]
10861086#[diag(passes_continue_labeled_block, code = E0696)]
1087pub struct ContinueLabeledBlock {
1087pub(crate) struct ContinueLabeledBlock {
10881088 #[primary_span]
10891089 #[label]
10901090 pub span: Span,
......@@ -1094,7 +1094,7 @@ pub struct ContinueLabeledBlock {
10941094
10951095#[derive(Diagnostic)]
10961096#[diag(passes_break_inside_closure, code = E0267)]
1097pub struct BreakInsideClosure<'a> {
1097pub(crate) struct BreakInsideClosure<'a> {
10981098 #[primary_span]
10991099 #[label]
11001100 pub span: Span,
......@@ -1105,7 +1105,7 @@ pub struct BreakInsideClosure<'a> {
11051105
11061106#[derive(Diagnostic)]
11071107#[diag(passes_break_inside_coroutine, code = E0267)]
1108pub struct BreakInsideCoroutine<'a> {
1108pub(crate) struct BreakInsideCoroutine<'a> {
11091109 #[primary_span]
11101110 #[label]
11111111 pub span: Span,
......@@ -1118,7 +1118,7 @@ pub struct BreakInsideCoroutine<'a> {
11181118
11191119#[derive(Diagnostic)]
11201120#[diag(passes_outside_loop, code = E0268)]
1121pub struct OutsideLoop<'a> {
1121pub(crate) struct OutsideLoop<'a> {
11221122 #[primary_span]
11231123 #[label]
11241124 pub spans: Vec<Span>,
......@@ -1129,7 +1129,7 @@ pub struct OutsideLoop<'a> {
11291129}
11301130#[derive(Subdiagnostic)]
11311131#[multipart_suggestion(passes_outside_loop_suggestion, applicability = "maybe-incorrect")]
1132pub struct OutsideLoopSuggestion {
1132pub(crate) struct OutsideLoopSuggestion {
11331133 #[suggestion_part(code = "'block: ")]
11341134 pub block_span: Span,
11351135 #[suggestion_part(code = " 'block")]
......@@ -1138,7 +1138,7 @@ pub struct OutsideLoopSuggestion {
11381138
11391139#[derive(Diagnostic)]
11401140#[diag(passes_unlabeled_in_labeled_block, code = E0695)]
1141pub struct UnlabeledInLabeledBlock<'a> {
1141pub(crate) struct UnlabeledInLabeledBlock<'a> {
11421142 #[primary_span]
11431143 #[label]
11441144 pub span: Span,
......@@ -1147,7 +1147,7 @@ pub struct UnlabeledInLabeledBlock<'a> {
11471147
11481148#[derive(Diagnostic)]
11491149#[diag(passes_unlabeled_cf_in_while_condition, code = E0590)]
1150pub struct UnlabeledCfInWhileCondition<'a> {
1150pub(crate) struct UnlabeledCfInWhileCondition<'a> {
11511151 #[primary_span]
11521152 #[label]
11531153 pub span: Span,
......@@ -1156,11 +1156,11 @@ pub struct UnlabeledCfInWhileCondition<'a> {
11561156
11571157#[derive(LintDiagnostic)]
11581158#[diag(passes_undefined_naked_function_abi)]
1159pub struct UndefinedNakedFunctionAbi;
1159pub(crate) struct UndefinedNakedFunctionAbi;
11601160
11611161#[derive(Diagnostic)]
11621162#[diag(passes_no_patterns)]
1163pub struct NoPatterns {
1163pub(crate) struct NoPatterns {
11641164 #[primary_span]
11651165 pub span: Span,
11661166}
......@@ -1168,12 +1168,12 @@ pub struct NoPatterns {
11681168#[derive(Diagnostic)]
11691169#[diag(passes_params_not_allowed)]
11701170#[help]
1171pub struct ParamsNotAllowed {
1171pub(crate) struct ParamsNotAllowed {
11721172 #[primary_span]
11731173 pub span: Span,
11741174}
11751175
1176pub struct NakedFunctionsAsmBlock {
1176pub(crate) struct NakedFunctionsAsmBlock {
11771177 pub span: Span,
11781178 pub multiple_asms: Vec<Span>,
11791179 pub non_asms: Vec<Span>,
......@@ -1197,14 +1197,14 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for NakedFunctionsAsmBlock {
11971197
11981198#[derive(Diagnostic)]
11991199#[diag(passes_naked_functions_operands, code = E0787)]
1200pub struct NakedFunctionsOperands {
1200pub(crate) struct NakedFunctionsOperands {
12011201 #[primary_span]
12021202 pub unsupported_operands: Vec<Span>,
12031203}
12041204
12051205#[derive(Diagnostic)]
12061206#[diag(passes_naked_functions_asm_options, code = E0787)]
1207pub struct NakedFunctionsAsmOptions {
1207pub(crate) struct NakedFunctionsAsmOptions {
12081208 #[primary_span]
12091209 pub span: Span,
12101210 pub unsupported_options: String,
......@@ -1212,7 +1212,7 @@ pub struct NakedFunctionsAsmOptions {
12121212
12131213#[derive(Diagnostic)]
12141214#[diag(passes_naked_functions_must_use_noreturn, code = E0787)]
1215pub struct NakedFunctionsMustUseNoreturn {
1215pub(crate) struct NakedFunctionsMustUseNoreturn {
12161216 #[primary_span]
12171217 pub span: Span,
12181218 #[suggestion(code = ", options(noreturn)", applicability = "machine-applicable")]
......@@ -1221,7 +1221,7 @@ pub struct NakedFunctionsMustUseNoreturn {
12211221
12221222#[derive(Diagnostic)]
12231223#[diag(passes_naked_functions_incompatible_attribute, code = E0736)]
1224pub struct NakedFunctionIncompatibleAttribute {
1224pub(crate) struct NakedFunctionIncompatibleAttribute {
12251225 #[primary_span]
12261226 #[label]
12271227 pub span: Span,
......@@ -1232,7 +1232,7 @@ pub struct NakedFunctionIncompatibleAttribute {
12321232
12331233#[derive(Diagnostic)]
12341234#[diag(passes_attr_only_in_functions)]
1235pub struct AttrOnlyInFunctions {
1235pub(crate) struct AttrOnlyInFunctions {
12361236 #[primary_span]
12371237 pub span: Span,
12381238 pub attr: Symbol,
......@@ -1240,7 +1240,7 @@ pub struct AttrOnlyInFunctions {
12401240
12411241#[derive(Diagnostic)]
12421242#[diag(passes_multiple_rustc_main, code = E0137)]
1243pub struct MultipleRustcMain {
1243pub(crate) struct MultipleRustcMain {
12441244 #[primary_span]
12451245 pub span: Span,
12461246 #[label(passes_first)]
......@@ -1251,7 +1251,7 @@ pub struct MultipleRustcMain {
12511251
12521252#[derive(Diagnostic)]
12531253#[diag(passes_multiple_start_functions, code = E0138)]
1254pub struct MultipleStartFunctions {
1254pub(crate) struct MultipleStartFunctions {
12551255 #[primary_span]
12561256 pub span: Span,
12571257 #[label]
......@@ -1262,12 +1262,12 @@ pub struct MultipleStartFunctions {
12621262
12631263#[derive(Diagnostic)]
12641264#[diag(passes_extern_main)]
1265pub struct ExternMain {
1265pub(crate) struct ExternMain {
12661266 #[primary_span]
12671267 pub span: Span,
12681268}
12691269
1270pub struct NoMainErr {
1270pub(crate) struct NoMainErr {
12711271 pub sp: Span,
12721272 pub crate_name: Symbol,
12731273 pub has_filename: bool,
......@@ -1321,7 +1321,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
13211321 }
13221322}
13231323
1324pub struct DuplicateLangItem {
1324pub(crate) struct DuplicateLangItem {
13251325 pub local_span: Option<Span>,
13261326 pub lang_item_name: Symbol,
13271327 pub crate_name: Symbol,
......@@ -1386,7 +1386,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
13861386
13871387#[derive(Diagnostic)]
13881388#[diag(passes_incorrect_target, code = E0718)]
1389pub struct IncorrectTarget<'a> {
1389pub(crate) struct IncorrectTarget<'a> {
13901390 #[primary_span]
13911391 pub span: Span,
13921392 #[label]
......@@ -1400,21 +1400,21 @@ pub struct IncorrectTarget<'a> {
14001400
14011401#[derive(LintDiagnostic)]
14021402#[diag(passes_useless_assignment)]
1403pub struct UselessAssignment<'a> {
1403pub(crate) struct UselessAssignment<'a> {
14041404 pub is_field_assign: bool,
14051405 pub ty: Ty<'a>,
14061406}
14071407
14081408#[derive(LintDiagnostic)]
14091409#[diag(passes_only_has_effect_on)]
1410pub struct OnlyHasEffectOn {
1410pub(crate) struct OnlyHasEffectOn {
14111411 pub attr_name: Symbol,
14121412 pub target_name: String,
14131413}
14141414
14151415#[derive(Diagnostic)]
14161416#[diag(passes_object_lifetime_err)]
1417pub struct ObjectLifetimeErr {
1417pub(crate) struct ObjectLifetimeErr {
14181418 #[primary_span]
14191419 pub span: Span,
14201420 pub repr: String,
......@@ -1423,13 +1423,13 @@ pub struct ObjectLifetimeErr {
14231423#[derive(Diagnostic)]
14241424#[diag(passes_unrecognized_repr_hint, code = E0552)]
14251425#[help]
1426pub struct UnrecognizedReprHint {
1426pub(crate) struct UnrecognizedReprHint {
14271427 #[primary_span]
14281428 pub span: Span,
14291429}
14301430
14311431#[derive(Diagnostic)]
1432pub enum AttrApplication {
1432pub(crate) enum AttrApplication {
14331433 #[diag(passes_attr_application_enum, code = E0517)]
14341434 Enum {
14351435 #[primary_span]
......@@ -1469,7 +1469,7 @@ pub enum AttrApplication {
14691469
14701470#[derive(Diagnostic)]
14711471#[diag(passes_transparent_incompatible, code = E0692)]
1472pub struct TransparentIncompatible {
1472pub(crate) struct TransparentIncompatible {
14731473 #[primary_span]
14741474 pub hint_spans: Vec<Span>,
14751475 pub target: String,
......@@ -1477,14 +1477,14 @@ pub struct TransparentIncompatible {
14771477
14781478#[derive(Diagnostic)]
14791479#[diag(passes_deprecated_attribute, code = E0549)]
1480pub struct DeprecatedAttribute {
1480pub(crate) struct DeprecatedAttribute {
14811481 #[primary_span]
14821482 pub span: Span,
14831483}
14841484
14851485#[derive(Diagnostic)]
14861486#[diag(passes_useless_stability)]
1487pub struct UselessStability {
1487pub(crate) struct UselessStability {
14881488 #[primary_span]
14891489 #[label]
14901490 pub span: Span,
......@@ -1494,7 +1494,7 @@ pub struct UselessStability {
14941494
14951495#[derive(Diagnostic)]
14961496#[diag(passes_cannot_stabilize_deprecated)]
1497pub struct CannotStabilizeDeprecated {
1497pub(crate) struct CannotStabilizeDeprecated {
14981498 #[primary_span]
14991499 #[label]
15001500 pub span: Span,
......@@ -1504,7 +1504,7 @@ pub struct CannotStabilizeDeprecated {
15041504
15051505#[derive(Diagnostic)]
15061506#[diag(passes_missing_stability_attr)]
1507pub struct MissingStabilityAttr<'a> {
1507pub(crate) struct MissingStabilityAttr<'a> {
15081508 #[primary_span]
15091509 pub span: Span,
15101510 pub descr: &'a str,
......@@ -1512,7 +1512,7 @@ pub struct MissingStabilityAttr<'a> {
15121512
15131513#[derive(Diagnostic)]
15141514#[diag(passes_missing_const_stab_attr)]
1515pub struct MissingConstStabAttr<'a> {
1515pub(crate) struct MissingConstStabAttr<'a> {
15161516 #[primary_span]
15171517 pub span: Span,
15181518 pub descr: &'a str,
......@@ -1521,14 +1521,14 @@ pub struct MissingConstStabAttr<'a> {
15211521#[derive(Diagnostic)]
15221522#[diag(passes_trait_impl_const_stable)]
15231523#[note]
1524pub struct TraitImplConstStable {
1524pub(crate) struct TraitImplConstStable {
15251525 #[primary_span]
15261526 pub span: Span,
15271527}
15281528
15291529#[derive(Diagnostic)]
15301530#[diag(passes_unknown_feature, code = E0635)]
1531pub struct UnknownFeature {
1531pub(crate) struct UnknownFeature {
15321532 #[primary_span]
15331533 pub span: Span,
15341534 pub feature: Symbol,
......@@ -1536,7 +1536,7 @@ pub struct UnknownFeature {
15361536
15371537#[derive(Diagnostic)]
15381538#[diag(passes_implied_feature_not_exist)]
1539pub struct ImpliedFeatureNotExist {
1539pub(crate) struct ImpliedFeatureNotExist {
15401540 #[primary_span]
15411541 pub span: Span,
15421542 pub feature: Symbol,
......@@ -1545,14 +1545,14 @@ pub struct ImpliedFeatureNotExist {
15451545
15461546#[derive(Diagnostic)]
15471547#[diag(passes_duplicate_feature_err, code = E0636)]
1548pub struct DuplicateFeatureErr {
1548pub(crate) struct DuplicateFeatureErr {
15491549 #[primary_span]
15501550 pub span: Span,
15511551 pub feature: Symbol,
15521552}
15531553#[derive(Diagnostic)]
15541554#[diag(passes_missing_const_err)]
1555pub struct MissingConstErr {
1555pub(crate) struct MissingConstErr {
15561556 #[primary_span]
15571557 #[help]
15581558 pub fn_sig_span: Span,
......@@ -1561,7 +1561,7 @@ pub struct MissingConstErr {
15611561}
15621562
15631563#[derive(LintDiagnostic)]
1564pub enum MultipleDeadCodes<'tcx> {
1564pub(crate) enum MultipleDeadCodes<'tcx> {
15651565 #[diag(passes_dead_codes)]
15661566 DeadCodes {
15671567 multiple: bool,
......@@ -1592,7 +1592,7 @@ pub enum MultipleDeadCodes<'tcx> {
15921592
15931593#[derive(Subdiagnostic)]
15941594#[label(passes_parent_info)]
1595pub struct ParentInfo<'tcx> {
1595pub(crate) struct ParentInfo<'tcx> {
15961596 pub num: usize,
15971597 pub descr: &'tcx str,
15981598 pub parent_descr: &'tcx str,
......@@ -1602,14 +1602,14 @@ pub struct ParentInfo<'tcx> {
16021602
16031603#[derive(Subdiagnostic)]
16041604#[note(passes_ignored_derived_impls)]
1605pub struct IgnoredDerivedImpls {
1605pub(crate) struct IgnoredDerivedImpls {
16061606 pub name: Symbol,
16071607 pub trait_list: DiagSymbolList,
16081608 pub trait_list_len: usize,
16091609}
16101610
16111611#[derive(Subdiagnostic)]
1612pub enum ChangeFields {
1612pub(crate) enum ChangeFields {
16131613 #[multipart_suggestion(
16141614 passes_change_fields_to_be_of_unit_type,
16151615 applicability = "has-placeholders"
......@@ -1633,14 +1633,14 @@ pub(crate) struct ProcMacroBadSig {
16331633
16341634#[derive(Diagnostic)]
16351635#[diag(passes_skipping_const_checks)]
1636pub struct SkippingConstChecks {
1636pub(crate) struct SkippingConstChecks {
16371637 #[primary_span]
16381638 pub span: Span,
16391639}
16401640
16411641#[derive(LintDiagnostic)]
16421642#[diag(passes_unreachable_due_to_uninhabited)]
1643pub struct UnreachableDueToUninhabited<'desc, 'tcx> {
1643pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
16441644 pub descr: &'desc str,
16451645 #[label]
16461646 pub expr: Span,
......@@ -1653,20 +1653,20 @@ pub struct UnreachableDueToUninhabited<'desc, 'tcx> {
16531653#[derive(LintDiagnostic)]
16541654#[diag(passes_unused_var_maybe_capture_ref)]
16551655#[help]
1656pub struct UnusedVarMaybeCaptureRef {
1656pub(crate) struct UnusedVarMaybeCaptureRef {
16571657 pub name: String,
16581658}
16591659
16601660#[derive(LintDiagnostic)]
16611661#[diag(passes_unused_capture_maybe_capture_ref)]
16621662#[help]
1663pub struct UnusedCaptureMaybeCaptureRef {
1663pub(crate) struct UnusedCaptureMaybeCaptureRef {
16641664 pub name: String,
16651665}
16661666
16671667#[derive(LintDiagnostic)]
16681668#[diag(passes_unused_var_remove_field)]
1669pub struct UnusedVarRemoveField {
1669pub(crate) struct UnusedVarRemoveField {
16701670 pub name: String,
16711671 #[subdiagnostic]
16721672 pub sugg: UnusedVarRemoveFieldSugg,
......@@ -1677,7 +1677,7 @@ pub struct UnusedVarRemoveField {
16771677 passes_unused_var_remove_field_suggestion,
16781678 applicability = "machine-applicable"
16791679)]
1680pub struct UnusedVarRemoveFieldSugg {
1680pub(crate) struct UnusedVarRemoveFieldSugg {
16811681 #[suggestion_part(code = "")]
16821682 pub spans: Vec<Span>,
16831683}
......@@ -1685,20 +1685,20 @@ pub struct UnusedVarRemoveFieldSugg {
16851685#[derive(LintDiagnostic)]
16861686#[diag(passes_unused_var_assigned_only)]
16871687#[note]
1688pub struct UnusedVarAssignedOnly {
1688pub(crate) struct UnusedVarAssignedOnly {
16891689 pub name: String,
16901690}
16911691
16921692#[derive(LintDiagnostic)]
16931693#[diag(passes_unnecessary_stable_feature)]
1694pub struct UnnecessaryStableFeature {
1694pub(crate) struct UnnecessaryStableFeature {
16951695 pub feature: Symbol,
16961696 pub since: Symbol,
16971697}
16981698
16991699#[derive(LintDiagnostic)]
17001700#[diag(passes_unnecessary_partial_stable_feature)]
1701pub struct UnnecessaryPartialStableFeature {
1701pub(crate) struct UnnecessaryPartialStableFeature {
17021702 #[suggestion(code = "{implies}", applicability = "maybe-incorrect")]
17031703 pub span: Span,
17041704 #[suggestion(passes_suggestion_remove, code = "", applicability = "maybe-incorrect")]
......@@ -1711,25 +1711,25 @@ pub struct UnnecessaryPartialStableFeature {
17111711#[derive(LintDiagnostic)]
17121712#[diag(passes_ineffective_unstable_impl)]
17131713#[note]
1714pub struct IneffectiveUnstableImpl;
1714pub(crate) struct IneffectiveUnstableImpl;
17151715
17161716#[derive(LintDiagnostic)]
17171717#[diag(passes_unused_assign)]
17181718#[help]
1719pub struct UnusedAssign {
1719pub(crate) struct UnusedAssign {
17201720 pub name: String,
17211721}
17221722
17231723#[derive(LintDiagnostic)]
17241724#[diag(passes_unused_assign_passed)]
17251725#[help]
1726pub struct UnusedAssignPassed {
1726pub(crate) struct UnusedAssignPassed {
17271727 pub name: String,
17281728}
17291729
17301730#[derive(LintDiagnostic)]
17311731#[diag(passes_unused_variable_try_prefix)]
1732pub struct UnusedVariableTryPrefix {
1732pub(crate) struct UnusedVariableTryPrefix {
17331733 #[label]
17341734 pub label: Option<Span>,
17351735 #[subdiagnostic]
......@@ -1740,7 +1740,7 @@ pub struct UnusedVariableTryPrefix {
17401740}
17411741
17421742#[derive(Subdiagnostic)]
1743pub enum UnusedVariableSugg {
1743pub(crate) enum UnusedVariableSugg {
17441744 #[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
17451745 TryPrefixSugg {
17461746 #[suggestion_part(code = "_{name}")]
......@@ -1755,7 +1755,7 @@ pub enum UnusedVariableSugg {
17551755 },
17561756}
17571757
1758pub struct UnusedVariableStringInterp {
1758pub(crate) struct UnusedVariableStringInterp {
17591759 pub lit: Span,
17601760 pub lo: Span,
17611761 pub hi: Span,
......@@ -1778,14 +1778,14 @@ impl Subdiagnostic for UnusedVariableStringInterp {
17781778
17791779#[derive(LintDiagnostic)]
17801780#[diag(passes_unused_variable_try_ignore)]
1781pub struct UnusedVarTryIgnore {
1781pub(crate) struct UnusedVarTryIgnore {
17821782 #[subdiagnostic]
17831783 pub sugg: UnusedVarTryIgnoreSugg,
17841784}
17851785
17861786#[derive(Subdiagnostic)]
17871787#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
1788pub struct UnusedVarTryIgnoreSugg {
1788pub(crate) struct UnusedVarTryIgnoreSugg {
17891789 #[suggestion_part(code = "{name}: _")]
17901790 pub shorthands: Vec<Span>,
17911791 #[suggestion_part(code = "_")]
......@@ -1796,14 +1796,14 @@ pub struct UnusedVarTryIgnoreSugg {
17961796#[derive(LintDiagnostic)]
17971797#[diag(passes_attr_crate_level)]
17981798#[note]
1799pub struct AttrCrateLevelOnly {
1799pub(crate) struct AttrCrateLevelOnly {
18001800 #[subdiagnostic]
18011801 pub sugg: Option<AttrCrateLevelOnlySugg>,
18021802}
18031803
18041804#[derive(Subdiagnostic)]
18051805#[suggestion(passes_suggestion, applicability = "maybe-incorrect", code = "!", style = "verbose")]
1806pub struct AttrCrateLevelOnlySugg {
1806pub(crate) struct AttrCrateLevelOnlySugg {
18071807 #[primary_span]
18081808 pub attr: Span,
18091809}
compiler/rustc_passes/src/lang_items.rs+1-1
......@@ -359,6 +359,6 @@ impl<'ast, 'tcx> visit::Visitor<'ast> for LanguageItemCollector<'ast, 'tcx> {
359359 }
360360}
361361
362pub fn provide(providers: &mut Providers) {
362pub(crate) fn provide(providers: &mut Providers) {
363363 providers.get_lang_items = get_lang_items;
364364}
compiler/rustc_passes/src/lib.rs+1
......@@ -12,6 +12,7 @@
1212#![feature(map_try_insert)]
1313#![feature(rustdoc_internals)]
1414#![feature(try_blocks)]
15#![warn(unreachable_pub)]
1516// tidy-alphabetical-end
1617
1718use rustc_middle::query::Providers;
compiler/rustc_passes/src/lib_features.rs+2-2
......@@ -16,7 +16,7 @@ use rustc_span::{sym, Span};
1616
1717use crate::errors::{FeaturePreviouslyDeclared, FeatureStableTwice};
1818
19pub struct LibFeatureCollector<'tcx> {
19struct LibFeatureCollector<'tcx> {
2020 tcx: TyCtxt<'tcx>,
2121 lib_features: LibFeatures,
2222}
......@@ -153,6 +153,6 @@ fn lib_features(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> LibFeatures {
153153 collector.lib_features
154154}
155155
156pub fn provide(providers: &mut Providers) {
156pub(crate) fn provide(providers: &mut Providers) {
157157 providers.lib_features = lib_features;
158158}
compiler/rustc_passes/src/liveness.rs+1-1
......@@ -178,7 +178,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
178178 lsets.warn_about_unused_args(&body, entry_ln);
179179}
180180
181pub fn provide(providers: &mut Providers) {
181pub(crate) fn provide(providers: &mut Providers) {
182182 *providers = Providers { check_liveness, ..*providers };
183183}
184184
compiler/rustc_passes/src/reachable.rs+1-1
......@@ -500,6 +500,6 @@ fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> LocalDefIdSet {
500500 reachable_context.reachable_symbols
501501}
502502
503pub fn provide(providers: &mut Providers) {
503pub(crate) fn provide(providers: &mut Providers) {
504504 *providers = Providers { reachable_set, ..*providers };
505505}
compiler/rustc_passes/src/upvars.rs+1-1
......@@ -9,7 +9,7 @@ use rustc_middle::query::Providers;
99use rustc_middle::ty::TyCtxt;
1010use rustc_span::Span;
1111
12pub fn provide(providers: &mut Providers) {
12pub(crate) fn provide(providers: &mut Providers) {
1313 providers.upvars_mentioned = |tcx, def_id| {
1414 if !tcx.is_closure_like(def_id) {
1515 return None;
compiler/rustc_passes/src/weak_lang_items.rs+5-1
......@@ -15,7 +15,11 @@ use crate::errors::{
1515
1616/// Checks the crate for usage of weak lang items, returning a vector of all the
1717/// lang items required by this crate, but not defined yet.
18pub fn check_crate(tcx: TyCtxt<'_>, items: &mut lang_items::LanguageItems, krate: &ast::Crate) {
18pub(crate) fn check_crate(
19 tcx: TyCtxt<'_>,
20 items: &mut lang_items::LanguageItems,
21 krate: &ast::Crate,
22) {
1923 // These are never called by user code, they're generated by the compiler.
2024 // They will never implicitly be added to the `missing` array unless we do
2125 // so here.
compiler/rustc_pattern_analysis/src/lib.rs+1
......@@ -6,6 +6,7 @@
66#![allow(rustc::diagnostic_outside_of_impl)]
77#![allow(rustc::untranslatable_diagnostic)]
88#![cfg_attr(feature = "rustc", feature(let_chains))]
9#![warn(unreachable_pub)]
910// tidy-alphabetical-end
1011
1112pub mod constructor;
compiler/rustc_privacy/src/errors.rs+9-9
......@@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};
55
66#[derive(Diagnostic)]
77#[diag(privacy_field_is_private, code = E0451)]
8pub struct FieldIsPrivate {
8pub(crate) struct FieldIsPrivate {
99 #[primary_span]
1010 pub span: Span,
1111 pub field_name: Symbol,
......@@ -16,7 +16,7 @@ pub struct FieldIsPrivate {
1616}
1717
1818#[derive(Subdiagnostic)]
19pub enum FieldIsPrivateLabel {
19pub(crate) enum FieldIsPrivateLabel {
2020 #[label(privacy_field_is_private_is_update_syntax_label)]
2121 IsUpdateSyntax {
2222 #[primary_span]
......@@ -32,7 +32,7 @@ pub enum FieldIsPrivateLabel {
3232
3333#[derive(Diagnostic)]
3434#[diag(privacy_item_is_private)]
35pub struct ItemIsPrivate<'a> {
35pub(crate) struct ItemIsPrivate<'a> {
3636 #[primary_span]
3737 #[label]
3838 pub span: Span,
......@@ -42,7 +42,7 @@ pub struct ItemIsPrivate<'a> {
4242
4343#[derive(Diagnostic)]
4444#[diag(privacy_unnamed_item_is_private)]
45pub struct UnnamedItemIsPrivate {
45pub(crate) struct UnnamedItemIsPrivate {
4646 #[primary_span]
4747 pub span: Span,
4848 pub kind: &'static str,
......@@ -50,7 +50,7 @@ pub struct UnnamedItemIsPrivate {
5050
5151#[derive(Diagnostic)]
5252#[diag(privacy_in_public_interface, code = E0446)]
53pub struct InPublicInterface<'a> {
53pub(crate) struct InPublicInterface<'a> {
5454 #[primary_span]
5555 #[label]
5656 pub span: Span,
......@@ -63,7 +63,7 @@ pub struct InPublicInterface<'a> {
6363
6464#[derive(Diagnostic)]
6565#[diag(privacy_report_effective_visibility)]
66pub struct ReportEffectiveVisibility {
66pub(crate) struct ReportEffectiveVisibility {
6767 #[primary_span]
6868 pub span: Span,
6969 pub descr: String,
......@@ -71,7 +71,7 @@ pub struct ReportEffectiveVisibility {
7171
7272#[derive(LintDiagnostic)]
7373#[diag(privacy_from_private_dep_in_public_interface)]
74pub struct FromPrivateDependencyInPublicInterface<'a> {
74pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
7575 pub kind: &'a str,
7676 pub descr: DiagArgFromDisplay<'a>,
7777 pub krate: Symbol,
......@@ -79,7 +79,7 @@ pub struct FromPrivateDependencyInPublicInterface<'a> {
7979
8080#[derive(LintDiagnostic)]
8181#[diag(privacy_unnameable_types_lint)]
82pub struct UnnameableTypesLint<'a> {
82pub(crate) struct UnnameableTypesLint<'a> {
8383 #[label]
8484 pub span: Span,
8585 pub kind: &'a str,
......@@ -93,7 +93,7 @@ pub struct UnnameableTypesLint<'a> {
9393// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
9494#[derive(LintDiagnostic)]
9595#[diag(privacy_private_interface_or_bounds_lint)]
96pub struct PrivateInterfacesOrBoundsLint<'a> {
96pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
9797 #[label(privacy_item_label)]
9898 pub item_span: Span,
9999 pub item_kind: &'a str,
compiler/rustc_privacy/src/lib.rs+2-1
......@@ -6,6 +6,7 @@
66#![feature(let_chains)]
77#![feature(rustdoc_internals)]
88#![feature(try_blocks)]
9#![warn(unreachable_pub)]
910// tidy-alphabetical-end
1011
1112mod errors;
......@@ -1497,7 +1498,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
14971498 self.effective_visibilities.effective_vis(def_id).copied()
14981499 }
14991500
1500 pub fn check_item(&mut self, id: ItemId) {
1501 fn check_item(&mut self, id: ItemId) {
15011502 let tcx = self.tcx;
15021503 let def_id = id.owner_id.def_id;
15031504 let item_visibility = tcx.local_visibility(def_id);
compiler/rustc_query_impl/src/lib.rs+1
......@@ -8,6 +8,7 @@
88#![feature(min_specialization)]
99#![feature(rustc_attrs)]
1010#![feature(rustdoc_internals)]
11#![warn(unreachable_pub)]
1112// tidy-alphabetical-end
1213
1314use field_offset::offset_of;
compiler/rustc_query_impl/src/plumbing.rs+26-18
......@@ -541,7 +541,7 @@ macro_rules! expand_if_cached {
541541/// Don't show the backtrace for query system by default
542542/// use `RUST_BACKTRACE=full` to show all the backtraces
543543#[inline(never)]
544pub fn __rust_begin_short_backtrace<F, T>(f: F) -> T
544pub(crate) fn __rust_begin_short_backtrace<F, T>(f: F) -> T
545545where
546546 F: FnOnce() -> T,
547547{
......@@ -557,17 +557,17 @@ macro_rules! define_queries {
557557 $($(#[$attr:meta])*
558558 [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
559559
560 pub(crate) mod query_impl { $(pub mod $name {
560 pub(crate) mod query_impl { $(pub(crate) mod $name {
561561 use super::super::*;
562562 use std::marker::PhantomData;
563563
564 pub mod get_query_incr {
564 pub(crate) mod get_query_incr {
565565 use super::*;
566566
567567 // Adding `__rust_end_short_backtrace` marker to backtraces so that we emit the frames
568568 // when `RUST_BACKTRACE=1`, add a new mod with `$name` here is to allow duplicate naming
569569 #[inline(never)]
570 pub fn __rust_end_short_backtrace<'tcx>(
570 pub(crate) fn __rust_end_short_backtrace<'tcx>(
571571 tcx: TyCtxt<'tcx>,
572572 span: Span,
573573 key: queries::$name::Key<'tcx>,
......@@ -585,11 +585,11 @@ macro_rules! define_queries {
585585 }
586586 }
587587
588 pub mod get_query_non_incr {
588 pub(crate) mod get_query_non_incr {
589589 use super::*;
590590
591591 #[inline(never)]
592 pub fn __rust_end_short_backtrace<'tcx>(
592 pub(crate) fn __rust_end_short_backtrace<'tcx>(
593593 tcx: TyCtxt<'tcx>,
594594 span: Span,
595595 key: queries::$name::Key<'tcx>,
......@@ -604,7 +604,9 @@ macro_rules! define_queries {
604604 }
605605 }
606606
607 pub fn dynamic_query<'tcx>() -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>> {
607 pub(crate) fn dynamic_query<'tcx>()
608 -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>>
609 {
608610 DynamicQuery {
609611 name: stringify!($name),
610612 eval_always: is_eval_always!([$($modifiers)*]),
......@@ -667,7 +669,7 @@ macro_rules! define_queries {
667669 }
668670
669671 #[derive(Copy, Clone, Default)]
670 pub struct QueryType<'tcx> {
672 pub(crate) struct QueryType<'tcx> {
671673 data: PhantomData<&'tcx ()>
672674 }
673675
......@@ -696,7 +698,7 @@ macro_rules! define_queries {
696698 }
697699 }
698700
699 pub fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap) {
701 pub(crate) fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap) {
700702 let make_query = |tcx, key| {
701703 let kind = rustc_middle::dep_graph::dep_kinds::$name;
702704 let name = stringify!($name);
......@@ -711,11 +713,17 @@ macro_rules! define_queries {
711713 // don't `unwrap()` here, just manually check for `None` and do best-effort error
712714 // reporting.
713715 if res.is_none() {
714 tracing::warn!("Failed to collect active jobs for query with name `{}`!", stringify!($name));
716 tracing::warn!(
717 "Failed to collect active jobs for query with name `{}`!",
718 stringify!($name)
719 );
715720 }
716721 }
717722
718 pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>, string_cache: &mut QueryKeyStringCache) {
723 pub(crate) fn alloc_self_profile_query_strings<'tcx>(
724 tcx: TyCtxt<'tcx>,
725 string_cache: &mut QueryKeyStringCache
726 ) {
719727 $crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
720728 tcx,
721729 stringify!($name),
......@@ -725,7 +733,7 @@ macro_rules! define_queries {
725733 }
726734
727735 item_if_cached! { [$($modifiers)*] {
728 pub fn encode_query_results<'tcx>(
736 pub(crate) fn encode_query_results<'tcx>(
729737 tcx: TyCtxt<'tcx>,
730738 encoder: &mut CacheEncoder<'_, 'tcx>,
731739 query_result_index: &mut EncodedDepNodeIndex
......@@ -739,7 +747,7 @@ macro_rules! define_queries {
739747 }
740748 }}
741749
742 pub fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
750 pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
743751 $crate::plumbing::query_key_hash_verify(
744752 query_impl::$name::QueryType::config(tcx),
745753 QueryCtxt::new(tcx),
......@@ -795,7 +803,7 @@ macro_rules! define_queries {
795803 use rustc_query_system::dep_graph::FingerprintStyle;
796804
797805 // We use this for most things when incr. comp. is turned off.
798 pub fn Null<'tcx>() -> DepKindStruct<'tcx> {
806 pub(crate) fn Null<'tcx>() -> DepKindStruct<'tcx> {
799807 DepKindStruct {
800808 is_anon: false,
801809 is_eval_always: false,
......@@ -807,7 +815,7 @@ macro_rules! define_queries {
807815 }
808816
809817 // We use this for the forever-red node.
810 pub fn Red<'tcx>() -> DepKindStruct<'tcx> {
818 pub(crate) fn Red<'tcx>() -> DepKindStruct<'tcx> {
811819 DepKindStruct {
812820 is_anon: false,
813821 is_eval_always: false,
......@@ -818,7 +826,7 @@ macro_rules! define_queries {
818826 }
819827 }
820828
821 pub fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
829 pub(crate) fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
822830 DepKindStruct {
823831 is_anon: true,
824832 is_eval_always: false,
......@@ -829,7 +837,7 @@ macro_rules! define_queries {
829837 }
830838 }
831839
832 pub fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
840 pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
833841 DepKindStruct {
834842 is_anon: false,
835843 is_eval_always: false,
......@@ -840,7 +848,7 @@ macro_rules! define_queries {
840848 }
841849 }
842850
843 pub fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
851 pub(crate) fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
844852 DepKindStruct {
845853 is_anon: false,
846854 is_eval_always: false,
compiler/rustc_query_system/src/dep_graph/serialized.rs+3-3
......@@ -617,14 +617,14 @@ impl<D: Deps> EncoderState<D> {
617617 }
618618}
619619
620pub struct GraphEncoder<D: Deps> {
620pub(crate) struct GraphEncoder<D: Deps> {
621621 profiler: SelfProfilerRef,
622622 status: Lock<Option<EncoderState<D>>>,
623623 record_graph: Option<Lock<DepGraphQuery>>,
624624}
625625
626626impl<D: Deps> GraphEncoder<D> {
627 pub fn new(
627 pub(crate) fn new(
628628 encoder: FileEncoder,
629629 prev_node_count: usize,
630630 record_graph: bool,
......@@ -723,7 +723,7 @@ impl<D: Deps> GraphEncoder<D> {
723723 )
724724 }
725725
726 pub fn finish(&self) -> FileEncodeResult {
726 pub(crate) fn finish(&self) -> FileEncodeResult {
727727 let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph_finish");
728728
729729 self.status.lock().take().unwrap().finish(&self.profiler)
compiler/rustc_query_system/src/error.rs+7-7
......@@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};
55
66#[derive(Subdiagnostic)]
77#[note(query_system_cycle_stack_middle)]
8pub struct CycleStack {
8pub(crate) struct CycleStack {
99 #[primary_span]
1010 pub span: Span,
1111 pub desc: String,
......@@ -20,7 +20,7 @@ pub enum HandleCycleError {
2020}
2121
2222#[derive(Subdiagnostic)]
23pub enum StackCount {
23pub(crate) enum StackCount {
2424 #[note(query_system_cycle_stack_single)]
2525 Single,
2626 #[note(query_system_cycle_stack_multiple)]
......@@ -28,7 +28,7 @@ pub enum StackCount {
2828}
2929
3030#[derive(Subdiagnostic)]
31pub enum Alias {
31pub(crate) enum Alias {
3232 #[note(query_system_cycle_recursive_ty_alias)]
3333 #[help(query_system_cycle_recursive_ty_alias_help1)]
3434 #[help(query_system_cycle_recursive_ty_alias_help2)]
......@@ -39,7 +39,7 @@ pub enum Alias {
3939
4040#[derive(Subdiagnostic)]
4141#[note(query_system_cycle_usage)]
42pub struct CycleUsage {
42pub(crate) struct CycleUsage {
4343 #[primary_span]
4444 pub span: Span,
4545 pub usage: String,
......@@ -47,7 +47,7 @@ pub struct CycleUsage {
4747
4848#[derive(Diagnostic)]
4949#[diag(query_system_cycle, code = E0391)]
50pub struct Cycle {
50pub(crate) struct Cycle {
5151 #[primary_span]
5252 pub span: Span,
5353 pub stack_bottom: String,
......@@ -65,14 +65,14 @@ pub struct Cycle {
6565
6666#[derive(Diagnostic)]
6767#[diag(query_system_reentrant)]
68pub struct Reentrant;
68pub(crate) struct Reentrant;
6969
7070#[derive(Diagnostic)]
7171#[diag(query_system_increment_compilation)]
7272#[help]
7373#[note(query_system_increment_compilation_note1)]
7474#[note(query_system_increment_compilation_note2)]
75pub struct IncrementCompilation {
75pub(crate) struct IncrementCompilation {
7676 pub run_cmd: String,
7777 pub dep_node: String,
7878}
compiler/rustc_query_system/src/lib.rs+1
......@@ -5,6 +5,7 @@
55#![feature(hash_raw_entry)]
66#![feature(let_chains)]
77#![feature(min_specialization)]
8#![warn(unreachable_pub)]
89// tidy-alphabetical-end
910
1011pub mod cache;
compiler/rustc_resolve/src/lib.rs+1
......@@ -21,6 +21,7 @@
2121#![feature(let_chains)]
2222#![feature(rustc_attrs)]
2323#![feature(rustdoc_internals)]
24#![warn(unreachable_pub)]
2425// tidy-alphabetical-end
2526
2627use std::cell::{Cell, RefCell};
compiler/rustc_session/src/config.rs+22-2
......@@ -22,7 +22,9 @@ use rustc_feature::UnstableFeatures;
2222use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2323use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
2424use rustc_span::source_map::FilePathMapping;
25use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
25use rustc_span::{
26 sym, FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol,
27};
2628use 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)]
409pub 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
418impl FmtDebug {
419 pub(crate) fn all() -> [Symbol; 3] {
420 [sym::full, sym::none, sym::shallow]
421 }
422}
423
405424#[derive(Clone, PartialEq, Hash, Debug)]
406425pub 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+18-1
......@@ -31,7 +31,7 @@ use rustc_span::symbol::{sym, Symbol};
3131use rustc_target::abi::Align;
3232use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target, TargetTriple, TARGETS};
3333
34use crate::config::CrateType;
34use crate::config::{CrateType, FmtDebug};
3535use 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+16
......@@ -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],
......@@ -1797,6 +1811,8 @@ options! {
17971811 "link the `.rlink` file generated by `-Z no-link` (default: no)"),
17981812 linker_features: LinkerFeaturesCli = (LinkerFeaturesCli::default(), parse_linker_features, [UNTRACKED],
17991813 "a comma-separated list of linker features to enable (+) or disable (-): `lld`"),
1814 lint_llvm_ir: bool = (false, parse_bool, [TRACKED],
1815 "lint LLVM IR (default: no)"),
18001816 lint_mir: bool = (false, parse_bool, [UNTRACKED],
18011817 "lint MIR before and after each transformation"),
18021818 llvm_module_flag: Vec<(String, u32, String)> = (Vec::new(), parse_llvm_module_flag, [TRACKED],
compiler/rustc_span/src/symbol.rs+5
......@@ -536,6 +536,7 @@ symbols! {
536536 cfg_attr_multi,
537537 cfg_doctest,
538538 cfg_eval,
539 cfg_fmt_debug,
539540 cfg_hide,
540541 cfg_overflow_checks,
541542 cfg_panic,
......@@ -895,6 +896,7 @@ symbols! {
895896 fmaf32,
896897 fmaf64,
897898 fmt,
899 fmt_debug,
898900 fmul_algebraic,
899901 fmul_fast,
900902 fn_align,
......@@ -938,6 +940,7 @@ symbols! {
938940 fs_create_dir,
939941 fsub_algebraic,
940942 fsub_fast,
943 full,
941944 fundamental,
942945 fused_iterator,
943946 future,
......@@ -1281,6 +1284,7 @@ symbols! {
12811284 new_binary,
12821285 new_const,
12831286 new_debug,
1287 new_debug_noop,
12841288 new_display,
12851289 new_lower_exp,
12861290 new_lower_hex,
......@@ -1715,6 +1719,7 @@ symbols! {
17151719 semitransparent,
17161720 sha512_sm_x86,
17171721 shadow_call_stack,
1722 shallow,
17181723 shl,
17191724 shl_assign,
17201725 shorter_tail_lifetimes,
compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs+1-1
......@@ -28,7 +28,7 @@ pub fn target() -> Target {
2828 code_model: Some(CodeModel::Medium),
2929 emit_debug_gdb_scripts: false,
3030 eh_frame_header: false,
31 supported_sanitizers: SanitizerSet::KERNELADDRESS,
31 supported_sanitizers: SanitizerSet::KERNELADDRESS | SanitizerSet::SHADOWCALLSTACK,
3232 ..Default::default()
3333 },
3434 }
compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs+1-1
......@@ -27,7 +27,7 @@ pub fn target() -> Target {
2727 code_model: Some(CodeModel::Medium),
2828 emit_debug_gdb_scripts: false,
2929 eh_frame_header: false,
30 supported_sanitizers: SanitizerSet::KERNELADDRESS,
30 supported_sanitizers: SanitizerSet::KERNELADDRESS | SanitizerSet::SHADOWCALLSTACK,
3131 ..Default::default()
3232 },
3333 }
library/core/benches/lib.rs+1
......@@ -8,6 +8,7 @@
88#![feature(iter_array_chunks)]
99#![feature(iter_next_chunk)]
1010#![feature(iter_advance_by)]
11#![feature(isqrt)]
1112
1213extern crate test;
1314
library/core/benches/num/int_sqrt/mod.rs created+62
......@@ -0,0 +1,62 @@
1use rand::Rng;
2use test::{black_box, Bencher};
3
4macro_rules! int_sqrt_bench {
5 ($t:ty, $predictable:ident, $random:ident, $random_small:ident, $random_uniform:ident) => {
6 #[bench]
7 fn $predictable(bench: &mut Bencher) {
8 bench.iter(|| {
9 for n in 0..(<$t>::BITS / 8) {
10 for i in 1..=(100 as $t) {
11 let x = black_box(i << (n * 8));
12 black_box(x.isqrt());
13 }
14 }
15 });
16 }
17
18 #[bench]
19 fn $random(bench: &mut Bencher) {
20 let mut rng = crate::bench_rng();
21 /* Exponentially distributed random numbers from the whole range of the type. */
22 let numbers: Vec<$t> =
23 (0..256).map(|_| rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS)).collect();
24 bench.iter(|| {
25 for x in &numbers {
26 black_box(black_box(x).isqrt());
27 }
28 });
29 }
30
31 #[bench]
32 fn $random_small(bench: &mut Bencher) {
33 let mut rng = crate::bench_rng();
34 /* Exponentially distributed random numbers from the range 0..256. */
35 let numbers: Vec<$t> =
36 (0..256).map(|_| (rng.gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t).collect();
37 bench.iter(|| {
38 for x in &numbers {
39 black_box(black_box(x).isqrt());
40 }
41 });
42 }
43
44 #[bench]
45 fn $random_uniform(bench: &mut Bencher) {
46 let mut rng = crate::bench_rng();
47 /* Exponentially distributed random numbers from the whole range of the type. */
48 let numbers: Vec<$t> = (0..256).map(|_| rng.gen::<$t>()).collect();
49 bench.iter(|| {
50 for x in &numbers {
51 black_box(black_box(x).isqrt());
52 }
53 });
54 }
55 };
56}
57
58int_sqrt_bench! {u8, u8_sqrt_predictable, u8_sqrt_random, u8_sqrt_random_small, u8_sqrt_uniform}
59int_sqrt_bench! {u16, u16_sqrt_predictable, u16_sqrt_random, u16_sqrt_random_small, u16_sqrt_uniform}
60int_sqrt_bench! {u32, u32_sqrt_predictable, u32_sqrt_random, u32_sqrt_random_small, u32_sqrt_uniform}
61int_sqrt_bench! {u64, u64_sqrt_predictable, u64_sqrt_random, u64_sqrt_random_small, u64_sqrt_uniform}
62int_sqrt_bench! {u128, u128_sqrt_predictable, u128_sqrt_random, u128_sqrt_random_small, u128_sqrt_uniform}
library/core/benches/num/mod.rs+1
......@@ -2,6 +2,7 @@ mod dec2flt;
22mod flt2dec;
33mod int_log;
44mod int_pow;
5mod int_sqrt;
56
67use std::str::FromStr;
78
library/core/src/fmt/rt.rs+4
......@@ -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 }
library/core/src/num/int_macros.rs+29-7
......@@ -1641,7 +1641,33 @@ macro_rules! int_impl {
16411641 if self < 0 {
16421642 None
16431643 } else {
1644 Some((self as $UnsignedT).isqrt() as Self)
1644 // SAFETY: Input is nonnegative in this `else` branch.
1645 let result = unsafe {
1646 crate::num::int_sqrt::$ActualT(self as $ActualT) as $SelfT
1647 };
1648
1649 // Inform the optimizer what the range of outputs is. If
1650 // testing `core` crashes with no panic message and a
1651 // `num::int_sqrt::i*` test failed, it's because your edits
1652 // caused these assertions to become false.
1653 //
1654 // SAFETY: Integer square root is a monotonically nondecreasing
1655 // function, which means that increasing the input will never
1656 // cause the output to decrease. Thus, since the input for
1657 // nonnegative signed integers is bounded by
1658 // `[0, <$ActualT>::MAX]`, sqrt(n) will be bounded by
1659 // `[sqrt(0), sqrt(<$ActualT>::MAX)]`.
1660 unsafe {
1661 // SAFETY: `<$ActualT>::MAX` is nonnegative.
1662 const MAX_RESULT: $SelfT = unsafe {
1663 crate::num::int_sqrt::$ActualT(<$ActualT>::MAX) as $SelfT
1664 };
1665
1666 crate::hint::assert_unchecked(result >= 0);
1667 crate::hint::assert_unchecked(result <= MAX_RESULT);
1668 }
1669
1670 Some(result)
16451671 }
16461672 }
16471673
......@@ -2862,15 +2888,11 @@ macro_rules! int_impl {
28622888 #[must_use = "this returns the result of the operation, \
28632889 without modifying the original"]
28642890 #[inline]
2891 #[track_caller]
28652892 pub const fn isqrt(self) -> Self {
2866 // I would like to implement it as
2867 // ```
2868 // self.checked_isqrt().expect("argument of integer square root must be non-negative")
2869 // ```
2870 // but `expect` is not yet stable as a `const fn`.
28712893 match self.checked_isqrt() {
28722894 Some(sqrt) => sqrt,
2873 None => panic!("argument of integer square root must be non-negative"),
2895 None => crate::num::int_sqrt::panic_for_negative_argument(),
28742896 }
28752897 }
28762898
library/core/src/num/int_sqrt.rs created+316
......@@ -0,0 +1,316 @@
1//! These functions use the [Karatsuba square root algorithm][1] to compute the
2//! [integer square root](https://en.wikipedia.org/wiki/Integer_square_root)
3//! for the primitive integer types.
4//!
5//! The signed integer functions can only handle **nonnegative** inputs, so
6//! that must be checked before calling those.
7//!
8//! [1]: <https://web.archive.org/web/20230511212802/https://inria.hal.science/inria-00072854v1/file/RR-3805.pdf>
9//! "Paul Zimmermann. Karatsuba Square Root. \[Research Report\] RR-3805,
10//! INRIA. 1999, pp.8. (inria-00072854)"
11
12/// This array stores the [integer square roots](
13/// https://en.wikipedia.org/wiki/Integer_square_root) and remainders of each
14/// [`u8`](prim@u8) value. For example, `U8_ISQRT_WITH_REMAINDER[17]` will be
15/// `(4, 1)` because the integer square root of 17 is 4 and because 17 is 1
16/// higher than 4 squared.
17const U8_ISQRT_WITH_REMAINDER: [(u8, u8); 256] = {
18 let mut result = [(0, 0); 256];
19
20 let mut n: usize = 0;
21 let mut isqrt_n: usize = 0;
22 while n < result.len() {
23 result[n] = (isqrt_n as u8, (n - isqrt_n.pow(2)) as u8);
24
25 n += 1;
26 if n == (isqrt_n + 1).pow(2) {
27 isqrt_n += 1;
28 }
29 }
30
31 result
32};
33
34/// Returns the [integer square root](
35/// https://en.wikipedia.org/wiki/Integer_square_root) of any [`u8`](prim@u8)
36/// input.
37#[must_use = "this returns the result of the operation, \
38 without modifying the original"]
39#[inline]
40pub const fn u8(n: u8) -> u8 {
41 U8_ISQRT_WITH_REMAINDER[n as usize].0
42}
43
44/// Generates an `i*` function that returns the [integer square root](
45/// https://en.wikipedia.org/wiki/Integer_square_root) of any **nonnegative**
46/// input of a specific signed integer type.
47macro_rules! signed_fn {
48 ($SignedT:ident, $UnsignedT:ident) => {
49 /// Returns the [integer square root](
50 /// https://en.wikipedia.org/wiki/Integer_square_root) of any
51 /// **nonnegative**
52 #[doc = concat!("[`", stringify!($SignedT), "`](prim@", stringify!($SignedT), ")")]
53 /// input.
54 ///
55 /// # Safety
56 ///
57 /// This results in undefined behavior when the input is negative.
58 #[must_use = "this returns the result of the operation, \
59 without modifying the original"]
60 #[inline]
61 pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT {
62 debug_assert!(n >= 0, "Negative input inside `isqrt`.");
63 $UnsignedT(n as $UnsignedT) as $SignedT
64 }
65 };
66}
67
68signed_fn!(i8, u8);
69signed_fn!(i16, u16);
70signed_fn!(i32, u32);
71signed_fn!(i64, u64);
72signed_fn!(i128, u128);
73
74/// Generates a `u*` function that returns the [integer square root](
75/// https://en.wikipedia.org/wiki/Integer_square_root) of any input of
76/// a specific unsigned integer type.
77macro_rules! unsigned_fn {
78 ($UnsignedT:ident, $HalfBitsT:ident, $stages:ident) => {
79 /// Returns the [integer square root](
80 /// https://en.wikipedia.org/wiki/Integer_square_root) of any
81 #[doc = concat!("[`", stringify!($UnsignedT), "`](prim@", stringify!($UnsignedT), ")")]
82 /// input.
83 #[must_use = "this returns the result of the operation, \
84 without modifying the original"]
85 #[inline]
86 pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT {
87 if n <= <$HalfBitsT>::MAX as $UnsignedT {
88 $HalfBitsT(n as $HalfBitsT) as $UnsignedT
89 } else {
90 // The normalization shift satisfies the Karatsuba square root
91 // algorithm precondition "a₃ ≥ b/4" where a₃ is the most
92 // significant quarter of `n`'s bits and b is the number of
93 // values that can be represented by that quarter of the bits.
94 //
95 // b/4 would then be all 0s except the second most significant
96 // bit (010...0) in binary. Since a₃ must be at least b/4, a₃'s
97 // most significant bit or its neighbor must be a 1. Since a₃'s
98 // most significant bits are `n`'s most significant bits, the
99 // same applies to `n`.
100 //
101 // The reason to shift by an even number of bits is because an
102 // even number of bits produces the square root shifted to the
103 // left by half of the normalization shift:
104 //
105 // sqrt(n << (2 * p))
106 // sqrt(2.pow(2 * p) * n)
107 // sqrt(2.pow(2 * p)) * sqrt(n)
108 // 2.pow(p) * sqrt(n)
109 // sqrt(n) << p
110 //
111 // Shifting by an odd number of bits leaves an ugly sqrt(2)
112 // multiplied in:
113 //
114 // sqrt(n << (2 * p + 1))
115 // sqrt(2.pow(2 * p + 1) * n)
116 // sqrt(2 * 2.pow(2 * p) * n)
117 // sqrt(2) * sqrt(2.pow(2 * p)) * sqrt(n)
118 // sqrt(2) * 2.pow(p) * sqrt(n)
119 // sqrt(2) * (sqrt(n) << p)
120 const EVEN_MAKING_BITMASK: u32 = !1;
121 let normalization_shift = n.leading_zeros() & EVEN_MAKING_BITMASK;
122 n <<= normalization_shift;
123
124 let s = $stages(n);
125
126 let denormalization_shift = normalization_shift >> 1;
127 s >> denormalization_shift
128 }
129 }
130 };
131}
132
133/// Generates the first stage of the computation after normalization.
134///
135/// # Safety
136///
137/// `$n` must be nonzero.
138macro_rules! first_stage {
139 ($original_bits:literal, $n:ident) => {{
140 debug_assert!($n != 0, "`$n` is zero in `first_stage!`.");
141
142 const N_SHIFT: u32 = $original_bits - 8;
143 let n = $n >> N_SHIFT;
144
145 let (s, r) = U8_ISQRT_WITH_REMAINDER[n as usize];
146
147 // Inform the optimizer that `s` is nonzero. This will allow it to
148 // avoid generating code to handle division-by-zero panics in the next
149 // stage.
150 //
151 // SAFETY: If the original `$n` is zero, the top of the `unsigned_fn`
152 // macro recurses instead of continuing to this point, so the original
153 // `$n` wasn't a 0 if we've reached here.
154 //
155 // Then the `unsigned_fn` macro normalizes `$n` so that at least one of
156 // its two most-significant bits is a 1.
157 //
158 // Then this stage puts the eight most-significant bits of `$n` into
159 // `n`. This means that `n` here has at least one 1 bit in its two
160 // most-significant bits, making `n` nonzero.
161 //
162 // `U8_ISQRT_WITH_REMAINDER[n as usize]` will give a nonzero `s` when
163 // given a nonzero `n`.
164 unsafe { crate::hint::assert_unchecked(s != 0) };
165 (s, r)
166 }};
167}
168
169/// Generates a middle stage of the computation.
170///
171/// # Safety
172///
173/// `$s` must be nonzero.
174macro_rules! middle_stage {
175 ($original_bits:literal, $ty:ty, $n:ident, $s:ident, $r:ident) => {{
176 debug_assert!($s != 0, "`$s` is zero in `middle_stage!`.");
177
178 const N_SHIFT: u32 = $original_bits - <$ty>::BITS;
179 let n = ($n >> N_SHIFT) as $ty;
180
181 const HALF_BITS: u32 = <$ty>::BITS >> 1;
182 const QUARTER_BITS: u32 = <$ty>::BITS >> 2;
183 const LOWER_HALF_1_BITS: $ty = (1 << HALF_BITS) - 1;
184 const LOWEST_QUARTER_1_BITS: $ty = (1 << QUARTER_BITS) - 1;
185
186 let lo = n & LOWER_HALF_1_BITS;
187 let numerator = (($r as $ty) << QUARTER_BITS) | (lo >> QUARTER_BITS);
188 let denominator = ($s as $ty) << 1;
189 let q = numerator / denominator;
190 let u = numerator % denominator;
191
192 let mut s = ($s << QUARTER_BITS) as $ty + q;
193 let (mut r, overflow) =
194 ((u << QUARTER_BITS) | (lo & LOWEST_QUARTER_1_BITS)).overflowing_sub(q * q);
195 if overflow {
196 r = r.wrapping_add(2 * s - 1);
197 s -= 1;
198 }
199
200 // Inform the optimizer that `s` is nonzero. This will allow it to
201 // avoid generating code to handle division-by-zero panics in the next
202 // stage.
203 //
204 // SAFETY: If the original `$n` is zero, the top of the `unsigned_fn`
205 // macro recurses instead of continuing to this point, so the original
206 // `$n` wasn't a 0 if we've reached here.
207 //
208 // Then the `unsigned_fn` macro normalizes `$n` so that at least one of
209 // its two most-significant bits is a 1.
210 //
211 // Then these stages take as many of the most-significant bits of `$n`
212 // as will fit in this stage's type. For example, the stage that
213 // handles `u32` deals with the 32 most-significant bits of `$n`. This
214 // means that each stage has at least one 1 bit in `n`'s two
215 // most-significant bits, making `n` nonzero.
216 //
217 // Then this stage will produce the correct integer square root for
218 // that `n` value. Since `n` is nonzero, `s` will also be nonzero.
219 unsafe { crate::hint::assert_unchecked(s != 0) };
220 (s, r)
221 }};
222}
223
224/// Generates the last stage of the computation before denormalization.
225///
226/// # Safety
227///
228/// `$s` must be nonzero.
229macro_rules! last_stage {
230 ($ty:ty, $n:ident, $s:ident, $r:ident) => {{
231 debug_assert!($s != 0, "`$s` is zero in `last_stage!`.");
232
233 const HALF_BITS: u32 = <$ty>::BITS >> 1;
234 const QUARTER_BITS: u32 = <$ty>::BITS >> 2;
235 const LOWER_HALF_1_BITS: $ty = (1 << HALF_BITS) - 1;
236
237 let lo = $n & LOWER_HALF_1_BITS;
238 let numerator = (($r as $ty) << QUARTER_BITS) | (lo >> QUARTER_BITS);
239 let denominator = ($s as $ty) << 1;
240
241 let q = numerator / denominator;
242 let mut s = ($s << QUARTER_BITS) as $ty + q;
243 let (s_squared, overflow) = s.overflowing_mul(s);
244 if overflow || s_squared > $n {
245 s -= 1;
246 }
247 s
248 }};
249}
250
251/// Takes the normalized [`u16`](prim@u16) input and gets its normalized
252/// [integer square root](https://en.wikipedia.org/wiki/Integer_square_root).
253///
254/// # Safety
255///
256/// `n` must be nonzero.
257#[inline]
258const fn u16_stages(n: u16) -> u16 {
259 let (s, r) = first_stage!(16, n);
260 last_stage!(u16, n, s, r)
261}
262
263/// Takes the normalized [`u32`](prim@u32) input and gets its normalized
264/// [integer square root](https://en.wikipedia.org/wiki/Integer_square_root).
265///
266/// # Safety
267///
268/// `n` must be nonzero.
269#[inline]
270const fn u32_stages(n: u32) -> u32 {
271 let (s, r) = first_stage!(32, n);
272 let (s, r) = middle_stage!(32, u16, n, s, r);
273 last_stage!(u32, n, s, r)
274}
275
276/// Takes the normalized [`u64`](prim@u64) input and gets its normalized
277/// [integer square root](https://en.wikipedia.org/wiki/Integer_square_root).
278///
279/// # Safety
280///
281/// `n` must be nonzero.
282#[inline]
283const fn u64_stages(n: u64) -> u64 {
284 let (s, r) = first_stage!(64, n);
285 let (s, r) = middle_stage!(64, u16, n, s, r);
286 let (s, r) = middle_stage!(64, u32, n, s, r);
287 last_stage!(u64, n, s, r)
288}
289
290/// Takes the normalized [`u128`](prim@u128) input and gets its normalized
291/// [integer square root](https://en.wikipedia.org/wiki/Integer_square_root).
292///
293/// # Safety
294///
295/// `n` must be nonzero.
296#[inline]
297const fn u128_stages(n: u128) -> u128 {
298 let (s, r) = first_stage!(128, n);
299 let (s, r) = middle_stage!(128, u16, n, s, r);
300 let (s, r) = middle_stage!(128, u32, n, s, r);
301 let (s, r) = middle_stage!(128, u64, n, s, r);
302 last_stage!(u128, n, s, r)
303}
304
305unsigned_fn!(u16, u8, u16_stages);
306unsigned_fn!(u32, u16, u32_stages);
307unsigned_fn!(u64, u32, u64_stages);
308unsigned_fn!(u128, u64, u128_stages);
309
310/// Instantiate this panic logic once, rather than for all the isqrt methods
311/// on every single primitive type.
312#[cold]
313#[track_caller]
314pub const fn panic_for_negative_argument() -> ! {
315 panic!("argument of integer square root cannot be negative")
316}
library/core/src/num/mod.rs+1
......@@ -41,6 +41,7 @@ mod uint_macros; // import uint_impl!
4141
4242mod error;
4343mod int_log10;
44mod int_sqrt;
4445mod nonzero;
4546mod overflow_panic;
4647mod saturating;
library/core/src/num/nonzero.rs+8-25
......@@ -7,7 +7,7 @@ use crate::marker::{Freeze, StructuralPartialEq};
77use crate::ops::{BitOr, BitOrAssign, Div, DivAssign, Neg, Rem, RemAssign};
88use crate::panic::{RefUnwindSafe, UnwindSafe};
99use crate::str::FromStr;
10use crate::{fmt, hint, intrinsics, ptr, ub_checks};
10use crate::{fmt, intrinsics, ptr, ub_checks};
1111
1212/// A marker trait for primitive types which can be zero.
1313///
......@@ -1545,31 +1545,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
15451545 without modifying the original"]
15461546 #[inline]
15471547 pub const fn isqrt(self) -> Self {
1548 // The algorithm is based on the one presented in
1549 // <https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Binary_numeral_system_(base_2)>
1550 // which cites as source the following C code:
1551 // <https://web.archive.org/web/20120306040058/http://medialab.freaknet.org/martin/src/sqrt/sqrt.c>.
1552
1553 let mut op = self.get();
1554 let mut res = 0;
1555 let mut one = 1 << (self.ilog2() & !1);
1556
1557 while one != 0 {
1558 if op >= res + one {
1559 op -= res + one;
1560 res = (res >> 1) + one;
1561 } else {
1562 res >>= 1;
1563 }
1564 one >>= 2;
1565 }
1548 let result = self.get().isqrt();
15661549
1567 // SAFETY: The result fits in an integer with half as many bits.
1568 // Inform the optimizer about it.
1569 unsafe { hint::assert_unchecked(res < 1 << (Self::BITS / 2)) };
1570
1571 // SAFETY: The square root of an integer >= 1 is always >= 1.
1572 unsafe { Self::new_unchecked(res) }
1550 // SAFETY: Integer square root is a monotonically nondecreasing
1551 // function, which means that increasing the input will never cause
1552 // the output to decrease. Thus, since the input for nonzero
1553 // unsigned integers has a lower bound of 1, the lower bound of the
1554 // results will be sqrt(1), which is 1, so a result can't be zero.
1555 unsafe { Self::new_unchecked(result) }
15731556 }
15741557 };
15751558
library/core/src/num/uint_macros.rs+17-3
......@@ -2762,10 +2762,24 @@ macro_rules! uint_impl {
27622762 without modifying the original"]
27632763 #[inline]
27642764 pub const fn isqrt(self) -> Self {
2765 match NonZero::new(self) {
2766 Some(x) => x.isqrt().get(),
2767 None => 0,
2765 let result = crate::num::int_sqrt::$ActualT(self as $ActualT) as $SelfT;
2766
2767 // Inform the optimizer what the range of outputs is. If testing
2768 // `core` crashes with no panic message and a `num::int_sqrt::u*`
2769 // test failed, it's because your edits caused these assertions or
2770 // the assertions in `fn isqrt` of `nonzero.rs` to become false.
2771 //
2772 // SAFETY: Integer square root is a monotonically nondecreasing
2773 // function, which means that increasing the input will never
2774 // cause the output to decrease. Thus, since the input for unsigned
2775 // integers is bounded by `[0, <$ActualT>::MAX]`, sqrt(n) will be
2776 // bounded by `[sqrt(0), sqrt(<$ActualT>::MAX)]`.
2777 unsafe {
2778 const MAX_RESULT: $SelfT = crate::num::int_sqrt::$ActualT(<$ActualT>::MAX) as $SelfT;
2779 crate::hint::assert_unchecked(result <= MAX_RESULT);
27682780 }
2781
2782 result
27692783 }
27702784
27712785 /// Performs Euclidean division.
library/core/tests/num/int_macros.rs-32
......@@ -288,38 +288,6 @@ macro_rules! int_module {
288288 assert_eq!(r.saturating_pow(0), 1 as $T);
289289 }
290290
291 #[test]
292 fn test_isqrt() {
293 assert_eq!($T::MIN.checked_isqrt(), None);
294 assert_eq!((-1 as $T).checked_isqrt(), None);
295 assert_eq!((0 as $T).isqrt(), 0 as $T);
296 assert_eq!((1 as $T).isqrt(), 1 as $T);
297 assert_eq!((2 as $T).isqrt(), 1 as $T);
298 assert_eq!((99 as $T).isqrt(), 9 as $T);
299 assert_eq!((100 as $T).isqrt(), 10 as $T);
300 }
301
302 #[cfg(not(miri))] // Miri is too slow
303 #[test]
304 fn test_lots_of_isqrt() {
305 let n_max: $T = (1024 * 1024).min($T::MAX as u128) as $T;
306 for n in 0..=n_max {
307 let isqrt: $T = n.isqrt();
308
309 assert!(isqrt.pow(2) <= n);
310 let (square, overflow) = (isqrt + 1).overflowing_pow(2);
311 assert!(overflow || square > n);
312 }
313
314 for n in ($T::MAX - 127)..=$T::MAX {
315 let isqrt: $T = n.isqrt();
316
317 assert!(isqrt.pow(2) <= n);
318 let (square, overflow) = (isqrt + 1).overflowing_pow(2);
319 assert!(overflow || square > n);
320 }
321 }
322
323291 #[test]
324292 fn test_div_floor() {
325293 let a: $T = 8;
library/core/tests/num/int_sqrt.rs created+248
......@@ -0,0 +1,248 @@
1macro_rules! tests {
2 ($isqrt_consistency_check_fn_macro:ident : $($T:ident)+) => {
3 $(
4 mod $T {
5 $isqrt_consistency_check_fn_macro!($T);
6
7 // Check that the following produce the correct values from
8 // `isqrt`:
9 //
10 // * the first and last 128 nonnegative values
11 // * powers of two, minus one
12 // * powers of two
13 //
14 // For signed types, check that `checked_isqrt` and `isqrt`
15 // either produce the same numeric value or respectively
16 // produce `None` and a panic. Make sure to do a consistency
17 // check for `<$T>::MIN` as well, as no nonnegative values
18 // negate to it.
19 //
20 // For unsigned types check that `isqrt` produces the same
21 // numeric value for `$T` and `NonZero<$T>`.
22 #[test]
23 fn isqrt() {
24 isqrt_consistency_check(<$T>::MIN);
25
26 for n in (0..=127)
27 .chain(<$T>::MAX - 127..=<$T>::MAX)
28 .chain((0..<$T>::MAX.count_ones()).map(|exponent| (1 << exponent) - 1))
29 .chain((0..<$T>::MAX.count_ones()).map(|exponent| 1 << exponent))
30 {
31 isqrt_consistency_check(n);
32
33 let isqrt_n = n.isqrt();
34 assert!(
35 isqrt_n
36 .checked_mul(isqrt_n)
37 .map(|isqrt_n_squared| isqrt_n_squared <= n)
38 .unwrap_or(false),
39 "`{n}.isqrt()` should be lower than {isqrt_n}."
40 );
41 assert!(
42 (isqrt_n + 1)
43 .checked_mul(isqrt_n + 1)
44 .map(|isqrt_n_plus_1_squared| n < isqrt_n_plus_1_squared)
45 .unwrap_or(true),
46 "`{n}.isqrt()` should be higher than {isqrt_n})."
47 );
48 }
49 }
50
51 // Check the square roots of:
52 //
53 // * the first 1,024 perfect squares
54 // * halfway between each of the first 1,024 perfect squares
55 // and the next perfect square
56 // * the next perfect square after the each of the first 1,024
57 // perfect squares, minus one
58 // * the last 1,024 perfect squares
59 // * the last 1,024 perfect squares, minus one
60 // * halfway between each of the last 1,024 perfect squares
61 // and the previous perfect square
62 #[test]
63 // Skip this test on Miri, as it takes too long to run.
64 #[cfg(not(miri))]
65 fn isqrt_extended() {
66 // The correct value is worked out by using the fact that
67 // the nth nonzero perfect square is the sum of the first n
68 // odd numbers:
69 //
70 // 1 = 1
71 // 4 = 1 + 3
72 // 9 = 1 + 3 + 5
73 // 16 = 1 + 3 + 5 + 7
74 //
75 // Note also that the last odd number added in is two times
76 // the square root of the previous perfect square, plus
77 // one:
78 //
79 // 1 = 2*0 + 1
80 // 3 = 2*1 + 1
81 // 5 = 2*2 + 1
82 // 7 = 2*3 + 1
83 //
84 // That means we can add the square root of this perfect
85 // square once to get about halfway to the next perfect
86 // square, then we can add the square root of this perfect
87 // square again to get to the next perfect square, minus
88 // one, then we can add one to get to the next perfect
89 // square.
90 //
91 // This allows us to, for each of the first 1,024 perfect
92 // squares, test that the square roots of the following are
93 // all correct and equal to each other:
94 //
95 // * the current perfect square
96 // * about halfway to the next perfect square
97 // * the next perfect square, minus one
98 let mut n: $T = 0;
99 for sqrt_n in 0..1_024.min((1_u128 << (<$T>::MAX.count_ones()/2)) - 1) as $T {
100 isqrt_consistency_check(n);
101 assert_eq!(
102 n.isqrt(),
103 sqrt_n,
104 "`{sqrt_n}.pow(2).isqrt()` should be {sqrt_n}."
105 );
106
107 n += sqrt_n;
108 isqrt_consistency_check(n);
109 assert_eq!(
110 n.isqrt(),
111 sqrt_n,
112 "{n} is about halfway between `{sqrt_n}.pow(2)` and `{}.pow(2)`, so `{n}.isqrt()` should be {sqrt_n}.",
113 sqrt_n + 1
114 );
115
116 n += sqrt_n;
117 isqrt_consistency_check(n);
118 assert_eq!(
119 n.isqrt(),
120 sqrt_n,
121 "`({}.pow(2) - 1).isqrt()` should be {sqrt_n}.",
122 sqrt_n + 1
123 );
124
125 n += 1;
126 }
127
128 // Similarly, for each of the last 1,024 perfect squares,
129 // check:
130 //
131 // * the current perfect square
132 // * the current perfect square, minus one
133 // * about halfway to the previous perfect square
134 //
135 // `MAX`'s `isqrt` return value is verified in the `isqrt`
136 // test function above.
137 let maximum_sqrt = <$T>::MAX.isqrt();
138 let mut n = maximum_sqrt * maximum_sqrt;
139
140 for sqrt_n in (maximum_sqrt - 1_024.min((1_u128 << (<$T>::MAX.count_ones()/2)) - 1) as $T..maximum_sqrt).rev() {
141 isqrt_consistency_check(n);
142 assert_eq!(
143 n.isqrt(),
144 sqrt_n + 1,
145 "`{0}.pow(2).isqrt()` should be {0}.",
146 sqrt_n + 1
147 );
148
149 n -= 1;
150 isqrt_consistency_check(n);
151 assert_eq!(
152 n.isqrt(),
153 sqrt_n,
154 "`({}.pow(2) - 1).isqrt()` should be {sqrt_n}.",
155 sqrt_n + 1
156 );
157
158 n -= sqrt_n;
159 isqrt_consistency_check(n);
160 assert_eq!(
161 n.isqrt(),
162 sqrt_n,
163 "{n} is about halfway between `{sqrt_n}.pow(2)` and `{}.pow(2)`, so `{n}.isqrt()` should be {sqrt_n}.",
164 sqrt_n + 1
165 );
166
167 n -= sqrt_n;
168 }
169 }
170 }
171 )*
172 };
173}
174
175macro_rules! signed_check {
176 ($T:ident) => {
177 /// This takes an input and, if it's nonnegative or
178 #[doc = concat!("`", stringify!($T), "::MIN`,")]
179 /// checks that `isqrt` and `checked_isqrt` produce equivalent results
180 /// for that input and for the negative of that input.
181 ///
182 /// # Note
183 ///
184 /// This cannot check that negative inputs to `isqrt` cause panics if
185 /// panics abort instead of unwind.
186 fn isqrt_consistency_check(n: $T) {
187 // `<$T>::MIN` will be negative, so ignore it in this nonnegative
188 // section.
189 if n >= 0 {
190 assert_eq!(
191 Some(n.isqrt()),
192 n.checked_isqrt(),
193 "`{n}.checked_isqrt()` should match `Some({n}.isqrt())`.",
194 );
195 }
196
197 // `wrapping_neg` so that `<$T>::MIN` will negate to itself rather
198 // than panicking.
199 let negative_n = n.wrapping_neg();
200
201 // Zero negated will still be nonnegative, so ignore it in this
202 // negative section.
203 if negative_n < 0 {
204 assert_eq!(
205 negative_n.checked_isqrt(),
206 None,
207 "`({negative_n}).checked_isqrt()` should be `None`, as {negative_n} is negative.",
208 );
209
210 // `catch_unwind` only works when panics unwind rather than abort.
211 #[cfg(panic = "unwind")]
212 {
213 std::panic::catch_unwind(core::panic::AssertUnwindSafe(|| (-n).isqrt())).expect_err(
214 &format!("`({negative_n}).isqrt()` should have panicked, as {negative_n} is negative.")
215 );
216 }
217 }
218 }
219 };
220}
221
222macro_rules! unsigned_check {
223 ($T:ident) => {
224 /// This takes an input and, if it's nonzero, checks that `isqrt`
225 /// produces the same numeric value for both
226 #[doc = concat!("`", stringify!($T), "` and ")]
227 #[doc = concat!("`NonZero<", stringify!($T), ">`.")]
228 fn isqrt_consistency_check(n: $T) {
229 // Zero cannot be turned into a `NonZero` value, so ignore it in
230 // this nonzero section.
231 if n > 0 {
232 assert_eq!(
233 n.isqrt(),
234 core::num::NonZero::<$T>::new(n)
235 .expect(
236 "Was not able to create a new `NonZero` value from a nonzero number."
237 )
238 .isqrt()
239 .get(),
240 "`{n}.isqrt` should match `NonZero`'s `{n}.isqrt().get()`.",
241 );
242 }
243 }
244 };
245}
246
247tests!(signed_check: i8 i16 i32 i64 i128);
248tests!(unsigned_check: u8 u16 u32 u64 u128);
library/core/tests/num/mod.rs+1
......@@ -27,6 +27,7 @@ mod const_from;
2727mod dec2flt;
2828mod flt2dec;
2929mod int_log;
30mod int_sqrt;
3031mod ops;
3132mod wrapping;
3233
src/doc/rustc/src/check-cfg.md+2-1
......@@ -99,7 +99,7 @@ the need to specify them manually.
9999Well known names and values are implicitly added as long as at least one `--check-cfg` argument
100100is present.
101101
102As of `2024-05-06T`, the list of known names is as follows:
102As 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
......@@ -107,6 +107,7 @@ As of `2024-05-06T`, the list of known names is as follows:
107107 - `debug_assertions`
108108 - `doc`
109109 - `doctest`
110 - `fmt_debug`
110111 - `miri`
111112 - `overflow_checks`
112113 - `panic`
src/doc/unstable-book/src/compiler-flags/fmt-debug.md created+15
......@@ -0,0 +1,15 @@
1# `fmt-debug`
2
3The tracking issue for this feature is: [#129709](https://github.com/rust-lang/rust/issues/129709).
4
5------------------------
6
7Option `-Z fmt-debug=val` controls verbosity of derived `Debug` implementations
8and 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.
src/doc/unstable-book/src/compiler-flags/lint-llvm-ir.md created+7
......@@ -0,0 +1,7 @@
1# `lint-llvm-ir`
2
3---------------------
4
5This flag will add `LintPass` to the start of the pipeline.
6You can use it to check for common errors in the LLVM IR generated by `rustc`.
7You can add `-Cllvm-args=-lint-abort-on-error` to abort the process if errors were found.
src/doc/unstable-book/src/compiler-flags/sanitizer.md+33-7
......@@ -775,22 +775,47 @@ See the [Clang SafeStack documentation][clang-safestack] for more details.
775775
776776# ShadowCallStack
777777
778ShadowCallStack provides backward edge control flow protection by storing a function's return address in a separately allocated 'shadow call stack' and loading the return address from that shadow call stack.
779
780ShadowCallStack requires a platform ABI which reserves `x18` as the instrumentation makes use of this register.
778ShadowCallStack provides backward edge control flow protection by storing a function's return address in a separately allocated 'shadow call stack'
779and loading the return address from that shadow call stack.
780AArch64 and RISC-V both have a platform register defined in their ABIs, which is `x18` and `x3`/`gp` respectively, that can optionally be reserved for this purpose.
781Software support from the operating system and runtime may be required depending on the target platform which is detailed in the remaining section.
782See the [Clang ShadowCallStack documentation][clang-scs] for more details.
781783
782784ShadowCallStack can be enabled with `-Zsanitizer=shadow-call-stack` option and is supported on the following targets:
783785
784* `aarch64-linux-android`
786## AArch64 family
785787
786A runtime must be provided by the application or operating system.
788ShadowCallStack requires the use of the ABI defined platform register, `x18`, which is required for code generation purposes.
789When `x18` is not reserved, and is instead used as a scratch register subsequently, enabling ShadowCallStack would lead to undefined behaviour
790due to corruption of return address or invalid memory access when the instrumentation restores return register to the link register `lr` from the
791already clobbered `x18` register.
792In other words, code that is calling into or called by functions instrumented with ShadowCallStack must reserve the `x18` register or preserve its value.
787793
788See the [Clang ShadowCallStack documentation][clang-scs] for more details.
794### `aarch64-linux-android` and `aarch64-unknown-fuchsia`/`aarch64-fuchsia`
789795
790* `aarch64-unknown-none`
796This target already reserves the `x18` register.
797A runtime must be provided by the application or operating system.
798If `bionic` is used on this target, the software support is provided.
799Otherwise, a runtime needs to prepare a memory region and points `x18` to the region which serves as the shadow call stack.
800
801### `aarch64-unknown-none`
791802
792803In addition to support from a runtime by the application or operating system, the `-Zfixed-x18` flag is also mandatory.
793804
805## RISC-V 64 family
806
807ShadowCallStack uses either the `gp` register for software shadow stack, also known as `x3`, or the `ssp` register if [`Zicfiss`][riscv-zicfiss] extension is available.
808`gp`/`x3` is currently always reserved and available for ShadowCallStack instrumentation, and `ssp` in case of `Zicfiss` is only accessible through its dedicated shadow stack instructions.
809
810Support from the runtime and operating system is required when `gp`/`x3` is used for software shadow stack.
811A runtime must prepare a memory region and point `gp`/`x3` to the region before executing the code.
812
813The following targets support ShadowCallStack.
814
815* `riscv64imac-unknown-none-elf`
816* `riscv64gc-unknown-none-elf`
817* `riscv64gc-unknown-fuchsia`
818
794819# ThreadSanitizer
795820
796821ThreadSanitizer is a data race detection tool. It is supported on the following
......@@ -912,3 +937,4 @@ Sanitizers produce symbolized stacktraces when llvm-symbolizer binary is in `PAT
912937[clang-tsan]: https://clang.llvm.org/docs/ThreadSanitizer.html
913938[linux-kasan]: https://www.kernel.org/doc/html/latest/dev-tools/kasan.html
914939[llvm-memtag]: https://llvm.org/docs/MemTagSanitizer.html
940[riscv-zicfiss]: https://github.com/riscv/riscv-cfi/blob/3f8e450c481ac303bd5643444f7a89672f24476e/src/cfi_backward.adoc
src/librustdoc/clean/auto_trait.rs+1-1
......@@ -341,7 +341,7 @@ fn clean_region_outlives_constraints<'tcx>(
341341 .map(|&region| {
342342 let lifetime = early_bound_region_name(region)
343343 .inspect(|name| assert!(region_params.contains(name)))
344 .map(|name| Lifetime(name))
344 .map(Lifetime)
345345 .unwrap_or(Lifetime::statik());
346346 clean::GenericBound::Outlives(lifetime)
347347 })
src/librustdoc/clean/blanket_impl.rs+1-1
......@@ -24,7 +24,7 @@ pub(crate) fn synthesize_blanket_impls(
2424 let mut blanket_impls = Vec::new();
2525 for trait_def_id in tcx.all_traits() {
2626 if !cx.cache.effective_visibilities.is_reachable(tcx, trait_def_id)
27 || cx.generated_synthetics.get(&(ty.skip_binder(), trait_def_id)).is_some()
27 || cx.generated_synthetics.contains(&(ty.skip_binder(), trait_def_id))
2828 {
2929 continue;
3030 }
src/librustdoc/clean/inline.rs+12-16
......@@ -54,7 +54,7 @@ pub(crate) fn try_inline(
5454 debug!("attrs={attrs:?}");
5555
5656 let attrs_without_docs = attrs.map(|(attrs, def_id)| {
57 (attrs.into_iter().filter(|a| a.doc_str().is_none()).cloned().collect::<Vec<_>>(), def_id)
57 (attrs.iter().filter(|a| a.doc_str().is_none()).cloned().collect::<Vec<_>>(), def_id)
5858 });
5959 let attrs_without_docs =
6060 attrs_without_docs.as_ref().map(|(attrs, def_id)| (&attrs[..], *def_id));
......@@ -288,10 +288,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
288288 clean::Trait { def_id: did, generics, items: trait_items, bounds: supertrait_bounds }
289289}
290290
291pub(crate) fn build_function<'tcx>(
292 cx: &mut DocContext<'tcx>,
293 def_id: DefId,
294) -> Box<clean::Function> {
291pub(crate) fn build_function(cx: &mut DocContext<'_>, def_id: DefId) -> Box<clean::Function> {
295292 let sig = cx.tcx.fn_sig(def_id).instantiate_identity();
296293 // The generics need to be cleaned before the signature.
297294 let mut generics =
......@@ -425,7 +422,7 @@ pub(crate) fn merge_attrs(
425422 both.cfg(cx.tcx, &cx.cache.hidden_cfg),
426423 )
427424 } else {
428 (Attributes::from_ast(&old_attrs), old_attrs.cfg(cx.tcx, &cx.cache.hidden_cfg))
425 (Attributes::from_ast(old_attrs), old_attrs.cfg(cx.tcx, &cx.cache.hidden_cfg))
429426 }
430427}
431428
......@@ -791,16 +788,15 @@ fn build_macro(
791788/// implementation for `AssociatedType`
792789fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean::Generics {
793790 for pred in &mut g.where_predicates {
794 match *pred {
795 clean::WherePredicate::BoundPredicate { ty: clean::SelfTy, ref mut bounds, .. } => {
796 bounds.retain(|bound| match bound {
797 clean::GenericBound::TraitBound(clean::PolyTrait { trait_, .. }, _) => {
798 trait_.def_id() != trait_did
799 }
800 _ => true,
801 });
802 }
803 _ => {}
791 if let clean::WherePredicate::BoundPredicate { ty: clean::SelfTy, ref mut bounds, .. } =
792 *pred
793 {
794 bounds.retain(|bound| match bound {
795 clean::GenericBound::TraitBound(clean::PolyTrait { trait_, .. }, _) => {
796 trait_.def_id() != trait_did
797 }
798 _ => true,
799 });
804800 }
805801 }
806802
src/librustdoc/clean/mod.rs+25-30
......@@ -266,7 +266,7 @@ fn clean_poly_trait_ref_with_constraints<'tcx>(
266266 )
267267}
268268
269fn clean_lifetime<'tcx>(lifetime: &hir::Lifetime, cx: &mut DocContext<'tcx>) -> Lifetime {
269fn clean_lifetime(lifetime: &hir::Lifetime, cx: &mut DocContext<'_>) -> Lifetime {
270270 if let Some(
271271 rbv::ResolvedArg::EarlyBound(did)
272272 | rbv::ResolvedArg::LateBound(_, _, did)
......@@ -274,7 +274,7 @@ fn clean_lifetime<'tcx>(lifetime: &hir::Lifetime, cx: &mut DocContext<'tcx>) ->
274274 ) = cx.tcx.named_bound_var(lifetime.hir_id)
275275 && let Some(lt) = cx.args.get(&did.to_def_id()).and_then(|arg| arg.as_lt())
276276 {
277 return lt.clone();
277 return *lt;
278278 }
279279 Lifetime(lifetime.ident.name)
280280}
......@@ -285,7 +285,7 @@ pub(crate) fn clean_const<'tcx>(
285285) -> ConstantKind {
286286 match &constant.kind {
287287 hir::ConstArgKind::Path(qpath) => {
288 ConstantKind::Path { path: qpath_to_string(&qpath).into() }
288 ConstantKind::Path { path: qpath_to_string(qpath).into() }
289289 }
290290 hir::ConstArgKind::Anon(anon) => ConstantKind::Anonymous { body: anon.body },
291291 }
......@@ -299,7 +299,7 @@ pub(crate) fn clean_middle_const<'tcx>(
299299 ConstantKind::TyConst { expr: constant.skip_binder().to_string().into() }
300300}
301301
302pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Lifetime> {
302pub(crate) fn clean_middle_region(region: ty::Region<'_>) -> Option<Lifetime> {
303303 match *region {
304304 ty::ReStatic => Some(Lifetime::statik()),
305305 _ if !region.has_name() => None,
......@@ -389,8 +389,8 @@ fn clean_poly_trait_predicate<'tcx>(
389389 })
390390}
391391
392fn clean_region_outlives_predicate<'tcx>(
393 pred: ty::RegionOutlivesPredicate<'tcx>,
392fn clean_region_outlives_predicate(
393 pred: ty::RegionOutlivesPredicate<'_>,
394394) -> Option<WherePredicate> {
395395 let ty::OutlivesPredicate(a, b) = pred;
396396
......@@ -513,10 +513,10 @@ fn projection_to_path_segment<'tcx>(
513513 }
514514}
515515
516fn clean_generic_param_def<'tcx>(
516fn clean_generic_param_def(
517517 def: &ty::GenericParamDef,
518518 defaults: ParamDefaults,
519 cx: &mut DocContext<'tcx>,
519 cx: &mut DocContext<'_>,
520520) -> GenericParamDef {
521521 let (name, kind) = match def.kind {
522522 ty::GenericParamDefKind::Lifetime => {
......@@ -1303,10 +1303,7 @@ pub(crate) fn clean_impl_item<'tcx>(
13031303 })
13041304}
13051305
1306pub(crate) fn clean_middle_assoc_item<'tcx>(
1307 assoc_item: &ty::AssocItem,
1308 cx: &mut DocContext<'tcx>,
1309) -> Item {
1306pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocContext<'_>) -> Item {
13101307 let tcx = cx.tcx;
13111308 let kind = match assoc_item.kind {
13121309 ty::AssocKind::Const => {
......@@ -1459,7 +1456,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
14591456 // which only has one associated type, which is not a GAT, so whatever.
14601457 }
14611458 }
1462 bounds.extend(mem::replace(pred_bounds, Vec::new()));
1459 bounds.extend(mem::take(pred_bounds));
14631460 false
14641461 }
14651462 _ => true,
......@@ -1661,7 +1658,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
16611658 expanded
16621659 } else {
16631660 // First we check if it's a private re-export.
1664 let path = if let Some(path) = first_non_private(cx, hir_id, &path) {
1661 let path = if let Some(path) = first_non_private(cx, hir_id, path) {
16651662 path
16661663 } else {
16671664 clean_path(path, cx)
......@@ -1796,7 +1793,7 @@ fn maybe_expand_private_type_alias<'tcx>(
17961793 }
17971794
17981795 Some(cx.enter_alias(args, def_id.to_def_id(), |cx| {
1799 cx.with_param_env(def_id.to_def_id(), |cx| clean_ty(&ty, cx))
1796 cx.with_param_env(def_id.to_def_id(), |cx| clean_ty(ty, cx))
18001797 }))
18011798}
18021799
......@@ -1806,8 +1803,8 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18061803 match ty.kind {
18071804 TyKind::Never => Primitive(PrimitiveType::Never),
18081805 TyKind::Ptr(ref m) => RawPointer(m.mutbl, Box::new(clean_ty(m.ty, cx))),
1809 TyKind::Ref(ref l, ref m) => {
1810 let lifetime = if l.is_anonymous() { None } else { Some(clean_lifetime(*l, cx)) };
1806 TyKind::Ref(l, ref m) => {
1807 let lifetime = if l.is_anonymous() { None } else { Some(clean_lifetime(l, cx)) };
18111808 BorrowedRef { lifetime, mutability: m.mutbl, type_: Box::new(clean_ty(m.ty, cx)) }
18121809 }
18131810 TyKind::Slice(ty) => Slice(Box::new(clean_ty(ty, cx))),
......@@ -1843,17 +1840,17 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18431840 TyKind::Tup(tys) => Tuple(tys.iter().map(|ty| clean_ty(ty, cx)).collect()),
18441841 TyKind::OpaqueDef(item_id, _, _) => {
18451842 let item = cx.tcx.hir().item(item_id);
1846 if let hir::ItemKind::OpaqueTy(ref ty) = item.kind {
1843 if let hir::ItemKind::OpaqueTy(ty) = item.kind {
18471844 ImplTrait(ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect())
18481845 } else {
18491846 unreachable!()
18501847 }
18511848 }
18521849 TyKind::Path(_) => clean_qpath(ty, cx),
1853 TyKind::TraitObject(bounds, ref lifetime, _) => {
1850 TyKind::TraitObject(bounds, lifetime, _) => {
18541851 let bounds = bounds.iter().map(|(bound, _)| clean_poly_trait_ref(bound, cx)).collect();
18551852 let lifetime =
1856 if !lifetime.is_elided() { Some(clean_lifetime(*lifetime, cx)) } else { None };
1853 if !lifetime.is_elided() { Some(clean_lifetime(lifetime, cx)) } else { None };
18571854 DynTrait(bounds, lifetime)
18581855 }
18591856 TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
......@@ -2355,7 +2352,7 @@ pub(crate) fn clean_field<'tcx>(field: &hir::FieldDef<'tcx>, cx: &mut DocContext
23552352 clean_field_with_def_id(field.def_id.to_def_id(), field.ident.name, clean_ty(field.ty, cx), cx)
23562353}
23572354
2358pub(crate) fn clean_middle_field<'tcx>(field: &ty::FieldDef, cx: &mut DocContext<'tcx>) -> Item {
2355pub(crate) fn clean_middle_field(field: &ty::FieldDef, cx: &mut DocContext<'_>) -> Item {
23592356 clean_field_with_def_id(
23602357 field.did,
23612358 field.name,
......@@ -2378,7 +2375,7 @@ pub(crate) fn clean_field_with_def_id(
23782375 Item::from_def_id_and_parts(def_id, Some(name), StructFieldItem(ty), cx)
23792376}
23802377
2381pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item {
2378pub(crate) fn clean_variant_def(variant: &ty::VariantDef, cx: &mut DocContext<'_>) -> Item {
23822379 let discriminant = match variant.discr {
23832380 ty::VariantDiscr::Explicit(def_id) => Some(Discriminant { expr: None, value: def_id }),
23842381 ty::VariantDiscr::Relative(_) => None,
......@@ -2526,7 +2523,7 @@ fn clean_generic_args<'tcx>(
25262523 .filter_map(|arg| {
25272524 Some(match arg {
25282525 hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2529 GenericArg::Lifetime(clean_lifetime(*lt, cx))
2526 GenericArg::Lifetime(clean_lifetime(lt, cx))
25302527 }
25312528 hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
25322529 hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
......@@ -2579,11 +2576,11 @@ fn clean_bare_fn_ty<'tcx>(
25792576 BareFunctionDecl { safety: bare_fn.safety, abi: bare_fn.abi, decl, generic_params }
25802577}
25812578
2582pub(crate) fn reexport_chain<'tcx>(
2583 tcx: TyCtxt<'tcx>,
2579pub(crate) fn reexport_chain(
2580 tcx: TyCtxt<'_>,
25842581 import_def_id: LocalDefId,
25852582 target_def_id: DefId,
2586) -> &'tcx [Reexport] {
2583) -> &[Reexport] {
25872584 for child in tcx.module_children_local(tcx.local_parent(import_def_id)) {
25882585 if child.res.opt_def_id() == Some(target_def_id)
25892586 && child.reexport_chain.first().and_then(|r| r.id()) == Some(import_def_id.to_def_id())
......@@ -2803,7 +2800,7 @@ fn clean_maybe_renamed_item<'tcx>(
28032800 fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
28042801 }),
28052802 ItemKind::Impl(impl_) => return clean_impl(impl_, item.owner_id.def_id, cx),
2806 ItemKind::Macro(ref macro_def, MacroKind::Bang) => {
2803 ItemKind::Macro(macro_def, MacroKind::Bang) => {
28072804 let ty_vis = cx.tcx.visibility(def_id);
28082805 MacroItem(Macro {
28092806 // FIXME this shouldn't be false
......@@ -3134,9 +3131,7 @@ fn clean_assoc_item_constraint<'tcx>(
31343131 }
31353132}
31363133
3137fn clean_bound_vars<'tcx>(
3138 bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
3139) -> Vec<GenericParamDef> {
3134fn clean_bound_vars(bound_vars: &ty::List<ty::BoundVariableKind>) -> Vec<GenericParamDef> {
31403135 bound_vars
31413136 .into_iter()
31423137 .filter_map(|var| match var {
src/librustdoc/clean/simplify.rs+1-1
......@@ -70,7 +70,7 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: ThinVec<WP>) -> ThinVe
7070
7171pub(crate) fn merge_bounds(
7272 cx: &clean::DocContext<'_>,
73 bounds: &mut Vec<clean::GenericBound>,
73 bounds: &mut [clean::GenericBound],
7474 trait_did: DefId,
7575 assoc: clean::PathSegment,
7676 rhs: &clean::Term,
src/librustdoc/clean/types.rs+14-17
......@@ -368,11 +368,11 @@ fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
368368}
369369
370370impl Item {
371 pub(crate) fn stability<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<Stability> {
371 pub(crate) fn stability(&self, tcx: TyCtxt<'_>) -> Option<Stability> {
372372 self.def_id().and_then(|did| tcx.lookup_stability(did))
373373 }
374374
375 pub(crate) fn const_stability<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<ConstStability> {
375 pub(crate) fn const_stability(&self, tcx: TyCtxt<'_>) -> Option<ConstStability> {
376376 self.def_id().and_then(|did| tcx.lookup_const_stability(did))
377377 }
378378
......@@ -945,9 +945,9 @@ pub(crate) trait AttributesExt {
945945 where
946946 Self: 'a;
947947
948 fn lists<'a>(&'a self, name: Symbol) -> Self::AttributeIterator<'a>;
948 fn lists(&self, name: Symbol) -> Self::AttributeIterator<'_>;
949949
950 fn iter<'a>(&'a self) -> Self::Attributes<'a>;
950 fn iter(&self) -> Self::Attributes<'_>;
951951
952952 fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
953953 let sess = tcx.sess;
......@@ -1043,15 +1043,15 @@ impl AttributesExt for [ast::Attribute] {
10431043 type AttributeIterator<'a> = impl Iterator<Item = ast::NestedMetaItem> + 'a;
10441044 type Attributes<'a> = impl Iterator<Item = &'a ast::Attribute> + 'a;
10451045
1046 fn lists<'a>(&'a self, name: Symbol) -> Self::AttributeIterator<'a> {
1046 fn lists(&self, name: Symbol) -> Self::AttributeIterator<'_> {
10471047 self.iter()
10481048 .filter(move |attr| attr.has_name(name))
10491049 .filter_map(ast::Attribute::meta_item_list)
10501050 .flatten()
10511051 }
10521052
1053 fn iter<'a>(&'a self) -> Self::Attributes<'a> {
1054 self.into_iter()
1053 fn iter(&self) -> Self::Attributes<'_> {
1054 self.iter()
10551055 }
10561056}
10571057
......@@ -1061,15 +1061,15 @@ impl AttributesExt for [(Cow<'_, ast::Attribute>, Option<DefId>)] {
10611061 type Attributes<'a> = impl Iterator<Item = &'a ast::Attribute> + 'a
10621062 where Self: 'a;
10631063
1064 fn lists<'a>(&'a self, name: Symbol) -> Self::AttributeIterator<'a> {
1064 fn lists(&self, name: Symbol) -> Self::AttributeIterator<'_> {
10651065 AttributesExt::iter(self)
10661066 .filter(move |attr| attr.has_name(name))
10671067 .filter_map(ast::Attribute::meta_item_list)
10681068 .flatten()
10691069 }
10701070
1071 fn iter<'a>(&'a self) -> Self::Attributes<'a> {
1072 self.into_iter().map(move |(attr, _)| match attr {
1071 fn iter(&self) -> Self::Attributes<'_> {
1072 self.iter().map(move |(attr, _)| match attr {
10731073 Cow::Borrowed(attr) => *attr,
10741074 Cow::Owned(attr) => attr,
10751075 })
......@@ -1389,7 +1389,7 @@ pub(crate) struct FnDecl {
13891389
13901390impl FnDecl {
13911391 pub(crate) fn receiver_type(&self) -> Option<&Type> {
1392 self.inputs.values.get(0).and_then(|v| v.to_receiver())
1392 self.inputs.values.first().and_then(|v| v.to_receiver())
13931393 }
13941394}
13951395
......@@ -1502,7 +1502,7 @@ impl Type {
15021502 pub(crate) fn without_borrowed_ref(&self) -> &Type {
15031503 let mut result = self;
15041504 while let Type::BorrowedRef { type_, .. } = result {
1505 result = &*type_;
1505 result = type_;
15061506 }
15071507 result
15081508 }
......@@ -1631,10 +1631,7 @@ impl Type {
16311631 }
16321632
16331633 pub(crate) fn is_self_type(&self) -> bool {
1634 match *self {
1635 SelfTy => true,
1636 _ => false,
1637 }
1634 matches!(*self, Type::SelfTy)
16381635 }
16391636
16401637 pub(crate) fn generic_args(&self) -> Option<&GenericArgs> {
......@@ -1673,7 +1670,7 @@ impl Type {
16731670 pub(crate) fn def_id(&self, cache: &Cache) -> Option<DefId> {
16741671 let t: PrimitiveType = match *self {
16751672 Type::Path { ref path } => return Some(path.def_id()),
1676 DynTrait(ref bounds, _) => return bounds.get(0).map(|b| b.trait_.def_id()),
1673 DynTrait(ref bounds, _) => return bounds.first().map(|b| b.trait_.def_id()),
16771674 Primitive(p) => return cache.primitive_locations.get(&p).cloned(),
16781675 BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference,
16791676 BorrowedRef { ref type_, .. } => return type_.def_id(cache),
src/librustdoc/clean/utils.rs+6-6
......@@ -321,9 +321,9 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
321321 "({})",
322322 elts.iter().map(|p| name_from_pat(p).to_string()).collect::<Vec<String>>().join(", ")
323323 ),
324 PatKind::Box(p) => return name_from_pat(&*p),
325 PatKind::Deref(p) => format!("deref!({})", name_from_pat(&*p)),
326 PatKind::Ref(p, _) => return name_from_pat(&*p),
324 PatKind::Box(p) => return name_from_pat(p),
325 PatKind::Deref(p) => format!("deref!({})", name_from_pat(p)),
326 PatKind::Ref(p, _) => return name_from_pat(p),
327327 PatKind::Lit(..) => {
328328 warn!(
329329 "tried to get argument name from PatKind::Lit, which is silly in function arguments"
......@@ -333,7 +333,7 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
333333 PatKind::Range(..) => return kw::Underscore,
334334 PatKind::Slice(begin, ref mid, end) => {
335335 let begin = begin.iter().map(|p| name_from_pat(p).to_string());
336 let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
336 let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(p))).into_iter();
337337 let end = end.iter().map(|p| name_from_pat(p).to_string());
338338 format!("[{}]", begin.chain(mid).chain(end).collect::<Vec<_>>().join(", "))
339339 }
......@@ -344,7 +344,7 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
344344 match n.kind() {
345345 ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args: _ }) => {
346346 let s = if let Some(def) = def.as_local() {
347 rendered_const(cx.tcx, &cx.tcx.hir().body_owned_by(def), def)
347 rendered_const(cx.tcx, cx.tcx.hir().body_owned_by(def), def)
348348 } else {
349349 inline::print_inlined_const(cx.tcx, def)
350350 };
......@@ -383,7 +383,7 @@ pub(crate) fn print_evaluated_const(
383383
384384fn format_integer_with_underscore_sep(num: &str) -> String {
385385 let num_chars: Vec<_> = num.chars().collect();
386 let mut num_start_index = if num_chars.get(0) == Some(&'-') { 1 } else { 0 };
386 let mut num_start_index = if num_chars.first() == Some(&'-') { 1 } else { 0 };
387387 let chunk_size = match num[num_start_index..].as_bytes() {
388388 [b'0', b'b' | b'x', ..] => {
389389 num_start_index += 2;
src/librustdoc/config.rs+3-3
......@@ -360,7 +360,7 @@ impl Options {
360360 return None;
361361 }
362362
363 if rustc_driver::describe_flag_categories(early_dcx, &matches) {
363 if rustc_driver::describe_flag_categories(early_dcx, matches) {
364364 return None;
365365 }
366366
......@@ -374,7 +374,7 @@ impl Options {
374374 let codegen_options = CodegenOptions::build(early_dcx, matches);
375375 let unstable_opts = UnstableOptions::build(early_dcx, matches);
376376
377 let remap_path_prefix = match parse_remap_path_prefix(&matches) {
377 let remap_path_prefix = match parse_remap_path_prefix(matches) {
378378 Ok(prefix_mappings) => prefix_mappings,
379379 Err(err) => {
380380 early_dcx.early_fatal(err);
......@@ -486,7 +486,7 @@ impl Options {
486486 _ => dcx.fatal("too many file operands"),
487487 }
488488 };
489 let input = make_input(early_dcx, &input);
489 let input = make_input(early_dcx, input);
490490
491491 let externs = parse_externs(early_dcx, matches, &unstable_opts);
492492 let extern_html_root_urls = match parse_extern_html_roots(matches) {
src/librustdoc/core.rs+1-1
......@@ -288,7 +288,7 @@ pub(crate) fn create_config(
288288 let hir = tcx.hir();
289289 let body = hir.body_owned_by(def_id);
290290 debug!("visiting body for {def_id:?}");
291 EmitIgnoredResolutionErrors::new(tcx).visit_body(&body);
291 EmitIgnoredResolutionErrors::new(tcx).visit_body(body);
292292 (rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id)
293293 };
294294 }),
src/librustdoc/doctest.rs+8-8
......@@ -272,7 +272,7 @@ pub(crate) fn run_tests(
272272 let mut tests_runner = runner::DocTestRunner::new();
273273
274274 let rustdoc_test_options = IndividualTestOptions::new(
275 &rustdoc_options,
275 rustdoc_options,
276276 &Some(format!("merged_doctest_{edition}")),
277277 PathBuf::from(format!("doctest_{edition}.rs")),
278278 );
......@@ -307,7 +307,7 @@ pub(crate) fn run_tests(
307307 doctest,
308308 scraped_test,
309309 opts.clone(),
310 Arc::clone(&rustdoc_options),
310 Arc::clone(rustdoc_options),
311311 unused_extern_reports.clone(),
312312 ));
313313 }
......@@ -316,7 +316,7 @@ pub(crate) fn run_tests(
316316 // We need to call `test_main` even if there is no doctest to run to get the output
317317 // `running 0 tests...`.
318318 if ran_edition_tests == 0 || !standalone_tests.is_empty() {
319 standalone_tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
319 standalone_tests.sort_by(|a, b| a.desc.name.as_slice().cmp(b.desc.name.as_slice()));
320320 test::test_main(&test_args, standalone_tests, None);
321321 }
322322 if nb_errors != 0 {
......@@ -421,7 +421,7 @@ fn add_exe_suffix(input: String, target: &TargetTriple) -> String {
421421}
422422
423423fn wrapped_rustc_command(rustc_wrappers: &[PathBuf], rustc_binary: &Path) -> Command {
424 let mut args = rustc_wrappers.iter().map(PathBuf::as_path).chain([rustc_binary].into_iter());
424 let mut args = rustc_wrappers.iter().map(PathBuf::as_path).chain([rustc_binary]);
425425
426426 let exe = args.next().expect("unable to create rustc command");
427427 let mut command = Command::new(exe);
......@@ -452,7 +452,7 @@ pub(crate) struct RunnableDocTest {
452452
453453impl RunnableDocTest {
454454 fn path_for_merged_doctest(&self) -> PathBuf {
455 self.test_opts.outdir.path().join(&format!("doctest_{}.rs", self.edition))
455 self.test_opts.outdir.path().join(format!("doctest_{}.rs", self.edition))
456456 }
457457}
458458
......@@ -477,13 +477,13 @@ fn run_test(
477477 .unwrap_or_else(|| rustc_interface::util::rustc_path().expect("found rustc"));
478478 let mut compiler = wrapped_rustc_command(&rustdoc_options.test_builder_wrappers, rustc_binary);
479479
480 compiler.arg(&format!("@{}", doctest.global_opts.args_file.display()));
480 compiler.arg(format!("@{}", doctest.global_opts.args_file.display()));
481481
482482 if let Some(sysroot) = &rustdoc_options.maybe_sysroot {
483483 compiler.arg(format!("--sysroot={}", sysroot.display()));
484484 }
485485
486 compiler.arg("--edition").arg(&doctest.edition.to_string());
486 compiler.arg("--edition").arg(doctest.edition.to_string());
487487 if !doctest.is_multiple_tests {
488488 // Setting these environment variables is unneeded if this is a merged doctest.
489489 compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", &doctest.test_opts.path);
......@@ -692,7 +692,7 @@ impl IndividualTestOptions {
692692 fn new(options: &RustdocOptions, test_id: &Option<String>, test_path: PathBuf) -> Self {
693693 let outdir = if let Some(ref path) = options.persist_doctests {
694694 let mut path = path.clone();
695 path.push(&test_id.as_deref().unwrap_or_else(|| "<doctest>"));
695 path.push(&test_id.as_deref().unwrap_or("<doctest>"));
696696
697697 if let Err(err) = std::fs::create_dir_all(&path) {
698698 eprintln!("Couldn't create directory for doctest executables: {err}");
src/librustdoc/doctest/make.rs+1-1
......@@ -311,7 +311,7 @@ fn parse_source(
311311 }
312312 ast::ItemKind::ExternCrate(original) => {
313313 if !info.found_extern_crate
314 && let Some(ref crate_name) = crate_name
314 && let Some(crate_name) = crate_name
315315 {
316316 info.found_extern_crate = match original {
317317 Some(name) => name.as_str() == *crate_name,
src/librustdoc/doctest/markdown.rs+1-1
......@@ -73,7 +73,7 @@ pub(crate) fn test(options: Options) -> Result<(), String> {
7373 use rustc_session::config::Input;
7474 let input_str = match &options.input {
7575 Input::File(path) => {
76 read_to_string(&path).map_err(|err| format!("{}: {err}", path.display()))?
76 read_to_string(path).map_err(|err| format!("{}: {err}", path.display()))?
7777 }
7878 Input::Str { name: _, input } => input.clone(),
7979 };
src/librustdoc/doctest/runner.rs+4-2
......@@ -98,8 +98,10 @@ impl DocTestRunner {
9898
9999 code.push_str("extern crate test;\n");
100100
101 let test_args =
102 test_args.iter().map(|arg| format!("{arg:?}.to_string(),")).collect::<String>();
101 let test_args = test_args.iter().fold(String::new(), |mut x, arg| {
102 write!(x, "{arg:?}.to_string(),").unwrap();
103 x
104 });
103105 write!(
104106 code,
105107 "\
src/librustdoc/error.rs+1-1
......@@ -39,7 +39,7 @@ macro_rules! try_none {
3939 match $e {
4040 Some(e) => e,
4141 None => {
42 return Err(<crate::error::Error as crate::docfs::PathError>::new(
42 return Err(<$crate::error::Error as $crate::docfs::PathError>::new(
4343 io::Error::new(io::ErrorKind::Other, "not found"),
4444 $file,
4545 ));
src/librustdoc/formats/cache.rs+6-6
......@@ -274,7 +274,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
274274 None
275275 };
276276 if let Some(name) = search_name {
277 add_item_to_search_index(self.tcx, &mut self.cache, &item, name)
277 add_item_to_search_index(self.tcx, self.cache, &item, name)
278278 }
279279
280280 // Keep track of the fully qualified path for this item.
......@@ -452,7 +452,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
452452 // or if item is tuple struct/variant field (name is a number -> not useful for search).
453453 if cache.stripped_mod
454454 || item.type_() == ItemType::StructField
455 && name.as_str().chars().all(|c| c.is_digit(10))
455 && name.as_str().chars().all(|c| c.is_ascii_digit())
456456 {
457457 return;
458458 }
......@@ -463,7 +463,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
463463 }
464464 clean::MethodItem(..) | clean::AssocConstItem(..) | clean::AssocTypeItem(..) => {
465465 let last = cache.parent_stack.last().expect("parent_stack is empty 2");
466 let parent_did = match &*last {
466 let parent_did = match last {
467467 // impl Trait for &T { fn method(self); }
468468 //
469469 // When generating a function index with the above shape, we want it
......@@ -471,9 +471,9 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
471471 // show up as `T::method`, rather than `reference::method`, in the search
472472 // results page.
473473 ParentStackItem::Impl { for_: clean::Type::BorrowedRef { type_, .. }, .. } => {
474 type_.def_id(&cache)
474 type_.def_id(cache)
475475 }
476 ParentStackItem::Impl { for_, .. } => for_.def_id(&cache),
476 ParentStackItem::Impl { for_, .. } => for_.def_id(cache),
477477 ParentStackItem::Type(item_id) => item_id.as_def_id(),
478478 };
479479 let Some(parent_did) = parent_did else { return };
......@@ -538,7 +538,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
538538 None
539539 };
540540 let search_type = get_function_type_for_search(
541 &item,
541 item,
542542 tcx,
543543 clean_impl_generics(cache.parent_stack.last()).as_ref(),
544544 parent_did,
src/librustdoc/html/format.rs+9-10
......@@ -633,7 +633,7 @@ fn generate_item_def_id_path(
633633 let module_fqp = to_module_fqp(shortty, &fqp);
634634 let mut is_remote = false;
635635
636 let url_parts = url_parts(cx.cache(), def_id, &module_fqp, &cx.current, &mut is_remote)?;
636 let url_parts = url_parts(cx.cache(), def_id, module_fqp, &cx.current, &mut is_remote)?;
637637 let (url_parts, shortty, fqp) = make_href(root_path, shortty, url_parts, &fqp, is_remote)?;
638638 if def_id == original_def_id {
639639 return Ok((url_parts, shortty, fqp));
......@@ -811,7 +811,7 @@ pub(crate) fn link_tooltip(did: DefId, fragment: &Option<UrlFragment>, cx: &Cont
811811 // primitives are documented in a crate, but not actually part of it
812812 &fqp[fqp.len() - 1..]
813813 } else {
814 &fqp
814 fqp
815815 };
816816 if let &Some(UrlFragment::Item(id)) = fragment {
817817 write!(buf, "{} ", cx.tcx().def_descr(id));
......@@ -820,7 +820,7 @@ pub(crate) fn link_tooltip(did: DefId, fragment: &Option<UrlFragment>, cx: &Cont
820820 }
821821 write!(buf, "{}", cx.tcx().item_name(id));
822822 } else if !fqp.is_empty() {
823 let mut fqp_it = fqp.into_iter();
823 let mut fqp_it = fqp.iter();
824824 write!(buf, "{shortty} {}", fqp_it.next().unwrap());
825825 for component in fqp_it {
826826 write!(buf, "::{component}");
......@@ -830,13 +830,13 @@ pub(crate) fn link_tooltip(did: DefId, fragment: &Option<UrlFragment>, cx: &Cont
830830}
831831
832832/// Used to render a [`clean::Path`].
833fn resolved_path<'cx>(
833fn resolved_path(
834834 w: &mut fmt::Formatter<'_>,
835835 did: DefId,
836836 path: &clean::Path,
837837 print_all: bool,
838838 use_absolute: bool,
839 cx: &'cx Context<'_>,
839 cx: &Context<'_>,
840840) -> fmt::Result {
841841 let last = path.segments.last().unwrap();
842842
......@@ -996,11 +996,11 @@ pub(crate) fn anchor<'a, 'cx: 'a>(
996996 })
997997}
998998
999fn fmt_type<'cx>(
999fn fmt_type(
10001000 t: &clean::Type,
10011001 f: &mut fmt::Formatter<'_>,
10021002 use_absolute: bool,
1003 cx: &'cx Context<'_>,
1003 cx: &Context<'_>,
10041004) -> fmt::Result {
10051005 trace!("fmt_type(t = {t:?})");
10061006
......@@ -1493,9 +1493,8 @@ impl clean::FnDecl {
14931493 }
14941494 clean::BorrowedRef { lifetime, mutability, type_: box clean::SelfTy } => {
14951495 write!(f, "{amp}")?;
1496 match lifetime {
1497 Some(lt) => write!(f, "{lt} ", lt = lt.print())?,
1498 None => {}
1496 if let Some(lt) = lifetime {
1497 write!(f, "{lt} ", lt = lt.print())?;
14991498 }
15001499 write!(f, "{mutability}self", mutability = mutability.print_with_space())?;
15011500 }
tests/codegen/cast-target-abi.rs+2-2
......@@ -1,7 +1,7 @@
11// ignore-tidy-linelength
22//@ revisions:aarch64 loongarch64 powerpc64 sparc64 x86_64
3// FIXME: Add `-Cllvm-args=--lint-abort-on-error` after LLVM 19
4//@ compile-flags: -O -C no-prepopulate-passes -C passes=lint
3//@ min-llvm-version: 19
4//@ compile-flags: -O -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error
55
66//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
77//@[aarch64] needs-llvm-components: arm
tests/codegen/cffi/ffi-out-of-bounds-loads.rs+2-1
......@@ -1,5 +1,6 @@
11//@ revisions: linux apple
2//@ compile-flags: -C opt-level=0 -C no-prepopulate-passes -C passes=lint
2//@ min-llvm-version: 19
3//@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error
34
45//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
56//@[linux] needs-llvm-components: x86
tests/codegen/sanitizer/riscv64-shadow-call-stack.rs created+17
......@@ -0,0 +1,17 @@
1//@ compile-flags: --target riscv64imac-unknown-none-elf -Zsanitizer=shadow-call-stack
2//@ needs-llvm-components: riscv
3
4#![allow(internal_features)]
5#![crate_type = "rlib"]
6#![feature(no_core, lang_items)]
7#![no_core]
8
9#[lang = "sized"]
10trait Sized {}
11
12// CHECK: ; Function Attrs:{{.*}}shadowcallstack
13// CHECK: define dso_local void @foo() unnamed_addr #0
14#[no_mangle]
15pub fn foo() {}
16
17// CHECK: attributes #0 = {{.*}}shadowcallstack{{.*}}
tests/run-make/dos-device-input/rmake.rs+2-4
......@@ -1,13 +1,11 @@
11//@ only-windows
22// Reason: dos devices are a Windows thing
33
4use std::path::Path;
5
6use run_make_support::{rustc, static_lib_name};
4use run_make_support::{path, rustc, static_lib_name};
75
86fn main() {
97 rustc().input(r"\\.\NUL").crate_type("staticlib").run();
108 rustc().input(r"\\?\NUL").crate_type("staticlib").run();
119
12 assert!(Path::new(&static_lib_name("rust_out")).exists());
10 assert!(path(&static_lib_name("rust_out")).exists());
1311}
tests/run-make/emit-shared-files/rmake.rs+21-23
......@@ -5,9 +5,7 @@
55// `all-shared` should only emit files that can be shared between crates.
66// See https://github.com/rust-lang/rust/pull/83478
77
8use std::path::Path;
9
10use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files};
8use run_make_support::{has_extension, has_prefix, path, rustdoc, shallow_find_files};
119
1210fn main() {
1311 rustdoc()
......@@ -19,18 +17,18 @@ fn main() {
1917 .args(&["--extend-css", "z.css"])
2018 .input("x.rs")
2119 .run();
22 assert!(Path::new("invocation-only/search-index-xxx.js").exists());
23 assert!(Path::new("invocation-only/crates-xxx.js").exists());
24 assert!(Path::new("invocation-only/settings.html").exists());
25 assert!(Path::new("invocation-only/x/all.html").exists());
26 assert!(Path::new("invocation-only/x/index.html").exists());
27 assert!(Path::new("invocation-only/theme-xxx.css").exists()); // generated from z.css
28 assert!(!Path::new("invocation-only/storage-xxx.js").exists());
29 assert!(!Path::new("invocation-only/SourceSerif4-It.ttf.woff2").exists());
20 assert!(path("invocation-only/search-index-xxx.js").exists());
21 assert!(path("invocation-only/crates-xxx.js").exists());
22 assert!(path("invocation-only/settings.html").exists());
23 assert!(path("invocation-only/x/all.html").exists());
24 assert!(path("invocation-only/x/index.html").exists());
25 assert!(path("invocation-only/theme-xxx.css").exists()); // generated from z.css
26 assert!(!path("invocation-only/storage-xxx.js").exists());
27 assert!(!path("invocation-only/SourceSerif4-It.ttf.woff2").exists());
3028 // FIXME: this probably shouldn't have a suffix
31 assert!(Path::new("invocation-only/y-xxx.css").exists());
29 assert!(path("invocation-only/y-xxx.css").exists());
3230 // FIXME: this is technically incorrect (see `write_shared`)
33 assert!(!Path::new("invocation-only/main-xxx.js").exists());
31 assert!(!path("invocation-only/main-xxx.js").exists());
3432
3533 rustdoc()
3634 .arg("-Zunstable-options")
......@@ -61,10 +59,10 @@ fn main() {
6159 .len(),
6260 1
6361 );
64 assert!(!Path::new("toolchain-only/search-index-xxx.js").exists());
65 assert!(!Path::new("toolchain-only/x/index.html").exists());
66 assert!(!Path::new("toolchain-only/theme.css").exists());
67 assert!(!Path::new("toolchain-only/y-xxx.css").exists());
62 assert!(!path("toolchain-only/search-index-xxx.js").exists());
63 assert!(!path("toolchain-only/x/index.html").exists());
64 assert!(!path("toolchain-only/theme.css").exists());
65 assert!(!path("toolchain-only/y-xxx.css").exists());
6866
6967 rustdoc()
7068 .arg("-Zunstable-options")
......@@ -88,11 +86,11 @@ fn main() {
8886 .len(),
8987 1
9088 );
91 assert!(!Path::new("all-shared/search-index-xxx.js").exists());
92 assert!(!Path::new("all-shared/settings.html").exists());
93 assert!(!Path::new("all-shared/x").exists());
94 assert!(!Path::new("all-shared/src").exists());
95 assert!(!Path::new("all-shared/theme.css").exists());
89 assert!(!path("all-shared/search-index-xxx.js").exists());
90 assert!(!path("all-shared/settings.html").exists());
91 assert!(!path("all-shared/x").exists());
92 assert!(!path("all-shared/src").exists());
93 assert!(!path("all-shared/theme.css").exists());
9694 assert_eq!(
9795 shallow_find_files("all-shared/static.files", |path| {
9896 has_prefix(path, "main-") && has_extension(path, "js")
......@@ -100,5 +98,5 @@ fn main() {
10098 .len(),
10199 1
102100 );
103 assert!(!Path::new("all-shared/y-xxx.css").exists());
101 assert!(!path("all-shared/y-xxx.css").exists());
104102}
tests/run-make/libtest-thread-limit/rmake.rs+3
......@@ -11,6 +11,9 @@
1111// Reason: thread limit modification
1212//@ ignore-cross-compile
1313// Reason: this test fails armhf-gnu, reasons unknown
14//@ needs-unwind
15// Reason: this should be ignored in cg_clif (Cranelift) CI and anywhere
16// else that uses panic=abort.
1417
1518use std::ffi::{self, CStr, CString};
1619use std::path::PathBuf;
tests/run-make/manual-crate-name/rmake.rs+2-4
......@@ -1,8 +1,6 @@
1use std::path::Path;
2
3use run_make_support::rustc;
1use run_make_support::{path, rustc};
42
53fn main() {
64 rustc().input("bar.rs").crate_name("foo").run();
7 assert!(Path::new("libfoo.rlib").is_file());
5 assert!(path("libfoo.rlib").is_file());
86}
tests/run-make/pretty-print-with-dep-file/rmake.rs+2-4
......@@ -5,14 +5,12 @@
55// does not get an unexpected dep-info file.
66// See https://github.com/rust-lang/rust/issues/112898
77
8use std::path::Path;
9
10use run_make_support::{invalid_utf8_contains, rfs, rustc};
8use run_make_support::{invalid_utf8_contains, path, rfs, rustc};
119
1210fn main() {
1311 rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run();
1412 invalid_utf8_contains("with-dep.d", "with-dep.rs");
1513 rfs::remove_file("with-dep.d");
1614 rustc().emit("dep-info").arg("-Zunpretty=normal").input("with-dep.rs").run();
17 assert!(!Path::new("with-dep.d").exists());
15 assert!(!path("with-dep.d").exists());
1816}
tests/run-make/profile/rmake.rs+4-6
......@@ -8,16 +8,14 @@
88//@ ignore-cross-compile
99//@ needs-profiler-support
1010
11use std::path::Path;
12
13use run_make_support::{run, rustc};
11use run_make_support::{path, run, rustc};
1412
1513fn main() {
1614 rustc().arg("-g").arg("-Zprofile").input("test.rs").run();
1715 run("test");
18 assert!(Path::new("test.gcno").exists(), "no .gcno file");
19 assert!(Path::new("test.gcda").exists(), "no .gcda file");
16 assert!(path("test.gcno").exists(), "no .gcno file");
17 assert!(path("test.gcda").exists(), "no .gcda file");
2018 rustc().arg("-g").arg("-Zprofile").arg("-Zprofile-emit=abc/abc.gcda").input("test.rs").run();
2119 run("test");
22 assert!(Path::new("abc/abc.gcda").exists(), "gcda file not emitted to defined path");
20 assert!(path("abc/abc.gcda").exists(), "gcda file not emitted to defined path");
2321}
tests/run-make/reset-codegen-1/rmake.rs+4-6
......@@ -7,9 +7,7 @@
77
88//@ ignore-cross-compile
99
10use std::path::Path;
11
12use run_make_support::{bin_name, rustc};
10use run_make_support::{bin_name, path, rustc};
1311
1412fn compile(output_file: &str, emit: Option<&str>) {
1513 let mut rustc = rustc();
......@@ -34,10 +32,10 @@ fn main() {
3432 // In the None case, bin_name is required for successful Windows compilation.
3533 let output_file = &bin_name(output_file);
3634 compile(output_file, emit);
37 assert!(Path::new(output_file).is_file());
35 assert!(path(output_file).is_file());
3836 }
3937
4038 compile("multi-output", Some("asm,obj"));
41 assert!(Path::new("multi-output.s").is_file());
42 assert!(Path::new("multi-output.o").is_file());
39 assert!(path("multi-output.s").is_file());
40 assert!(path("multi-output.o").is_file());
4341}
tests/run-make/rustdoc-determinism/rmake.rs+3-5
......@@ -1,16 +1,14 @@
11// Assert that the search index is generated deterministically, regardless of the
22// order that crates are documented in.
33
4use std::path::Path;
5
6use run_make_support::{diff, rustdoc};
4use run_make_support::{diff, path, rustdoc};
75
86fn main() {
9 let foo_first = Path::new("foo_first");
7 let foo_first = path("foo_first");
108 rustdoc().input("foo.rs").out_dir(&foo_first).run();
119 rustdoc().input("bar.rs").out_dir(&foo_first).run();
1210
13 let bar_first = Path::new("bar_first");
11 let bar_first = path("bar_first");
1412 rustdoc().input("bar.rs").out_dir(&bar_first).run();
1513 rustdoc().input("foo.rs").out_dir(&bar_first).run();
1614
tests/run-make/rustdoc-output-path/rmake.rs+2-4
......@@ -1,11 +1,9 @@
11// Checks that if the output folder doesn't exist, rustdoc will create it.
22
3use std::path::Path;
4
5use run_make_support::rustdoc;
3use run_make_support::{path, rustdoc};
64
75fn main() {
8 let out_dir = Path::new("foo/bar/doc");
6 let out_dir = path("foo/bar/doc");
97 rustdoc().input("foo.rs").out_dir(&out_dir).run();
108 assert!(out_dir.exists());
119}
tests/ui/cfg/disallowed-cli-cfgs.fmt_debug_.stderr created+8
......@@ -0,0 +1,8 @@
1error: 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
7error: aborting due to 1 previous error
8
tests/ui/cfg/disallowed-cli-cfgs.rs+2
......@@ -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
3537fn main() {}
tests/ui/check-cfg/allow-same-level.stderr+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `FALSE`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo`
44LL | #[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+1-1
......@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525LL | #[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+1-1
......@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `linux`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `target_architecture`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key`
44LL | #[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+1-1
......@@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu`
4444LL | #[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+1-1
......@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `crossbeam_loom`
44LL | #[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+1-1
......@@ -18,7 +18,7 @@ warning: unexpected `cfg` condition name: `features`
1818LL | #[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+3
......@@ -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+39-30
......@@ -1,5 +1,5 @@
11warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
2 --> $DIR/well-known-values.rs:28:5
2 --> $DIR/well-known-values.rs:29:5
33 |
44LL | clippy = "_UNEXPECTED_VALUE",
55 | ^^^^^^----------------------
......@@ -11,7 +11,7 @@ LL | clippy = "_UNEXPECTED_VALUE",
1111 = note: `#[warn(unexpected_cfgs)]` on by default
1212
1313warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
14 --> $DIR/well-known-values.rs:30:5
14 --> $DIR/well-known-values.rs:31:5
1515 |
1616LL | 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
2424warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
25 --> $DIR/well-known-values.rs:32:5
25 --> $DIR/well-known-values.rs:33:5
2626 |
2727LL | 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
3535warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
36 --> $DIR/well-known-values.rs:34:5
36 --> $DIR/well-known-values.rs:35:5
3737 |
3838LL | 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
4646warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
47 --> $DIR/well-known-values.rs:36:5
47 --> $DIR/well-known-values.rs:37:5
48 |
49LL | 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
55warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
56 --> $DIR/well-known-values.rs:39:5
4857 |
4958LL | 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
5766warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
58 --> $DIR/well-known-values.rs:38:5
67 --> $DIR/well-known-values.rs:41:5
5968 |
6069LL | 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
6877warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
69 --> $DIR/well-known-values.rs:40:5
78 --> $DIR/well-known-values.rs:43:5
7079 |
7180LL | 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
7786warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
78 --> $DIR/well-known-values.rs:42:5
87 --> $DIR/well-known-values.rs:45:5
7988 |
8089LL | 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
8897warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
89 --> $DIR/well-known-values.rs:44:5
98 --> $DIR/well-known-values.rs:47:5
9099 |
91100LL | 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
97106warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
98 --> $DIR/well-known-values.rs:46:5
107 --> $DIR/well-known-values.rs:49:5
99108 |
100109LL | 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
108117warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
109 --> $DIR/well-known-values.rs:48:5
118 --> $DIR/well-known-values.rs:51:5
110119 |
111120LL | 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
117126warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
118 --> $DIR/well-known-values.rs:50:5
127 --> $DIR/well-known-values.rs:53:5
119128 |
120129LL | 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
126135warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
127 --> $DIR/well-known-values.rs:52:5
136 --> $DIR/well-known-values.rs:55:5
128137 |
129138LL | 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
135144warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
136 --> $DIR/well-known-values.rs:54:5
145 --> $DIR/well-known-values.rs:57:5
137146 |
138147LL | 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
144153warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
145 --> $DIR/well-known-values.rs:56:5
154 --> $DIR/well-known-values.rs:59:5
146155 |
147156LL | 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
153162warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
154 --> $DIR/well-known-values.rs:58:5
163 --> $DIR/well-known-values.rs:61:5
155164 |
156165LL | 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
162171warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
163 --> $DIR/well-known-values.rs:60:5
172 --> $DIR/well-known-values.rs:63:5
164173 |
165174LL | 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
171180warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
172 --> $DIR/well-known-values.rs:62:5
181 --> $DIR/well-known-values.rs:65:5
173182 |
174183LL | 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
180189warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
181 --> $DIR/well-known-values.rs:64:5
190 --> $DIR/well-known-values.rs:67:5
182191 |
183192LL | 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
189198warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
190 --> $DIR/well-known-values.rs:66:5
199 --> $DIR/well-known-values.rs:69:5
191200 |
192201LL | 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
198207warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
199 --> $DIR/well-known-values.rs:68:5
208 --> $DIR/well-known-values.rs:71:5
200209 |
201210LL | 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
207216warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
208 --> $DIR/well-known-values.rs:70:5
217 --> $DIR/well-known-values.rs:73:5
209218 |
210219LL | 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
216225warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
217 --> $DIR/well-known-values.rs:72:5
226 --> $DIR/well-known-values.rs:75:5
218227 |
219228LL | 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
227236warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
228 --> $DIR/well-known-values.rs:74:5
237 --> $DIR/well-known-values.rs:77:5
229238 |
230239LL | 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
236245warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
237 --> $DIR/well-known-values.rs:76:5
246 --> $DIR/well-known-values.rs:79:5
238247 |
239248LL | 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
247256warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
248 --> $DIR/well-known-values.rs:78:5
257 --> $DIR/well-known-values.rs:81:5
249258 |
250259LL | 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
258267warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
259 --> $DIR/well-known-values.rs:80:5
268 --> $DIR/well-known-values.rs:83:5
260269 |
261270LL | 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
269278warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
270 --> $DIR/well-known-values.rs:82:5
279 --> $DIR/well-known-values.rs:85:5
271280 |
272281LL | 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
280289warning: unexpected `cfg` condition value: `linuz`
281 --> $DIR/well-known-values.rs:88:7
290 --> $DIR/well-known-values.rs:91:7
282291 |
283292LL | #[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
291warning: 29 warnings emitted
300warning: 30 warnings emitted
292301
tests/ui/feature-gates/feature-gate-fmt-debug.rs created+5
......@@ -0,0 +1,5 @@
1#[cfg(fmt_debug = "full")]
2//~^ ERROR is experimental
3fn main() {
4
5}
tests/ui/feature-gates/feature-gate-fmt-debug.stderr created+13
......@@ -0,0 +1,13 @@
1error[E0658]: `cfg(fmt_debug)` is experimental and subject to change
2 --> $DIR/feature-gate-fmt-debug.rs:1:7
3 |
4LL | #[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
11error: aborting due to 1 previous error
12
13For more information about this error, try `rustc --explain E0658`.
tests/ui/fmt/fmt_debug/full.rs created+15
......@@ -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)]
8struct Foo {
9 bar: u32,
10}
11
12fn 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 created+4
......@@ -0,0 +1,4 @@
1//@ compile-flags: -Zfmt-debug=invalid-value
2//@ failure-status: 1
3fn main() {
4}
tests/ui/fmt/fmt_debug/invalid.stderr created+2
......@@ -0,0 +1,2 @@
1error: incorrect value `invalid-value` for unstable option `fmt-debug` - either `full`, `shallow`, or `none` was expected
2
tests/ui/fmt/fmt_debug/none.rs created+37
......@@ -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)]
8struct Foo {
9 bar: u32,
10}
11
12#[derive(Debug)]
13enum Baz {
14 Quz,
15}
16
17#[cfg(fmt_debug = "full")]
18compile_error!("nope");
19
20#[cfg(fmt_debug = "none")]
21struct Custom;
22
23impl 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
29fn 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 created+33
......@@ -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)]
8struct Foo {
9 bar: u32,
10 bomb: Bomb,
11}
12
13#[derive(Debug)]
14enum Baz {
15 Quz,
16}
17
18struct Bomb;
19
20impl std::fmt::Debug for Bomb {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 panic!()
23 }
24}
25
26fn 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}