mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
clippy::useless_format
This commit is contained in:
parent
d0a8a12dc6
commit
3fd8cbb404
@ -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,
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -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(
|
||||
|
@ -344,7 +344,7 @@ impl DebugCounters {
|
||||
return if counter_format.id {
|
||||
format!("{}#{}", block_label, id.index())
|
||||
} else {
|
||||
format!("{}", block_label)
|
||||
block_label.to_string()
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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())
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -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();
|
||||
|
@ -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) =
|
||||
|
Loading…
Reference in New Issue
Block a user