Skip to content

Commit 61b091b

Browse files
authored
Rollup merge of #69541 - dotdash:format, r=Mark-Simulacrum
Remove unneeded calls to format!()
2 parents b95945c + c1de0b1 commit 61b091b

File tree

15 files changed

+34
-53
lines changed

15 files changed

+34
-53
lines changed

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl RustcDefaultCalls {
601601
});
602602
compiler.codegen_backend().link(&sess, Box::new(codegen_results), &outputs)
603603
} else {
604-
sess.fatal(&format!("rlink must be a file"))
604+
sess.fatal("rlink must be a file")
605605
}
606606
}
607607

src/librustc_expand/expand.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1668,10 +1668,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
16681668
}
16691669
}
16701670
} else {
1671-
let mut err = self.cx.struct_span_err(
1672-
it.span(),
1673-
&format!("expected path to external documentation"),
1674-
);
1671+
let mut err = self
1672+
.cx
1673+
.struct_span_err(it.span(), "expected path to external documentation");
16751674

16761675
// Check if the user erroneously used `doc(include(...))` syntax.
16771676
let literal = it.meta_item_list().and_then(|list| {

src/librustc_incremental/assert_module_sources.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ impl AssertModuleSource<'tcx> {
8181
if !self.tcx.sess.opts.debugging_opts.query_dep_graph {
8282
self.tcx.sess.span_fatal(
8383
attr.span,
84-
&format!(
85-
"found CGU-reuse attribute but `-Zquery-dep-graph` \
86-
was not specified"
87-
),
84+
"found CGU-reuse attribute but `-Zquery-dep-graph` was not specified",
8885
);
8986
}
9087

src/librustc_incremental/persist/dirty_clean.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,7 @@ impl FindAllAttrs<'tcx> {
537537
if !checked_attrs.contains(&attr.id) {
538538
self.tcx.sess.span_err(
539539
attr.span,
540-
&format!(
541-
"found unchecked \
542-
`#[rustc_dirty]` / `#[rustc_clean]` attribute"
543-
),
540+
"found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute",
544541
);
545542
}
546543
}

src/librustc_infer/traits/coherence.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ pub struct OverlapResult<'tcx> {
3939
}
4040

4141
pub fn add_placeholder_note(err: &mut rustc_errors::DiagnosticBuilder<'_>) {
42-
err.note(&format!(
42+
err.note(
4343
"this behavior recently changed as a result of a bug fix; \
44-
see rust-lang/rust#56105 for details"
45-
));
44+
see rust-lang/rust#56105 for details",
45+
);
4646
}
4747

4848
/// If there are types that satisfy both impls, invokes `on_overlap`

src/librustc_infer/traits/error_reporting/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
935935

936936
// Already reported in the query.
937937
ConstEvalFailure(ErrorHandled::Reported) => {
938-
self.tcx
939-
.sess
940-
.delay_span_bug(span, &format!("constant in type had an ignored error"));
938+
self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error");
941939
return;
942940
}
943941

src/librustc_metadata/creader.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,7 @@ impl<'a> CrateLoader<'a> {
680680

681681
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
682682
if !data.is_profiler_runtime() {
683-
self.sess.err(&format!(
684-
"the crate `profiler_builtins` is not \
685-
a profiler runtime"
686-
));
683+
self.sess.err("the crate `profiler_builtins` is not a profiler runtime");
687684
}
688685
}
689686
}

src/librustc_mir/transform/check_consts/ops.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ impl NonConstOp for Downcast {
6565
pub struct FnCallIndirect;
6666
impl NonConstOp for FnCallIndirect {
6767
fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
68-
let mut err = item
69-
.tcx
70-
.sess
71-
.struct_span_err(span, &format!("function pointers are not allowed in const fn"));
68+
let mut err =
69+
item.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn");
7270
err.emit();
7371
}
7472
}

src/librustc_parse/parser/generics.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,12 @@ impl<'a> Parser<'a> {
121121
.span_label(attrs[0].span, "attributes must go before parameters")
122122
.emit();
123123
} else {
124-
self.struct_span_err(
125-
attrs[0].span,
126-
&format!("attribute without generic parameters"),
127-
)
128-
.span_label(
129-
attrs[0].span,
130-
"attributes are only permitted when preceding parameters",
131-
)
132-
.emit();
124+
self.struct_span_err(attrs[0].span, "attribute without generic parameters")
125+
.span_label(
126+
attrs[0].span,
127+
"attributes are only permitted when preceding parameters",
128+
)
129+
.emit();
133130
}
134131
}
135132
break;

src/librustc_passes/weak_lang_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
6464
for (name, &item) in WEAK_ITEMS_REFS.iter() {
6565
if missing.contains(&item) && !whitelisted(tcx, item) && items.require(item).is_err() {
6666
if item == lang_items::PanicImplLangItem {
67-
tcx.sess.err(&format!("`#[panic_handler]` function required, but not found"));
67+
tcx.sess.err("`#[panic_handler]` function required, but not found");
6868
} else if item == lang_items::OomLangItem {
69-
tcx.sess.err(&format!("`#[alloc_error_handler]` function required, but not found"));
69+
tcx.sess.err("`#[alloc_error_handler]` function required, but not found");
7070
} else {
7171
tcx.sess.err(&format!("language item required, but not found: `{}`", name));
7272
}

src/librustc_resolve/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a> Resolver<'a> {
143143
if has_generic_params == HasGenericParams::Yes {
144144
// Try to retrieve the span of the function signature and generate a new
145145
// message with a local type or const parameter.
146-
let sugg_msg = &format!("try using a local generic parameter instead");
146+
let sugg_msg = "try using a local generic parameter instead";
147147
if let Some((sugg_span, snippet)) = sm.generate_local_type_param_snippet(span) {
148148
// Suggest the modification to the user
149149
err.span_suggestion(
@@ -158,7 +158,7 @@ impl<'a> Resolver<'a> {
158158
format!("try adding a local generic parameter in this method instead"),
159159
);
160160
} else {
161-
err.help(&format!("try using a local generic parameter instead"));
161+
err.help("try using a local generic parameter instead");
162162
}
163163
}
164164

src/librustc_session/config.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1500,10 +1500,8 @@ fn parse_libs(
15001500
{
15011501
early_error(
15021502
error_format,
1503-
&format!(
1504-
"the library kind 'static-nobundle' is only \
1505-
accepted on the nightly compiler"
1506-
),
1503+
"the library kind 'static-nobundle' is only \
1504+
accepted on the nightly compiler",
15071505
);
15081506
}
15091507
let mut name_parts = name.splitn(2, ':');

src/librustc_typeck/astconv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
964964
),
965965
);
966966
}
967-
err.note(&format!(
967+
err.note(
968968
"because of the default `Self` reference, type parameters must be \
969-
specified on object types"
970-
));
969+
specified on object types",
970+
);
971971
err.emit();
972972
}
973973

src/librustc_typeck/coherence/inherent_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
283283
"no base type found for inherent implementation"
284284
)
285285
.span_label(ty.span, "impl requires a base type")
286-
.note(&format!(
286+
.note(
287287
"either implement a trait on it or create a newtype \
288-
to wrap it instead"
289-
))
288+
to wrap it instead",
289+
)
290290
.emit();
291291
return;
292292
}

src/librustc_typeck/collect.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1283,10 +1283,10 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
12831283
param.hir_id,
12841284
param.span,
12851285
|lint| {
1286-
lint.build(&format!(
1286+
lint.build(
12871287
"defaults for type parameters are only allowed in \
1288-
`struct`, `enum`, `type`, or `trait` definitions."
1289-
))
1288+
`struct`, `enum`, `type`, or `trait` definitions.",
1289+
)
12901290
.emit();
12911291
},
12921292
);

0 commit comments

Comments
 (0)