Skip to content

Commit c2d4266

Browse files
committed
Auto merge of #9525 - nyurik:apply-lints, r=llogiq
pre-fallout: Apply uninlined_format-args lint This change is needed for the uninlined_format-args lint to be merged. See #9233 changelog: none
2 parents ff65eec + 59d0e8c commit c2d4266

File tree

241 files changed

+623
-917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+623
-917
lines changed

clippy_dev/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() {
4141
matches.contains_id("msrv"),
4242
) {
4343
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
44-
Err(e) => eprintln!("Unable to create lint: {}", e),
44+
Err(e) => eprintln!("Unable to create lint: {e}"),
4545
}
4646
},
4747
Some(("setup", sub_command)) => match sub_command.subcommand() {

clippy_lints/src/approx_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl ApproxConstant {
9292
cx,
9393
APPROX_CONSTANT,
9494
e.span,
95-
&format!("approximate value of `{}::consts::{}` found", module, &name),
95+
&format!("approximate value of `{module}::consts::{}` found", &name),
9696
None,
9797
"consider using the constant directly",
9898
);
@@ -126,7 +126,7 @@ fn is_approx_const(constant: f64, value: &str, min_digits: usize) -> bool {
126126
// The value is a truncated constant
127127
true
128128
} else {
129-
let round_const = format!("{:.*}", value.len() - 2, constant);
129+
let round_const = format!("{constant:.*}", value.len() - 2);
130130
value == round_const
131131
}
132132
}

clippy_lints/src/asm_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr
4444
cx,
4545
lint,
4646
expr.span,
47-
&format!("{} x86 assembly syntax used", style),
47+
&format!("{style} x86 assembly syntax used"),
4848
None,
4949
&format!("use {} x86 assembly syntax", !style),
5050
);

clippy_lints/src/assertions_on_constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
6060
cx,
6161
ASSERTIONS_ON_CONSTANTS,
6262
macro_call.span,
63-
&format!("`assert!(false{})` should probably be replaced", assert_arg),
63+
&format!("`assert!(false{assert_arg})` should probably be replaced"),
6464
None,
65-
&format!("use `panic!({})` or `unreachable!({0})`", panic_arg),
65+
&format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
6666
);
6767
}
6868
}

clippy_lints/src/assertions_on_result_states.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
6969
"called `assert!` with `Result::is_ok`",
7070
"replace with",
7171
format!(
72-
"{}.unwrap(){}",
73-
snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0,
74-
semicolon
72+
"{}.unwrap(){semicolon}",
73+
snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0
7574
),
7675
app,
7776
);
@@ -84,9 +83,8 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
8483
"called `assert!` with `Result::is_err`",
8584
"replace with",
8685
format!(
87-
"{}.unwrap_err(){}",
88-
snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0,
89-
semicolon
86+
"{}.unwrap_err(){semicolon}",
87+
snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0
9088
),
9189
app,
9290
);

clippy_lints/src/attrs.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
541541
cx,
542542
INLINE_ALWAYS,
543543
attr.span,
544-
&format!(
545-
"you have declared `#[inline(always)]` on `{}`. This is usually a bad idea",
546-
name
547-
),
544+
&format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
548545
);
549546
}
550547
}
@@ -720,7 +717,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
720717
let mut unix_suggested = false;
721718

722719
for (os, span) in mismatched {
723-
let sugg = format!("target_os = \"{}\"", os);
720+
let sugg = format!("target_os = \"{os}\"");
724721
diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect);
725722

726723
if !unix_suggested && is_unix(os) {

clippy_lints/src/bool_assert_comparison.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {
9898
cx,
9999
BOOL_ASSERT_COMPARISON,
100100
macro_call.span,
101-
&format!("used `{}!` with a literal bool", macro_name),
101+
&format!("used `{macro_name}!` with a literal bool"),
102102
"replace it with",
103-
format!("{}!(..)", non_eq_mac),
103+
format!("{non_eq_mac}!(..)"),
104104
Applicability::MaybeIncorrect,
105105
);
106106
}

clippy_lints/src/booleans.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
263263
}
264264
.and_then(|op| {
265265
Some(format!(
266-
"{}{}{}",
266+
"{}{op}{}",
267267
snippet_opt(cx, lhs.span)?,
268-
op,
269268
snippet_opt(cx, rhs.span)?
270269
))
271270
})
@@ -285,7 +284,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
285284
let path: &str = path.ident.name.as_str();
286285
a == path
287286
})
288-
.and_then(|(_, neg_method)| Some(format!("{}.{}()", snippet_opt(cx, receiver.span)?, neg_method)))
287+
.and_then(|(_, neg_method)| Some(format!("{}.{neg_method}()", snippet_opt(cx, receiver.span)?)))
289288
},
290289
_ => None,
291290
}

clippy_lints/src/cargo/common_metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, ignore_publish: b
4040
}
4141

4242
fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, field: &str) {
43-
let message = format!("package `{}` is missing `{}` metadata", package.name, field);
43+
let message = format!("package `{}` is missing `{field}` metadata", package.name);
4444
span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message);
4545
}
4646

clippy_lints/src/cargo/feature_name.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ fn lint(cx: &LateContext<'_>, feature: &str, substring: &str, is_prefix: bool) {
5757
},
5858
DUMMY_SP,
5959
&format!(
60-
"the \"{}\" {} in the feature name \"{}\" is {}",
61-
substring,
60+
"the \"{substring}\" {} in the feature name \"{feature}\" is {}",
6261
if is_prefix { "prefix" } else { "suffix" },
63-
feature,
6462
if is_negative { "negative" } else { "redundant" }
6563
),
6664
None,

clippy_lints/src/cargo/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl LateLintPass<'_> for Cargo {
196196
},
197197
Err(e) => {
198198
for lint in NO_DEPS_LINTS {
199-
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {}", e));
199+
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}"));
200200
}
201201
},
202202
}
@@ -212,7 +212,7 @@ impl LateLintPass<'_> for Cargo {
212212
},
213213
Err(e) => {
214214
for lint in WITH_DEPS_LINTS {
215-
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {}", e));
215+
span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}"));
216216
}
217217
},
218218
}

clippy_lints/src/cargo/multiple_crate_versions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) {
3737
cx,
3838
MULTIPLE_CRATE_VERSIONS,
3939
DUMMY_SP,
40-
&format!("multiple versions for dependency `{}`: {}", name, versions),
40+
&format!("multiple versions for dependency `{name}`: {versions}"),
4141
);
4242
}
4343
}

clippy_lints/src/casts/borrow_as_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(
3030
expr.span,
3131
"borrow as raw pointer",
3232
"try",
33-
format!("{}::ptr::{}!({})", core_or_std, macro_name, snip),
33+
format!("{core_or_std}::ptr::{macro_name}!({snip})"),
3434
Applicability::MachineApplicable,
3535
);
3636
}

clippy_lints/src/casts/cast_lossless.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@ pub(super) fn check(
4141
);
4242

4343
let message = if cast_from.is_bool() {
44-
format!(
45-
"casting `{0:}` to `{1:}` is more cleanly stated with `{1:}::from(_)`",
46-
cast_from, cast_to
47-
)
44+
format!("casting `{cast_from:}` to `{cast_to:}` is more cleanly stated with `{cast_to:}::from(_)`")
4845
} else {
49-
format!(
50-
"casting `{}` to `{}` may become silently lossy if you later change the type",
51-
cast_from, cast_to
52-
)
46+
format!("casting `{cast_from}` to `{cast_to}` may become silently lossy if you later change the type")
5347
};
5448

5549
span_lint_and_sugg(
@@ -58,7 +52,7 @@ pub(super) fn check(
5852
expr.span,
5953
&message,
6054
"try",
61-
format!("{}::from({})", cast_to, sugg),
55+
format!("{cast_to}::from({sugg})"),
6256
applicability,
6357
);
6458
}

clippy_lints/src/casts/cast_possible_truncation.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
103103
return;
104104
}
105105

106-
format!(
107-
"casting `{}` to `{}` may truncate the value{}",
108-
cast_from, cast_to, suffix,
109-
)
106+
format!("casting `{cast_from}` to `{cast_to}` may truncate the value{suffix}",)
110107
},
111108

112109
(ty::Adt(def, _), true) if def.is_enum() => {
@@ -142,20 +139,17 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
142139
CAST_ENUM_TRUNCATION,
143140
expr.span,
144141
&format!(
145-
"casting `{}::{}` to `{}` will truncate the value{}",
146-
cast_from, variant.name, cast_to, suffix,
142+
"casting `{cast_from}::{}` to `{cast_to}` will truncate the value{suffix}",
143+
variant.name,
147144
),
148145
);
149146
return;
150147
}
151-
format!(
152-
"casting `{}` to `{}` may truncate the value{}",
153-
cast_from, cast_to, suffix,
154-
)
148+
format!("casting `{cast_from}` to `{cast_to}` may truncate the value{suffix}",)
155149
},
156150

157151
(ty::Float(_), true) => {
158-
format!("casting `{}` to `{}` may truncate the value", cast_from, cast_to)
152+
format!("casting `{cast_from}` to `{cast_to}` may truncate the value")
159153
},
160154

161155
(ty::Float(FloatTy::F64), false) if matches!(cast_to.kind(), &ty::Float(FloatTy::F32)) => {

clippy_lints/src/casts/cast_possible_wrap.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
3535
cx,
3636
CAST_POSSIBLE_WRAP,
3737
expr.span,
38-
&format!(
39-
"casting `{}` to `{}` may wrap around the value{}",
40-
cast_from, cast_to, suffix,
41-
),
38+
&format!("casting `{cast_from}` to `{cast_to}` may wrap around the value{suffix}",),
4239
);
4340
}
4441
}

clippy_lints/src/casts/cast_ptr_alignment.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_f
4949
CAST_PTR_ALIGNMENT,
5050
expr.span,
5151
&format!(
52-
"casting from `{}` to a more-strictly-aligned pointer (`{}`) ({} < {} bytes)",
53-
cast_from,
54-
cast_to,
52+
"casting from `{cast_from}` to a more-strictly-aligned pointer (`{cast_to}`) ({} < {} bytes)",
5553
from_layout.align.abi.bytes(),
5654
to_layout.align.abi.bytes(),
5755
),

clippy_lints/src/casts/cast_sign_loss.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, c
1414
cx,
1515
CAST_SIGN_LOSS,
1616
expr.span,
17-
&format!(
18-
"casting `{}` to `{}` may lose the sign of the value",
19-
cast_from, cast_to
20-
),
17+
&format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"),
2118
);
2219
}
2320
}

clippy_lints/src/casts/cast_slice_different_sizes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: Optio
3535
CAST_SLICE_DIFFERENT_SIZES,
3636
expr.span,
3737
&format!(
38-
"casting between raw pointers to `[{}]` (element size {}) and `[{}]` (element size {}) does not adjust the count",
39-
start_ty.ty, from_size, end_ty.ty, to_size,
38+
"casting between raw pointers to `[{}]` (element size {from_size}) and `[{}]` (element size {to_size}) does not adjust the count",
39+
start_ty.ty, end_ty.ty,
4040
),
4141
|diag| {
4242
let ptr_snippet = source::snippet(cx, left_cast.span, "..");

clippy_lints/src/casts/char_lit_as_u8.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
3131
diag.span_suggestion(
3232
expr.span,
3333
"use a byte literal instead",
34-
format!("b{}", snippet),
34+
format!("b{snippet}"),
3535
applicability,
3636
);
3737
}

clippy_lints/src/casts/fn_to_numeric_cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
2525
cx,
2626
FN_TO_NUMERIC_CAST,
2727
expr.span,
28-
&format!("casting function pointer `{}` to `{}`", from_snippet, cast_to),
28+
&format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
2929
"try",
30-
format!("{} as usize", from_snippet),
30+
format!("{from_snippet} as usize"),
3131
applicability,
3232
);
3333
}

clippy_lints/src/casts/fn_to_numeric_cast_any.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
2323
cx,
2424
FN_TO_NUMERIC_CAST_ANY,
2525
expr.span,
26-
&format!("casting function pointer `{}` to `{}`", from_snippet, cast_to),
26+
&format!("casting function pointer `{from_snippet}` to `{cast_to}`"),
2727
"did you mean to invoke the function?",
28-
format!("{}() as {}", from_snippet, cast_to),
28+
format!("{from_snippet}() as {cast_to}"),
2929
applicability,
3030
);
3131
},

clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
2424
cx,
2525
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
2626
expr.span,
27-
&format!(
28-
"casting function pointer `{}` to `{}`, which truncates the value",
29-
from_snippet, cast_to
30-
),
27+
&format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"),
3128
"try",
32-
format!("{} as usize", from_snippet),
29+
format!("{from_snippet} as usize"),
3330
applicability,
3431
);
3532
}

clippy_lints/src/casts/ptr_as_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option<RustcVer
3333
let turbofish = match &cast_to_hir_ty.kind {
3434
TyKind::Infer => Cow::Borrowed(""),
3535
TyKind::Ptr(mut_ty) if matches!(mut_ty.ty.kind, TyKind::Infer) => Cow::Borrowed(""),
36-
_ => Cow::Owned(format!("::<{}>", to_pointee_ty)),
36+
_ => Cow::Owned(format!("::<{to_pointee_ty}>")),
3737
};
3838
span_lint_and_sugg(
3939
cx,
4040
PTR_AS_PTR,
4141
expr.span,
4242
"`as` casting between raw pointers without changing its mutability",
4343
"try `pointer::cast`, a safer alternative",
44-
format!("{}.cast{}()", cast_expr_sugg.maybe_par(), turbofish),
44+
format!("{}.cast{turbofish}()", cast_expr_sugg.maybe_par()),
4545
applicability,
4646
);
4747
}

clippy_lints/src/casts/unnecessary_cast.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ pub(super) fn check<'tcx>(
7171
cx,
7272
UNNECESSARY_CAST,
7373
expr.span,
74-
&format!(
75-
"casting to the same type is unnecessary (`{}` -> `{}`)",
76-
cast_from, cast_to
77-
),
74+
&format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"),
7875
"try",
7976
literal_str,
8077
Applicability::MachineApplicable,
@@ -101,9 +98,9 @@ fn lint_unnecessary_cast(cx: &LateContext<'_>, expr: &Expr<'_>, literal_str: &st
10198
cx,
10299
UNNECESSARY_CAST,
103100
expr.span,
104-
&format!("casting {} literal to `{}` is unnecessary", literal_kind_name, cast_to),
101+
&format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"),
105102
"try",
106-
format!("{}_{}", matchless.trim_end_matches('.'), cast_to),
103+
format!("{}_{cast_to}", matchless.trim_end_matches('.')),
107104
Applicability::MachineApplicable,
108105
);
109106
}

clippy_lints/src/checked_conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for CheckedConversions {
8282
item.span,
8383
"checked cast can be simplified",
8484
"try",
85-
format!("{}::try_from({}).is_ok()", to_type, snippet),
85+
format!("{to_type}::try_from({snippet}).is_ok()"),
8686
applicability,
8787
);
8888
}

0 commit comments

Comments
 (0)