Skip to content

Commit

Permalink
clippy::useless_format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Jul 25, 2021
1 parent d0a8a12 commit 3fd8cbb
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Expand Up @@ -906,7 +906,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} else {
return FfiUnsafe {
ty,
reason: format!("box cannot be represented as a single pointer"),
reason: "box cannot be represented as a single pointer".to_string(),
help: None,
};
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/symbols.rs
Expand Up @@ -135,7 +135,7 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
let mut check_dup = |span: Span, str: &str, errors: &mut Errors| {
if let Some(prev_span) = keys.get(str) {
errors.error(span, format!("Symbol `{}` is duplicated", str));
errors.error(*prev_span, format!("location of previous definition"));
errors.error(*prev_span, "location of previous definition".to_string());
} else {
keys.insert(str.to_string(), span);
}
Expand Down
Expand Up @@ -320,7 +320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.map(|n| format!("`{}`", n))
.unwrap_or_else(|| "the mutable reference".to_string()),
),
format!("&mut *"),
"&mut *".to_string(),
Applicability::MachineApplicable,
);
}
Expand Down
Expand Up @@ -721,7 +721,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if suggestions.peek().is_some() {
err.span_suggestions(
path_segment.ident.span,
&format!("use mutable method"),
"use mutable method",
suggestions,
Applicability::MaybeIncorrect,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/check_consts/ops.rs
Expand Up @@ -255,7 +255,7 @@ impl NonConstOp for CellBorrow {
);
err.span_label(
span,
format!("this borrow of an interior mutable value may end up in the final value"),
"this borrow of an interior mutable value may end up in the final value",
);
if let hir::ConstContext::Static(_) = ccx.const_kind() {
err.help(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/transform/coverage/debug.rs
Expand Up @@ -344,7 +344,7 @@ impl DebugCounters {
return if counter_format.id {
format!("{}#{}", block_label, id.index())
} else {
format!("{}", block_label)
block_label.to_string()
};
}
}
Expand All @@ -369,7 +369,7 @@ impl DebugCounters {
}
return format!("({})", self.format_counter_kind(counter_kind));
}
return format!("{}", self.format_counter_kind(counter_kind));
return self.format_counter_kind(counter_kind).to_string();
}
}
format!("#{}", operand.index().to_string())
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/transform/lower_intrinsics.rs
Expand Up @@ -147,8 +147,8 @@ fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span)
match &args[2] {
Operand::Constant(_) => {} // all good
_ => {
let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
tcx.sess.span_err(span, &msg);
let msg = "last argument of `simd_shuffle` is required to be a `const` item";
tcx.sess.span_err(span, msg);
}
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/util/pretty.rs
Expand Up @@ -479,7 +479,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
uv.promoted
),
ty::ConstKind::Value(val) => format!("Value({:?})", val),
ty::ConstKind::Error(_) => format!("Error"),
ty::ConstKind::Error(_) => "Error".to_string(),
};
self.push(&format!("+ val: {}", val));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Expand Up @@ -855,7 +855,7 @@ impl CheckAttrVisitor<'tcx> {
hir_id,
meta.span(),
|lint| {
lint.build(&format!("invalid `doc` attribute")).emit();
lint.build(&"invalid `doc` attribute").emit();
},
);
is_valid = false;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/entry.rs
Expand Up @@ -229,7 +229,7 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
if let Some(main_def) = tcx.resolutions(()).main_def {
if main_def.opt_fn_def_id().is_none() {
// There is something at `crate::main`, but it is not a function definition.
err.span_label(main_def.span, &format!("non-function item at `crate::main` is found"));
err.span_label(main_def.span, "non-function item at `crate::main` is found");
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_query_system/src/query/plumbing.rs
Expand Up @@ -618,8 +618,8 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
};
tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
.help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd))
.note(&format!("Please follow the instructions below to create a bug report with the provided information"))
.note(&format!("See <https://github.com/rust-lang/rust/issues/84970> for more information"))
.note(&"Please follow the instructions below to create a bug report with the provided information")
.note(&"See <https://github.com/rust-lang/rust/issues/84970> for more information")
.emit();
panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Expand Up @@ -1061,7 +1061,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
}
err.span_suggestion(
span,
&format!("use this syntax instead"),
&"use this syntax instead",
format!("{path_str}"),
Applicability::MaybeIncorrect,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Expand Up @@ -2018,7 +2018,7 @@ impl Target {

if base.is_builtin {
// This can cause unfortunate ICEs later down the line.
return Err(format!("may not set is_builtin for targets not built-in"));
return Err("may not set is_builtin for targets not built-in".to_string());
}
// Each field should have been read using `Json::remove_key` so any keys remaining are unused.
let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/method/prelude2021.rs
Expand Up @@ -342,7 +342,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
(expr_text, true)
} else {
(format!("(..)"), false)
("(..)".to_string(), false)
};

let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) =
Expand Down

0 comments on commit 3fd8cbb

Please sign in to comment.