fix fallout from previous commit

This commit is contained in:
y21 2024-03-23 06:52:11 +01:00
parent bd4d456138
commit 91f514cc83
234 changed files with 373 additions and 371 deletions

View File

@ -95,7 +95,7 @@ impl ApproxConstant {
cx,
APPROX_CONSTANT,
e.span,
&format!("approximate value of `{module}::consts::{}` found", &name),
format!("approximate value of `{module}::consts::{}` found", &name),
None,
"consider using the constant directly",
);

View File

@ -53,9 +53,9 @@ fn check_asm_syntax(
cx,
lint,
span,
&format!("{style} x86 assembly syntax used"),
format!("{style} x86 assembly syntax used"),
None,
&format!("use {} x86 assembly syntax", !style),
format!("use {} x86 assembly syntax", !style),
);
}
}

View File

@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
cx,
ASSERTIONS_ON_CONSTANTS,
macro_call.span,
&format!(
format!(
"`{}!(true)` will be optimized out by the compiler",
cx.tcx.item_name(macro_call.def_id)
),
@ -74,9 +74,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
cx,
ASSERTIONS_ON_CONSTANTS,
macro_call.span,
&format!("`assert!(false{assert_arg})` should probably be replaced"),
format!("`assert!(false{assert_arg})` should probably be replaced"),
None,
&format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
);
}
}

View File

@ -30,7 +30,7 @@ pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMet
cx,
ALLOW_ATTRIBUTES_WITHOUT_REASON,
attr.span,
&format!("`{}` attribute without specifying a reason", name.as_str()),
format!("`{}` attribute without specifying a reason", name.as_str()),
None,
"try adding a reason at the end with `, reason = \"..\"`",
);

View File

@ -21,7 +21,7 @@ pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Att
cx,
INLINE_ALWAYS,
attr.span,
&format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
);
}
}

View File

@ -40,7 +40,7 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) {
cx,
MAYBE_MISUSED_CFG,
meta.span,
&format!("'test' may be misspelled as '{}'", ident.name.as_str()),
format!("'test' may be misspelled as '{}'", ident.name.as_str()),
"did you mean",
"test".to_string(),
Applicability::MaybeIncorrect,

View File

@ -58,7 +58,7 @@ pub(super) fn check(
clippy_lints,
"no need to put clippy lints behind a `clippy` cfg",
None,
&format!(
format!(
"write instead: `#{}[{}({})]`",
if attr.style == AttrStyle::Inner { "!" } else { "" },
ident.name,

View File

@ -267,7 +267,7 @@ fn emit_invalid_type(cx: &LateContext<'_>, span: Span, disallowed: &DisallowedPa
cx,
AWAIT_HOLDING_INVALID_TYPE,
span,
&format!(
format!(
"`{}` may not be held across an `await` point per `clippy.toml`",
disallowed.path()
),

View File

@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions {
else {
return;
};
let complex_block_message = &format!(
let complex_block_message = format!(
"in {desc}, avoid complex blocks or closures with blocks; \
instead, move the block or closure higher and bind it with a `let`",
);
@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions {
let ex = &body.value;
if let ExprKind::Block(block, _) = ex.kind {
if !body.value.span.from_expansion() && !block.stmts.is_empty() {
span_lint(cx, BLOCKS_IN_CONDITIONS, ex.span, complex_block_message);
span_lint(cx, BLOCKS_IN_CONDITIONS, ex.span, complex_block_message.clone());
return ControlFlow::Continue(Descend::No);
}
}

View File

@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {
cx,
BOOL_ASSERT_COMPARISON,
macro_call.span,
&format!("used `{macro_name}!` with a literal bool"),
format!("used `{macro_name}!` with a literal bool"),
|diag| {
// assert_eq!(...)
// ^^^^^^^^^

View File

@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, ignore_publish: b
fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, field: &str) {
let message = format!("package `{}` is missing `{field}` metadata", package.name);
span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message);
span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, message);
}
fn is_empty_str<T: AsRef<std::ffi::OsStr>>(value: &Option<T>) -> bool {

View File

@ -56,13 +56,13 @@ fn lint(cx: &LateContext<'_>, feature: &str, substring: &str, is_prefix: bool) {
REDUNDANT_FEATURE_NAMES
},
DUMMY_SP,
&format!(
format!(
"the \"{substring}\" {} in the feature name \"{feature}\" is {}",
if is_prefix { "prefix" } else { "suffix" },
if is_negative { "negative" } else { "redundant" }
),
None,
&format!(
format!(
"consider renaming the feature to \"{}\"{}",
if is_prefix {
feature.strip_prefix(substring)

View File

@ -102,7 +102,7 @@ fn check_table(cx: &LateContext<'_>, table: LintTable, groups: &FxHashSet<&str>,
cx,
LINT_GROUPS_PRIORITY,
toml_span(group.span(), file),
&format!(
format!(
"lint group `{}` has the same priority ({priority}) as a lint",
group.as_ref()
),

View File

@ -241,7 +241,7 @@ impl LateLintPass<'_> for Cargo {
},
Err(e) => {
for lint in NO_DEPS_LINTS {
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}"));
span_lint(cx, lint, DUMMY_SP, format!("could not read cargo metadata: {e}"));
}
},
}
@ -257,7 +257,7 @@ impl LateLintPass<'_> for Cargo {
},
Err(e) => {
for lint in WITH_DEPS_LINTS {
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}"));
span_lint(cx, lint, DUMMY_SP, format!("could not read cargo metadata: {e}"));
}
},
}

View File

@ -52,7 +52,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, allowed_duplicate
cx,
MULTIPLE_CRATE_VERSIONS,
DUMMY_SP,
&format!("multiple versions for dependency `{name}`: {versions}"),
format!("multiple versions for dependency `{name}`: {versions}"),
);
}
}

View File

@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) {
cx,
WILDCARD_DEPENDENCIES,
DUMMY_SP,
&format!("wildcard dependency for `{}`", dep.name),
format!("wildcard dependency for `{}`", dep.name),
);
}
}

View File

@ -33,7 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
AS_PTR_CAST_MUT,
expr.span,
&format!("casting the result of `as_ptr` to *mut {ptrty}"),
format!("casting the result of `as_ptr` to *mut {ptrty}"),
"replace with",
format!("{recv}.as_mut_ptr()"),
applicability,

View File

@ -34,7 +34,7 @@ pub(super) fn check(
cx,
CAST_ABS_TO_UNSIGNED,
span,
&format!("casting the result of `{cast_from}::abs()` to {cast_to}"),
format!("casting the result of `{cast_from}::abs()` to {cast_to}"),
"replace with",
format!("{}.unsigned_abs()", Sugg::hir(cx, receiver, "..").maybe_par()),
Applicability::MachineApplicable,

View File

@ -68,7 +68,7 @@ pub(super) fn check(
cx,
CAST_LOSSLESS,
expr.span,
&message,
message,
"try",
format!("{cast_to_fmt}::from({sugg})"),
app,

View File

@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
CAST_NAN_TO_INT,
expr.span,
&format!("casting a known NaN to {to_ty}"),
format!("casting a known NaN to {to_ty}"),
None,
"this always evaluates to 0",
);

View File

@ -142,7 +142,7 @@ pub(super) fn check(
cx,
CAST_ENUM_TRUNCATION,
expr.span,
&format!(
format!(
"casting `{cast_from}::{}` to `{cast_to}` will truncate the value{suffix}",
variant.name,
),
@ -163,7 +163,7 @@ pub(super) fn check(
_ => return,
};
span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, &msg, |diag| {
span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, msg, |diag| {
diag.help("if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...");
if !cast_from.is_floating_point() {
offer_suggestion(cx, expr, cast_expr, cast_to_span, diag);

View File

@ -79,7 +79,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
),
};
span_lint_and_then(cx, CAST_POSSIBLE_WRAP, expr.span, &message, |diag| {
span_lint_and_then(cx, CAST_POSSIBLE_WRAP, expr.span, message, |diag| {
if let EmitState::LintOnPtrSize(16) = should_lint {
diag
.note("`usize` and `isize` may be as small as 16 bits on some platforms")

View File

@ -38,7 +38,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
cx,
CAST_PRECISION_LOSS,
expr.span,
&format!(
format!(
"casting `{0}` to `{1}` causes a loss of precision {2}(`{0}` is {3} bits wide, \
but `{1}`'s mantissa is only {4} bits wide)",
cast_from,

View File

@ -48,7 +48,7 @@ fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_f
cx,
CAST_PTR_ALIGNMENT,
expr.span,
&format!(
format!(
"casting from `{cast_from}` to a more-strictly-aligned pointer (`{cast_to}`) ({} < {} bytes)",
from_layout.align.abi.bytes(),
to_layout.align.abi.bytes(),

View File

@ -47,7 +47,7 @@ pub(super) fn check<'cx>(
cx,
CAST_SIGN_LOSS,
expr.span,
&format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"),
format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"),
);
}
}

View File

@ -35,7 +35,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
cx,
CAST_SLICE_DIFFERENT_SIZES,
expr.span,
&format!(
format!(
"casting between raw pointers to `[{}]` (element size {from_size}) and `[{}]` (element size {to_size}) does not adjust the count",
start_ty.ty, end_ty.ty,
),

View File

@ -46,7 +46,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
CAST_SLICE_FROM_RAW_PARTS,
span,
&format!("casting the result of `{func}` to {cast_to}"),
format!("casting the result of `{func}` to {cast_to}"),
"replace with",
format!("core::ptr::slice_{func}({ptr}, {len})"),
applicability,

View File

@ -25,7 +25,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
FN_TO_NUMERIC_CAST,
expr.span,
&format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
"try",
format!("{from_snippet} as usize"),
applicability,

View File

@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
FN_TO_NUMERIC_CAST_ANY,
expr.span,
&format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
"did you mean to invoke the function?",
format!("{from_snippet}() as {cast_to}"),
applicability,

View File

@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
cx,
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
expr.span,
&format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"),
format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"),
"try",
format!("{from_snippet} as usize"),
applicability,

View File

@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(
PTR_CAST_CONSTNESS,
expr.span,
"`as` casting between raw pointers while changing only its constness",
&format!("try `pointer::cast_{constness}`, a safer alternative"),
format!("try `pointer::cast_{constness}`, a safer alternative"),
format!("{}.cast_{constness}()", sugg.maybe_par()),
Applicability::MachineApplicable,
);

View File

@ -51,7 +51,7 @@ pub(super) fn check<'tcx>(
cx,
UNNECESSARY_CAST,
expr.span,
&format!(
format!(
"casting raw pointers to the same type and constness is unnecessary (`{cast_from}` -> `{cast_to}`)"
),
"try",
@ -166,7 +166,7 @@ pub(super) fn check<'tcx>(
cx,
UNNECESSARY_CAST,
expr.span,
&format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"),
format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"),
"try",
if needs_block {
format!("{{ {cast_str} }}")
@ -209,7 +209,7 @@ fn lint_unnecessary_cast(
cx,
UNNECESSARY_CAST,
expr.span,
&format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"),
format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"),
"try",
sugg,
Applicability::MachineApplicable,

View File

@ -121,7 +121,7 @@ impl CognitiveComplexity {
cx,
COGNITIVE_COMPLEXITY,
fn_span,
&format!(
format!(
"the function has a cognitive complexity of ({cc}/{})",
self.limit.limit()
),

View File

@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
cx,
DEFAULT_TRAIT_ACCESS,
expr.span,
&format!("calling `{replacement}` is more clear than this expression"),
format!("calling `{replacement}` is more clear than this expression"),
"try",
replacement,
Applicability::Unspecified, // First resolve the TODO above
@ -243,7 +243,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
first_assign.unwrap().span,
"field assignment outside of initializer for an instance created with Default::default()",
Some(local.span),
&format!("consider initializing the variable with `{sugg}` and removing relevant reassignments"),
format!("consider initializing the variable with `{sugg}` and removing relevant reassignments"),
);
self.reassigned_linted.insert(span);
}

View File

@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultIterEmpty {
cx,
DEFAULT_INSTEAD_OF_ITER_EMPTY,
expr.span,
&format!("`{path}()` is the more idiomatic way"),
format!("`{path}()` is the more idiomatic way"),
"try",
sugg,
applicability,

View File

@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
item.span,
"this union has the default representation",
None,
&format!(
format!(
"consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout",
cx.tcx.def_path_str(item.owner_id)
),

View File

@ -102,11 +102,11 @@ impl DisallowedMacros {
DISALLOWED_MACROS,
cx.tcx.local_def_id_to_hir_id(derive_src.def_id),
mac.span,
&msg,
msg,
add_note,
);
} else {
span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, &msg, add_note);
span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, msg, add_note);
}
}
}

View File

@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethods {
None => return,
};
let msg = format!("use of a disallowed method `{}`", conf.path());
span_lint_and_then(cx, DISALLOWED_METHODS, expr.span, &msg, |diag| {
span_lint_and_then(cx, DISALLOWED_METHODS, expr.span, msg, |diag| {
if let Some(reason) = conf.reason() {
diag.note(reason);
}

View File

@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedNames {
cx,
DISALLOWED_NAMES,
ident.span,
&format!("use of a disallowed/placeholder name `{}`", ident.name),
format!("use of a disallowed/placeholder name `{}`", ident.name),
);
}
}

View File

@ -98,7 +98,7 @@ impl EarlyLintPass for DisallowedScriptIdents {
cx,
DISALLOWED_SCRIPT_IDENTS,
span,
&format!(
format!(
"identifier `{symbol_str}` has a Unicode script that is not allowed by configuration: {}",
script.full_name()
),

View File

@ -127,7 +127,7 @@ fn emit(cx: &LateContext<'_>, name: &str, span: Span, conf: &DisallowedPath) {
cx,
DISALLOWED_TYPES,
span,
&format!("`{name}` is not allowed according to config"),
format!("`{name}` is not allowed according to config"),
|diag| {
if let Some(reason) = conf.reason() {
diag.note(reason);

View File

@ -129,9 +129,9 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
cx,
lint,
expr.span,
&msg,
msg,
note_span,
&format!("argument has type `{arg_ty}`"),
format!("argument has type `{arg_ty}`"),
);
}
}

View File

@ -119,7 +119,7 @@ impl EarlyLintPass for DuplicateMod {
cx,
DUPLICATE_MOD,
multi_span,
&format!("file is loaded as a module multiple times: `{}`", local_path.display()),
format!("file is loaded as a module multiple times: `{}`", local_path.display()),
None,
"replace all but one `mod` item with `use` items",
);

View File

@ -197,7 +197,7 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix
cx,
lint.as_lint(),
expr.span,
&format!(
format!(
"usage of the {}`{ty}::{}`{}",
if prefix == Prefix::From { "function " } else { "" },
lint.as_name(prefix),

View File

@ -186,7 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass {
cx,
MAP_ENTRY,
expr.span,
&format!("usage of `contains_key` followed by `insert` on a `{}`", map_ty.name()),
format!("usage of `contains_key` followed by `insert` on a `{}`", map_ty.name()),
"try",
sugg,
app,

View File

@ -120,7 +120,7 @@ impl ExcessiveBools {
cx,
FN_PARAMS_EXCESSIVE_BOOLS,
span,
&format!("more than {} bools in function parameters", self.max_fn_params_bools),
format!("more than {} bools in function parameters", self.max_fn_params_bools),
None,
"consider refactoring bools into two-variant enums",
);
@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
cx,
STRUCT_EXCESSIVE_BOOLS,
item.span,
&format!("more than {} bools in a struct", self.max_struct_bools),
format!("more than {} bools in a struct", self.max_struct_bools),
None,
"consider using a state machine or refactoring bools into two-variant enums",
);

View File

@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
cx,
EXPLICIT_WRITE,
expr.span,
&format!("use of `{used}.unwrap()`"),
format!("use of `{used}.unwrap()`"),
"try",
format!("{prefix}{sugg_mac}!({inputs_snippet})"),
applicability,

View File

@ -110,11 +110,11 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> {
.map_or(param.span, |bound_span| param.span.with_hi(bound_span.hi()))
}
fn emit_help(&self, spans: Vec<Span>, msg: &str, help: &'static str) {
fn emit_help(&self, spans: Vec<Span>, msg: String, help: &'static str) {
span_lint_and_help(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, spans, msg, None, help);
}
fn emit_sugg(&self, spans: Vec<Span>, msg: &str, help: &'static str) {
fn emit_sugg(&self, spans: Vec<Span>, msg: String, help: &'static str) {
let suggestions: Vec<(Span, String)> = spans.iter().copied().zip(std::iter::repeat(String::new())).collect();
span_lint_and_then(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, spans, msg, |diag| {
diag.multipart_suggestion(help, suggestions, Applicability::MachineApplicable);
@ -167,7 +167,7 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> {
.iter()
.map(|(_, param)| self.get_bound_span(param))
.collect::<Vec<_>>();
self.emit_help(spans, &msg, help);
self.emit_help(spans, msg, help);
} else {
let spans = if explicit_params.len() == extra_params.len() {
vec![self.generics.span] // Remove the entire list of generics
@ -196,7 +196,7 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> {
})
.collect()
};
self.emit_sugg(spans, &msg, help);
self.emit_sugg(spans, msg, help);
};
}
}

View File

@ -401,7 +401,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> {
self.cx,
FORMAT_IN_FORMAT_ARGS,
self.macro_call.span,
&format!("`format!` in `{name}!` args"),
format!("`format!` in `{name}!` args"),
|diag| {
diag.help(format!(
"combine the `format!(..)` arguments with the outer `{name}!(..)` call"
@ -431,7 +431,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> {
cx,
TO_STRING_IN_FORMAT_ARGS,
to_string_span.with_lo(receiver.span.hi()),
&format!("`to_string` applied to a type that implements `Display` in `{name}!` args"),
format!("`to_string` applied to a type that implements `Display` in `{name}!` args"),
"remove this",
String::new(),
Applicability::MachineApplicable,
@ -441,7 +441,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> {
cx,
TO_STRING_IN_FORMAT_ARGS,
value.span,
&format!("`to_string` applied to a type that implements `Display` in `{name}!` args"),
format!("`to_string` applied to a type that implements `Display` in `{name}!` args"),
"use this",
format!(
"{}{:*>n_needed_derefs$}{receiver_snippet}",

View File

@ -214,7 +214,7 @@ impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> {
self.cx,
RECURSIVE_FORMAT_IMPL,
self.expr.span,
&format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"),
format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"),
);
}
}
@ -235,7 +235,7 @@ impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> {
self.cx,
PRINT_IN_FORMAT_IMPL,
macro_call.span,
&format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name),
format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name),
"replace with",
if let Some(formatter_name) = self.format_trait_impl.formatter_name {
format!("{replacement}!({formatter_name}, ..)")

View File

@ -151,12 +151,12 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) {
cx,
SUSPICIOUS_ASSIGNMENT_FORMATTING,
eqop_span,
&format!(
format!(
"this looks like you are trying to use `.. {op}= ..`, but you \
really are doing `.. = ({op} ..)`"
),
None,
&format!("to remove this lint, use either `{op}=` or `= {op}`"),
format!("to remove this lint, use either `{op}=` or `= {op}`"),
);
}
}
@ -187,12 +187,12 @@ fn check_unop(cx: &EarlyContext<'_>, expr: &Expr) {
cx,
SUSPICIOUS_UNARY_OP_FORMATTING,
eqop_span,
&format!(
format!(
"by not having a space between `{binop_str}` and `{unop_str}` it looks like \
`{binop_str}{unop_str}` is a single operator"
),
None,
&format!("put a space between `{binop_str}` and `{unop_str}` and remove the space after `{unop_str}`"),
format!("put a space between `{binop_str}` and `{unop_str}` and remove the space after `{unop_str}`"),
);
}
}
@ -239,9 +239,9 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) {
cx,
SUSPICIOUS_ELSE_FORMATTING,
else_span,
&format!("this is an `else {else_desc}` but the formatting might hide it"),
format!("this is an `else {else_desc}` but the formatting might hide it"),
None,
&format!(
format!(
"to remove this lint, remove the `else` or remove the new line between \
`else` and `{else_desc}`",
),
@ -309,9 +309,9 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
cx,
SUSPICIOUS_ELSE_FORMATTING,
else_span,
&format!("this looks like {looks_like} but the `else` is missing"),
format!("this looks like {looks_like} but the `else` is missing"),
None,
&format!("to remove this lint, add the missing `else` or add a new line before {next_thing}",),
format!("to remove this lint, add the missing `else` or add a new line before {next_thing}",),
);
}
}

View File

@ -52,7 +52,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr {
cx,
FROM_RAW_WITH_VOID_PTR,
expr.span,
&msg,
msg,
Some(arg.span),
"cast this to a pointer of the appropriate type",
);

View File

@ -142,7 +142,7 @@ fn check_must_use_candidate<'tcx>(
item_span: Span,
item_id: hir::OwnerId,
fn_span: Span,
msg: &str,
msg: &'static str,
) {
if has_mutable_arg(cx, body)
|| mutates_static(cx, body)

View File

@ -59,7 +59,7 @@ fn check_arg_number(cx: &LateContext<'_>, decl: &hir::FnDecl<'_>, fn_span: Span,
cx,
TOO_MANY_ARGUMENTS,
fn_span,
&format!("this function has too many arguments ({args}/{too_many_arguments_threshold})"),
format!("this function has too many arguments ({args}/{too_many_arguments_threshold})"),
);
}
}

View File

@ -77,7 +77,7 @@ pub(super) fn check_fn(
cx,
TOO_MANY_LINES,
span,
&format!("this function has too many lines ({line_count}/{too_many_lines_threshold})"),
format!("this function has too many lines ({line_count}/{too_many_lines_threshold})"),
);
}
}

View File

@ -117,9 +117,9 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone {
cx,
IF_THEN_SOME_ELSE_NONE,
expr.span,
&format!("this could be simplified with `bool::{method_name}`"),
format!("this could be simplified with `bool::{method_name}`"),
None,
&help,
help,
);
}
}

View File

@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
cx,
IMPLICIT_HASHER,
target.span(),
&format!(
format!(
"impl for `{}` should be generalized over different hashers",
target.type_name()
),
@ -187,7 +187,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
cx,
IMPLICIT_HASHER,
target.span(),
&format!(
format!(
"parameter of type `{}` should be generalized over different hashers",
target.type_name()
),

View File

@ -65,7 +65,7 @@ fn emit_lint(
cx,
IMPLIED_BOUNDS_IN_IMPLS,
poly_trait.span,
&format!("this bound is already specified as the supertrait of `{implied_by}`"),
format!("this bound is already specified as the supertrait of `{implied_by}`"),
|diag| {
// If we suggest removing a bound, we may also need to extend the span
// to include the `+` token that is ahead or behind,

View File

@ -104,7 +104,7 @@ impl IncompatibleMsrv {
cx,
INCOMPATIBLE_MSRV,
span,
&format!(
format!(
"current MSRV (Minimum Supported Rust Version) is `{}` but this item is stable since `{version}`",
self.msrv
),

View File

@ -132,20 +132,20 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
cx,
INHERENT_TO_STRING_SHADOW_DISPLAY,
item.span,
&format!(
format!(
"type `{self_type}` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`"
),
None,
&format!("remove the inherent method from type `{self_type}`"),
format!("remove the inherent method from type `{self_type}`"),
);
} else {
span_lint_and_help(
cx,
INHERENT_TO_STRING,
item.span,
&format!("implementation of inherent method `to_string(&self) -> String` for type `{self_type}`"),
format!("implementation of inherent method `to_string(&self) -> String` for type `{self_type}`"),
None,
&format!("implement trait `Display` for type `{self_type}` instead"),
format!("implement trait `Display` for type `{self_type}` instead"),
);
}
}

View File

@ -51,7 +51,7 @@ fn check_attrs(cx: &LateContext<'_>, name: Symbol, attrs: &[Attribute]) {
cx,
INLINE_FN_WITHOUT_BODY,
attr.span,
&format!("use of `#[inline]` on trait method `{name}` which has no body"),
format!("use of `#[inline]` on trait method `{name}` which has no body"),
|diag| {
diag.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable);
},

View File

@ -43,7 +43,7 @@ impl LateLintPass<'_> for IntegerDivisionRemainderUsed {
cx,
INTEGER_DIVISION_REMAINDER_USED,
expr.span.source_callsite(),
&format!("use of {} has been disallowed in this context", op.node.as_str()),
format!("use of {} has been disallowed in this context", op.node.as_str()),
);
}
}

View File

@ -76,7 +76,7 @@ fn err_upcast_comparison(cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, alwa
cx,
INVALID_UPCAST_COMPARISONS,
span,
&format!(
format!(
"because of the numeric bounds on `{}` prior to casting, this expression is always {}",
snippet(cx, cast_val.span, "the expression"),
if always { "true" } else { "false" },

View File

@ -240,9 +240,9 @@ fn check_fields(cx: &LateContext<'_>, threshold: u64, item: &Item<'_>, fields: &
cx,
STRUCT_FIELD_NAMES,
item.span,
&format!("all fields have the same {what}fix: `{value}`"),
format!("all fields have the same {what}fix: `{value}`"),
None,
&format!("remove the {what}fixes"),
format!("remove the {what}fixes"),
);
}
}
@ -370,9 +370,9 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
cx,
ENUM_VARIANT_NAMES,
span,
&format!("all variants have the same {what}fix: `{value}`"),
format!("all variants have the same {what}fix: `{value}`"),
None,
&format!(
format!(
"remove the {what}fixes and use full paths to \
the variants instead of glob imports"
),

View File

@ -84,7 +84,7 @@ fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefI
cx,
ITER_NOT_RETURNING_ITERATOR,
sig.span,
&format!("this method is named `{name}` but its return type does not implement `Iterator`"),
format!("this method is named `{name}` but its return type does not implement `Iterator`"),
);
}
}

View File

@ -182,7 +182,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter {
cx,
INTO_ITER_WITHOUT_ITER,
item.span,
&format!("`IntoIterator` implemented for a reference type without an `{expected_method_name}` method"),
format!("`IntoIterator` implemented for a reference type without an `{expected_method_name}` method"),
|diag| {
// The suggestion forwards to the `IntoIterator` impl and uses a form of UFCS
// to avoid name ambiguities, as there might be an inherent into_iter method
@ -258,7 +258,7 @@ impl {self_ty_without_ref} {{
cx,
ITER_WITHOUT_INTO_ITER,
item.span,
&format!(
format!(
"`{}` method without an `IntoIterator` impl for `{self_ty_snippet}`",
item.ident
),

View File

@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture {
cx,
LARGE_FUTURES,
expr.span,
&format!("large future with a size of {} bytes", size.bytes()),
format!("large future with a size of {} bytes", size.bytes()),
"consider `Box::pin` on it",
format!("Box::pin({})", snippet(cx, expr.span, "..")),
Applicability::Unspecified,

View File

@ -74,7 +74,7 @@ impl LateLintPass<'_> for LargeIncludeFile {
expr.span,
"attempted to include a large file",
None,
&format!(
format!(
"the configuration allows a maximum size of {} bytes",
self.max_file_size
),

View File

@ -58,12 +58,12 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
cx,
LARGE_STACK_ARRAYS,
expr.span,
&format!(
format!(
"allocating a local array larger than {} bytes",
self.maximum_allowed_size
),
None,
&format!(
format!(
"consider allocating on the heap with `vec!{}.into_boxed_slice()`",
snippet(cx, expr.span, "[...]")
),

View File

@ -174,7 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames {
cx,
LARGE_STACK_FRAMES,
fn_span,
&format!("this function may allocate {frame_size} on the stack"),
format!("this function may allocate {frame_size} on the stack"),
|diag| {
// Point out the largest individual contribution to this size, because
// it is the most likely to be unintentionally large.

View File

@ -266,7 +266,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
cx,
LEN_WITHOUT_IS_EMPTY,
visited_trait.span,
&format!(
format!(
"trait `{}` has a `len` method but no (possibly inherited) `is_empty` method",
visited_trait.ident.name
),
@ -484,7 +484,7 @@ fn check_for_is_empty(
Some(_) => return,
};
span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, &msg, |db| {
span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, msg, |db| {
if let Some(span) = is_empty_span {
db.span_note(span, "`is_empty` defined here");
}
@ -542,8 +542,8 @@ fn check_len(
cx,
LEN_ZERO,
span,
&format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }),
&format!("using `{op}is_empty` is clearer and more explicit"),
format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }),
format!("using `{op}is_empty` is clearer and more explicit"),
format!(
"{op}{}.is_empty()",
snippet_with_context(cx, receiver.span, span.ctxt(), "_", &mut applicability).0,
@ -566,7 +566,7 @@ fn check_empty_expr(cx: &LateContext<'_>, span: Span, lit1: &Expr<'_>, lit2: &Ex
COMPARISON_TO_EMPTY,
span,
"comparison to empty slice",
&format!("using `{op}is_empty` is clearer and more explicit"),
format!("using `{op}is_empty` is clearer and more explicit"),
format!("{op}{lit_str}.is_empty()"),
applicability,
);

View File

@ -216,7 +216,7 @@ fn check_fn_inner<'tcx>(
None
}))
.collect_vec(),
&format!("the following explicit lifetimes could be elided: {lts}"),
format!("the following explicit lifetimes could be elided: {lts}"),
|diag| {
if sig.header.is_async() {
// async functions have usages whose spans point at the lifetime declaration which messes up

View File

@ -70,7 +70,7 @@ impl LateLintPass<'_> for LinesFilterMapOk {
cx,
LINES_FILTER_MAP_OK,
fm_span,
&format!("`{fm_method_str}()` will run forever if the iterator repeatedly produces an `Err`",),
format!("`{fm_method_str}()` will run forever if the iterator repeatedly produces an `Err`",),
|diag| {
diag.span_note(
fm_receiver.span,

View File

@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(
cx,
EXPLICIT_COUNTER_LOOP,
span,
&format!("the variable `{name}` is used as a loop counter"),
format!("the variable `{name}` is used as a loop counter"),
"consider using",
format!(
"for ({name}, {}) in {}.enumerate()",
@ -62,7 +62,7 @@ pub(super) fn check<'tcx>(
cx,
EXPLICIT_COUNTER_LOOP,
span,
&format!("the variable `{name}` is used as a loop counter"),
format!("the variable `{name}` is used as a loop counter"),
|diag| {
diag.span_suggestion(
span,

View File

@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx
cx,
FOR_KV_MAP,
arg_span,
&format!("you seem to want to iterate on a map's {kind}s"),
format!("you seem to want to iterate on a map's {kind}s"),
|diag| {
let map = sugg::Sugg::hir(cx, arg, "map");
multispan_sugg(

View File

@ -62,7 +62,7 @@ pub(super) fn check<'tcx>(
"...and remove the `if let` statement in the for loop"
};
span_lint_and_then(cx, MANUAL_FLATTEN, span, &msg, |diag| {
span_lint_and_then(cx, MANUAL_FLATTEN, span, msg, |diag| {
diag.span_suggestion(arg.span, "try", sugg, applicability);
diag.span_help(inner_expr.span, help_msg);
});

View File

@ -143,7 +143,7 @@ pub(super) fn check<'tcx>(
cx,
NEEDLESS_RANGE_LOOP,
arg.span,
&format!("the loop variable `{}` is used to index `{indexed}`", ident.name),
format!("the loop variable `{}` is used to index `{indexed}`", ident.name),
|diag| {
multispan_sugg(
diag,
@ -169,7 +169,7 @@ pub(super) fn check<'tcx>(
cx,
NEEDLESS_RANGE_LOOP,
arg.span,
&format!("the loop variable `{}` is only used to index `{indexed}`", ident.name),
format!("the loop variable `{}` is only used to index `{indexed}`", ident.name),
|diag| {
multispan_sugg(
diag,

View File

@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(
vec.span,
"it looks like the same item is being pushed into this Vec",
None,
&format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"),
);
}

View File

@ -95,7 +95,7 @@ pub(super) fn check<'tcx>(
cx,
SINGLE_ELEMENT_LOOP,
arg.span,
format!("this loops only once with `{pat_snip}` being `{range_expr}`").as_str(),
format!("this loops only once with `{pat_snip}` being `{range_expr}`"),
"did you mean to iterate over the range instead?",
sugg.to_string(),
Applicability::Unspecified,

View File

@ -51,7 +51,7 @@ impl LateLintPass<'_> for MainRecursion {
cx,
MAIN_RECURSION,
func.span,
&format!("recursing into entrypoint `{}`", snippet(cx, func.span, "main")),
format!("recursing into entrypoint `{}`", snippet(cx, func.span, "main")),
None,
"consider using another function for this recursion",
);

View File

@ -106,12 +106,12 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
cx,
MANUAL_STRIP,
strippings[0],
&format!("stripping a {kind_word} manually"),
format!("stripping a {kind_word} manually"),
|diag| {
diag.span_note(test_span, format!("the {kind_word} was tested here"));
multispan_sugg(
diag,
&format!("try using the `strip_{kind_word}` method"),
format!("try using the `strip_{kind_word}` method"),
vec![(
test_span,
format!(

View File

@ -221,13 +221,13 @@ fn lint_map_unit_fn(
binding = let_binding_name(cx, var_arg)
);
span_lint_and_then(cx, lint, expr.span, &msg, |diag| {
span_lint_and_then(cx, lint, expr.span, msg, |diag| {
diag.span_suggestion(stmt.span, "try", suggestion, applicability);
});
} else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) {
let msg = suggestion_msg("closure", map_type);
span_lint_and_then(cx, lint, expr.span, &msg, |diag| {
span_lint_and_then(cx, lint, expr.span, msg, |diag| {
if let Some(reduced_expr_span) = reduce_unit_expression(cx, closure_expr) {
let mut applicability = Applicability::MachineApplicable;
let suggestion = format!(

View File

@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchResultOk {
MATCH_RESULT_OK,
expr.span.with_hi(let_expr.span.hi()),
"matching on `Some` with `ok()` is redundant",
&format!("consider matching on `Ok({some_expr_string})` and removing the call to `ok` instead"),
format!("consider matching on `Ok({some_expr_string})` and removing the call to `ok` instead"),
sugg,
applicability,
);

View File

@ -97,7 +97,7 @@ fn check_arm<'tcx>(
} else {
String::new()
};
span_lint_and_then(cx, COLLAPSIBLE_MATCH, inner_expr.span, &msg, |diag| {
span_lint_and_then(cx, COLLAPSIBLE_MATCH, inner_expr.span, msg, |diag| {
let mut help_span = MultiSpan::from_spans(vec![binding_span, inner_then_pat.span]);
help_span.push_span_label(binding_span, "replace this binding");
help_span.push_span_label(inner_then_pat.span, format!("with this pattern{replace_msg}"));

View File

@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, scrutinee:
cx,
MANUAL_UNWRAP_OR,
expr.span,
&format!("this pattern reimplements `{ty_name}::unwrap_or`"),
format!("this pattern reimplements `{ty_name}::unwrap_or`"),
"replace with",
format!("{suggestion}.unwrap_or({reindented_or_body})",),
app,

View File

@ -43,7 +43,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr:
cx,
MATCH_AS_REF,
expr.span,
&format!("use `{suggestion}()` instead"),
format!("use `{suggestion}()` instead"),
"try",
format!(
"{}.{suggestion}(){cast}",

View File

@ -122,7 +122,7 @@ where
cx,
MATCH_LIKE_MATCHES_MACRO,
expr.span,
&format!(
format!(
"{} expression looks like `matches!` macro",
if is_if_let { "if let .. else" } else { "match" }
),

View File

@ -111,7 +111,7 @@ fn lint(cx: &LateContext<'_>, case_method: &CaseMethod, bad_case_span: Span, bad
MATCH_STR_CASE_MISMATCH,
bad_case_span,
"this `match` arm has a differing case than its expression",
&format!("consider changing the case of this arm to respect `{method_str}`"),
format!("consider changing the case of this arm to respect `{method_str}`"),
format!("\"{suggestion}\""),
Applicability::MachineApplicable,
);

View File

@ -43,7 +43,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm<'
cx,
MATCH_WILD_ERR_ARM,
arm.pat.span,
&format!("`Err({ident_bind_name})` matches all errors"),
format!("`Err({ident_bind_name})` matches all errors"),
None,
"match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable",
);

View File

@ -72,7 +72,7 @@ fn find_match_true<'tcx>(
pat: &'tcx Pat<'_>,
scrutinee: &'tcx Expr<'_>,
span: Span,
message: &str,
message: &'static str,
) {
if let PatKind::Lit(lit) = pat.kind
&& let ExprKind::Lit(lit) = lit.kind
@ -98,7 +98,7 @@ fn find_match_true<'tcx>(
span,
message,
"consider using the condition directly",
sugg.to_string(),
sugg.into_string(),
applicability,
);
}
@ -227,7 +227,7 @@ fn find_method_sugg_for_if_let<'tcx>(
cx,
REDUNDANT_PATTERN_MATCHING,
let_pat.span,
&format!("redundant pattern matching, consider using `{good_method}`"),
format!("redundant pattern matching, consider using `{good_method}`"),
|diag| {
// if/while let ... = ... { ... }
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -304,7 +304,7 @@ pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op
cx,
REDUNDANT_PATTERN_MATCHING,
span,
&format!("redundant pattern matching, consider using `{good_method}`"),
format!("redundant pattern matching, consider using `{good_method}`"),
"try",
sugg,
Applicability::MachineApplicable,

View File

@ -193,7 +193,7 @@ fn check_replace_with_default(cx: &LateContext<'_>, src: &Expr<'_>, dest: &Expr<
cx,
MEM_REPLACE_WITH_DEFAULT,
expr_span,
&format!(
format!(
"replacing a value of type `T` with `T::default()` is better expressed using `{top_crate}::mem::take`"
),
|diag| {

View File

@ -84,7 +84,7 @@ pub(crate) trait BindInsteadOfMap {
"{option_snip}.{}({closure_args_snip} {some_inner_snip})",
Self::GOOD_METHOD_NAME
);
span_lint_and_sugg(cx, BIND_INSTEAD_OF_MAP, expr.span, &msg, "try", note, app);
span_lint_and_sugg(cx, BIND_INSTEAD_OF_MAP, expr.span, msg, "try", note, app);
true
} else {
false
@ -114,7 +114,7 @@ pub(crate) trait BindInsteadOfMap {
} else {
return false;
};
span_lint_and_then(cx, BIND_INSTEAD_OF_MAP, expr.span, &msg, |diag| {
span_lint_and_then(cx, BIND_INSTEAD_OF_MAP, expr.span, msg, |diag| {
multispan_sugg_with_applicability(
diag,
"try",
@ -157,7 +157,7 @@ pub(crate) trait BindInsteadOfMap {
cx,
BIND_INSTEAD_OF_MAP,
expr.span,
&msg,
msg,
"use the expression directly",
snippet(cx, recv.span, "..").into(),
Applicability::MachineApplicable,

View File

@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E
cx,
BYTES_NTH,
parent.span,
&format!("called `.bytes().nth().unwrap()` on a `{caller_type}`"),
format!("called `.bytes().nth().unwrap()` on a `{caller_type}`"),
"try",
format!("{receiver}.as_bytes()[{n}]",),
applicability,
@ -41,7 +41,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E
cx,
BYTES_NTH,
expr.span,
&format!("called `.bytes().nth()` on a `{caller_type}`"),
format!("called `.bytes().nth()` on a `{caller_type}`"),
"try",
format!("{receiver}.as_bytes().get({n}).copied()"),
applicability,

View File

@ -30,7 +30,7 @@ pub(super) fn check(
cx,
lint,
info.expr.span,
&format!("you should use the `{suggest}` method"),
format!("you should use the `{suggest}` method"),
"like this",
format!(
"{}{}.{suggest}({})",

View File

@ -23,7 +23,7 @@ pub(super) fn check(
cx,
lint,
info.expr.span,
&format!("you should use the `{suggest}` method"),
format!("you should use the `{suggest}` method"),
"like this",
format!(
"{}{}.{suggest}('{}')",

View File

@ -43,7 +43,7 @@ fn suggest(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span) {
cx,
CLEAR_WITH_DRAIN,
span.with_hi(expr.span.hi()),
&format!("`drain` used to clear a `{ty_name}`"),
format!("`drain` used to clear a `{ty_name}`"),
"try",
"clear()".to_string(),
Applicability::MachineApplicable,

View File

@ -94,7 +94,7 @@ pub(super) fn check(
cx,
CLONE_ON_COPY,
expr.span,
&with_forced_trimmed_paths!(format!(
with_forced_trimmed_paths!(format!(
"using `clone` on type `{ty}` which implements the `Copy` trait"
)),
help,

View File

@ -70,7 +70,7 @@ pub(super) fn check(cx: &LateContext<'_>, args: &[Expr<'_>], expr: &Expr<'_>, re
cx,
DRAIN_COLLECT,
expr.span,
&format!("you seem to be trying to move all elements into a new `{typename}`"),
format!("you seem to be trying to move all elements into a new `{typename}`"),
"consider using `mem::take`",
sugg,
Applicability::MachineApplicable,

View File

@ -142,7 +142,7 @@ pub(super) fn check<'tcx>(
cx,
EXPECT_FUN_CALL,
span_replace_word,
&format!("use of `{name}` followed by a function call"),
format!("use of `{name}` followed by a function call"),
"try",
format!("unwrap_or_else({closure_args} panic!({sugg}))"),
applicability,
@ -160,7 +160,7 @@ pub(super) fn check<'tcx>(
cx,
EXPECT_FUN_CALL,
span_replace_word,
&format!("use of `{name}` followed by a function call"),
format!("use of `{name}` followed by a function call"),
"try",
format!("unwrap_or_else({closure_args} {{ panic!(\"{{}}\", {arg_root_snippet}) }})"),
applicability,

View File

@ -34,5 +34,5 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
}
let lint_msg = format!("`{lint_unary}FileType::is_file()` only {verb} regular files");
let help_msg = format!("use `{help_unary}FileType::is_dir()` instead");
span_lint_and_help(cx, FILETYPE_IS_FILE, span, &lint_msg, None, &help_msg);
span_lint_and_help(cx, FILETYPE_IS_FILE, span, lint_msg, None, help_msg);
}

Some files were not shown because too many files have changed in this diff Show More