Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded calls to format!() #69541

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/librustc_expand/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_incremental/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
}

Expand Down
5 changes: 1 addition & 4 deletions src/librustc_incremental/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_infer/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_infer/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 1 addition & 4 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/librustc_parse/parser/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_passes/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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");
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ':');
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
);
Expand Down