Remove unneeded calls to format!() · rust-lang/rust@c1de0b1 (original) (raw)

File tree

15 files changed

lines changed

15 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -601,7 +601,7 @@ impl RustcDefaultCalls {
601 601 });
602 602 compiler.codegen_backend().link(&sess, Box::new(codegen_results), &outputs)
603 603 } else {
604 - sess.fatal(&format!("rlink must be a file"))
604 + sess.fatal("rlink must be a file")
605 605 }
606 606 }
607 607
Original file line number Diff line number Diff line change
@@ -1664,10 +1664,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1664 1664 }
1665 1665 }
1666 1666 } else {
1667 -let mut err = self.cx.struct_span_err(
1668 - it.span(),
1669 -&format!("expected path to external documentation"),
1670 -);
1667 +let mut err = self
1668 +.cx
1669 +.struct_span_err(it.span(), "expected path to external documentation");
1671 1670
1672 1671 // Check if the user erroneously used `doc(include(...))` syntax.
1673 1672 let literal = it.meta_item_list().and_then(|list
Original file line number Diff line number Diff line change
@@ -81,10 +81,7 @@ impl AssertModuleSource<'tcx> {
81 81 if !self.tcx.sess.opts.debugging_opts.query_dep_graph {
82 82 self.tcx.sess.span_fatal(
83 83 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",
88 85 );
89 86 }
90 87
Original file line number Diff line number Diff line change
@@ -537,10 +537,7 @@ impl FindAllAttrs<'tcx> {
537 537 if !checked_attrs.contains(&attr.id) {
538 538 self.tcx.sess.span_err(
539 539 attr.span,
540 -&format!(
541 -"found unchecked \
542 - `#[rustc_dirty]` / `#[rustc_clean]` attribute"
543 -),
540 +"found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute",
544 541 );
545 542 }
546 543 }
Original file line number Diff line number Diff line change
@@ -39,10 +39,10 @@ pub struct OverlapResult<'tcx> {
39 39 }
40 40
41 41 pub fn add_placeholder_note(err: &mut rustc_errors::DiagnosticBuilder<'_>) {
42 - err.note(&format!(
42 + err.note(
43 43 "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 +);
46 46 }
47 47
48 48 /// If there are types that satisfy both impls, invokes `on_overlap`
Original file line number Diff line number Diff line change
@@ -935,9 +935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
935 935
936 936 // Already reported in the query.
937 937 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");
941 939 return;
942 940 }
943 941
Original file line number Diff line number Diff line change
@@ -680,10 +680,7 @@ impl<'a> CrateLoader<'a> {
680 680
681 681 // Sanity check the loaded crate to ensure it is indeed a profiler runtime
682 682 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");
687 684 }
688 685 }
689 686 }
Original file line number Diff line number Diff line change
@@ -65,10 +65,8 @@ impl NonConstOp for Downcast {
65 65 pub struct FnCallIndirect;
66 66 impl NonConstOp for FnCallIndirect {
67 67 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");
72 70 err.emit();
73 71 }
74 72 }
Original file line number Diff line number Diff line change
@@ -121,15 +121,12 @@ impl<'a> Parser<'a> {
121 121 .span_label(attrs[0].span, "attributes must go before parameters")
122 122 .emit();
123 123 } 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();
133 130 }
134 131 }
135 132 break;
Original file line number Diff line number Diff line change
@@ -64,9 +64,9 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
64 64 for (name, &item) in WEAK_ITEMS_REFS.iter() {
65 65 if missing.contains(&item) && !whitelisted(tcx, item) && items.require(item).is_err() {
66 66 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");
68 68 } 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");
70 70 } else {
71 71 tcx.sess.err(&format!("language item required, but not found: `{}`", name));
72 72 }
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ impl<'a> Resolver<'a> {
179 179 if has_generic_params == HasGenericParams::Yes {
180 180 // Try to retrieve the span of the function signature and generate a new
181 181 // message with a local type or const parameter.
182 -let sugg_msg = &format!("try using a local generic parameter instead");
182 +let sugg_msg = "try using a local generic parameter instead";
183 183 if let Some((sugg_span, snippet)) = sm.generate_local_type_param_snippet(span) {
184 184 // Suggest the modification to the user
185 185 err.span_suggestion(
@@ -194,7 +194,7 @@ impl<'a> Resolver<'a> {
194 194 format!("try adding a local generic parameter in this method instead"),
195 195 );
196 196 } else {
197 - err.help(&format!("try using a local generic parameter instead"));
197 + err.help("try using a local generic parameter instead");
198 198 }
199 199 }
200 200
Original file line number Diff line number Diff line change
@@ -1500,10 +1500,8 @@ fn parse_libs(
1500 1500 {
1501 1501 early_error(
1502 1502 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",
1507 1505 );
1508 1506 }
1509 1507 let mut name_parts = name.splitn(2, ':');
Original file line number Diff line number Diff line change
@@ -888,10 +888,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
888 888 ),
889 889 );
890 890 }
891 - err.note(&format!(
891 + err.note(
892 892 "because of the default `Self` reference, type parameters must be \
893 - specified on object types"
894 -));
893 + specified on object types",
894 +);
895 895 err.emit();
896 896 }
897 897
Original file line number Diff line number Diff line change
@@ -283,10 +283,10 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
283 283 "no base type found for inherent implementation"
284 284 )
285 285 .span_label(ty.span, "impl requires a base type")
286 -.note(&format!(
286 +.note(
287 287 "either implement a trait on it or create a newtype \
288 - to wrap it instead"
289 -))
288 + to wrap it instead",
289 +)
290 290 .emit();
291 291 return;
292 292 }
Original file line number Diff line number Diff line change
@@ -1282,10 +1282,10 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
1282 1282 param.hir_id,
1283 1283 param.span,
1284 1284 |lint
1285 - lint.build(&format!(
1285 + lint.build(
1286 1286 "defaults for type parameters are only allowed in \
1287 - `struct`, `enum`, `type`, or `trait` definitions."
1288 -))
1287 + `struct`, `enum`, `type`, or `trait` definitions.",
1288 +)
1289 1289 .emit();
1290 1290 },
1291 1291 );