diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index f68ea7e077032..1296d7ad2da8e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -601,7 +601,7 @@ impl RustcDefaultCalls { }); compiler.codegen_backend().link(&sess, Box::new(codegen_results), &outputs) } else { - sess.fatal(&format!("rlink must be a file")) + sess.fatal("rlink must be a file") } } diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index bbea066b048d2..53f439a4789dd 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -1664,10 +1664,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } } } else { - let mut err = self.cx.struct_span_err( - it.span(), - &format!("expected path to external documentation"), - ); + let mut err = self + .cx + .struct_span_err(it.span(), "expected path to external documentation"); // Check if the user erroneously used `doc(include(...))` syntax. let literal = it.meta_item_list().and_then(|list| { diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 70abb38278add..e420613ac9a8c 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -81,10 +81,7 @@ impl AssertModuleSource<'tcx> { if !self.tcx.sess.opts.debugging_opts.query_dep_graph { self.tcx.sess.span_fatal( attr.span, - &format!( - "found CGU-reuse attribute but `-Zquery-dep-graph` \ - was not specified" - ), + "found CGU-reuse attribute but `-Zquery-dep-graph` was not specified", ); } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 1fa57f1ecf26d..f6e2956e5b2fc 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -537,10 +537,7 @@ impl FindAllAttrs<'tcx> { if !checked_attrs.contains(&attr.id) { self.tcx.sess.span_err( attr.span, - &format!( - "found unchecked \ - `#[rustc_dirty]` / `#[rustc_clean]` attribute" - ), + "found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute", ); } } diff --git a/src/librustc_infer/traits/coherence.rs b/src/librustc_infer/traits/coherence.rs index 43c0fbc27e620..5e314a2ffdf5d 100644 --- a/src/librustc_infer/traits/coherence.rs +++ b/src/librustc_infer/traits/coherence.rs @@ -39,10 +39,10 @@ pub struct OverlapResult<'tcx> { } pub fn add_placeholder_note(err: &mut rustc_errors::DiagnosticBuilder<'_>) { - err.note(&format!( + err.note( "this behavior recently changed as a result of a bug fix; \ - see rust-lang/rust#56105 for details" - )); + see rust-lang/rust#56105 for details", + ); } /// If there are types that satisfy both impls, invokes `on_overlap` diff --git a/src/librustc_infer/traits/error_reporting/mod.rs b/src/librustc_infer/traits/error_reporting/mod.rs index 2fc7c17897739..43ee2cbc188ef 100644 --- a/src/librustc_infer/traits/error_reporting/mod.rs +++ b/src/librustc_infer/traits/error_reporting/mod.rs @@ -935,9 +935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // Already reported in the query. ConstEvalFailure(ErrorHandled::Reported) => { - self.tcx - .sess - .delay_span_bug(span, &format!("constant in type had an ignored error")); + self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error"); return; } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 4c4383aa603cb..647224bc8d6b7 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -680,10 +680,7 @@ impl<'a> CrateLoader<'a> { // Sanity check the loaded crate to ensure it is indeed a profiler runtime if !data.is_profiler_runtime() { - self.sess.err(&format!( - "the crate `profiler_builtins` is not \ - a profiler runtime" - )); + self.sess.err("the crate `profiler_builtins` is not a profiler runtime"); } } } diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs index 3263905eadb81..9ba44a4d18e58 100644 --- a/src/librustc_mir/transform/check_consts/ops.rs +++ b/src/librustc_mir/transform/check_consts/ops.rs @@ -65,10 +65,8 @@ impl NonConstOp for Downcast { pub struct FnCallIndirect; impl NonConstOp for FnCallIndirect { fn emit_error(&self, item: &Item<'_, '_>, span: Span) { - let mut err = item - .tcx - .sess - .struct_span_err(span, &format!("function pointers are not allowed in const fn")); + let mut err = + item.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn"); err.emit(); } } diff --git a/src/librustc_parse/parser/generics.rs b/src/librustc_parse/parser/generics.rs index 0984263bb283e..ef01df2ea05b4 100644 --- a/src/librustc_parse/parser/generics.rs +++ b/src/librustc_parse/parser/generics.rs @@ -121,15 +121,12 @@ impl<'a> Parser<'a> { .span_label(attrs[0].span, "attributes must go before parameters") .emit(); } else { - self.struct_span_err( - attrs[0].span, - &format!("attribute without generic parameters"), - ) - .span_label( - attrs[0].span, - "attributes are only permitted when preceding parameters", - ) - .emit(); + self.struct_span_err(attrs[0].span, "attribute without generic parameters") + .span_label( + attrs[0].span, + "attributes are only permitted when preceding parameters", + ) + .emit(); } } break; diff --git a/src/librustc_passes/weak_lang_items.rs b/src/librustc_passes/weak_lang_items.rs index 010712c28ba75..1511742446b6e 100644 --- a/src/librustc_passes/weak_lang_items.rs +++ b/src/librustc_passes/weak_lang_items.rs @@ -64,9 +64,9 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) { for (name, &item) in WEAK_ITEMS_REFS.iter() { if missing.contains(&item) && !whitelisted(tcx, item) && items.require(item).is_err() { if item == lang_items::PanicImplLangItem { - tcx.sess.err(&format!("`#[panic_handler]` function required, but not found")); + tcx.sess.err("`#[panic_handler]` function required, but not found"); } else if item == lang_items::OomLangItem { - tcx.sess.err(&format!("`#[alloc_error_handler]` function required, but not found")); + tcx.sess.err("`#[alloc_error_handler]` function required, but not found"); } else { tcx.sess.err(&format!("language item required, but not found: `{}`", name)); } diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 7c48ccfaddd3a..4c850068441ec 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -179,7 +179,7 @@ impl<'a> Resolver<'a> { if has_generic_params == HasGenericParams::Yes { // Try to retrieve the span of the function signature and generate a new // message with a local type or const parameter. - let sugg_msg = &format!("try using a local generic parameter instead"); + let sugg_msg = "try using a local generic parameter instead"; if let Some((sugg_span, snippet)) = sm.generate_local_type_param_snippet(span) { // Suggest the modification to the user err.span_suggestion( @@ -194,7 +194,7 @@ impl<'a> Resolver<'a> { format!("try adding a local generic parameter in this method instead"), ); } else { - err.help(&format!("try using a local generic parameter instead")); + err.help("try using a local generic parameter instead"); } } diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index a6f9a5fe3e0fa..8392d2b50d22e 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -1500,10 +1500,8 @@ fn parse_libs( { early_error( error_format, - &format!( - "the library kind 'static-nobundle' is only \ - accepted on the nightly compiler" - ), + "the library kind 'static-nobundle' is only \ + accepted on the nightly compiler", ); } let mut name_parts = name.splitn(2, ':'); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 78c05a51e4fbd..6eec03d2e4c8f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -888,10 +888,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ), ); } - err.note(&format!( + err.note( "because of the default `Self` reference, type parameters must be \ - specified on object types" - )); + specified on object types", + ); err.emit(); } diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index d4c89b7e03793..49fa45836e134 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -283,10 +283,10 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { "no base type found for inherent implementation" ) .span_label(ty.span, "impl requires a base type") - .note(&format!( + .note( "either implement a trait on it or create a newtype \ - to wrap it instead" - )) + to wrap it instead", + ) .emit(); return; } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 70586be0d0433..36cd7cf7bff8e 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1282,10 +1282,10 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { param.hir_id, param.span, |lint| { - lint.build(&format!( + lint.build( "defaults for type parameters are only allowed in \ - `struct`, `enum`, `type`, or `trait` definitions." - )) + `struct`, `enum`, `type`, or `trait` definitions.", + ) .emit(); }, );