mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Remove unneeded calls to format!()
This commit is contained in:
parent
834bc5650a
commit
c1de0b1b70
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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| {
|
||||
|
@ -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",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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`
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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, ':');
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
},
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user