Skip to content

Commit eb7ad1c

Browse files
committed
cargo dev fmt
1 parent 870ae36 commit eb7ad1c

File tree

3 files changed

+61
-37
lines changed

3 files changed

+61
-37
lines changed

clippy_lints/src/eq_op.rs

+30-18
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
124124
&& !rcpy
125125
&& implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right).into()])
126126
{
127-
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |diag| {
128-
let lsnip = snippet(cx, l.span, "...").to_string();
129-
diag.span_suggestion(
130-
left.span,
131-
"use the left value directly",
132-
lsnip,
133-
Applicability::MaybeIncorrect, // FIXME #2597
134-
);
135-
})
127+
span_lint_and_then(
128+
cx,
129+
OP_REF,
130+
e.span,
131+
"needlessly taken reference of left operand",
132+
|diag| {
133+
let lsnip = snippet(cx, l.span, "...").to_string();
134+
diag.span_suggestion(
135+
left.span,
136+
"use the left value directly",
137+
lsnip,
138+
Applicability::MaybeIncorrect, // FIXME #2597
139+
);
140+
},
141+
)
136142
} else if !lcpy
137143
&& rcpy
138144
&& implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()])
@@ -161,15 +167,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
161167
if (requires_ref || lcpy)
162168
&& implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right).into()])
163169
{
164-
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |diag| {
165-
let lsnip = snippet(cx, l.span, "...").to_string();
166-
diag.span_suggestion(
167-
left.span,
168-
"use the left value directly",
169-
lsnip,
170-
Applicability::MaybeIncorrect, // FIXME #2597
171-
);
172-
})
170+
span_lint_and_then(
171+
cx,
172+
OP_REF,
173+
e.span,
174+
"needlessly taken reference of left operand",
175+
|diag| {
176+
let lsnip = snippet(cx, l.span, "...").to_string();
177+
diag.span_suggestion(
178+
left.span,
179+
"use the left value directly",
180+
lsnip,
181+
Applicability::MaybeIncorrect, // FIXME #2597
182+
);
183+
},
184+
)
173185
}
174186
},
175187
// foo == &bar

clippy_lints/src/redundant_static_lifetimes.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ impl RedundantStaticLifetimes {
5353
if lifetime.ident.name == rustc_span::symbol::kw::StaticLifetime {
5454
let snip = snippet(cx, borrow_type.ty.span, "<type>");
5555
let sugg = format!("&{}", snip);
56-
span_lint_and_then(cx, REDUNDANT_STATIC_LIFETIMES, lifetime.ident.span, reason, |diag| {
57-
diag.span_suggestion(
58-
ty.span,
59-
"consider removing `'static`",
60-
sugg,
61-
Applicability::MachineApplicable, //snippet
62-
);
63-
});
56+
span_lint_and_then(
57+
cx,
58+
REDUNDANT_STATIC_LIFETIMES,
59+
lifetime.ident.span,
60+
reason,
61+
|diag| {
62+
diag.span_suggestion(
63+
ty.span,
64+
"consider removing `'static`",
65+
sugg,
66+
Applicability::MachineApplicable, //snippet
67+
);
68+
},
69+
);
6470
}
6571
},
6672
_ => {},

clippy_lints/src/types.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -608,17 +608,23 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnitValue {
608608
if higher::is_from_for_desugar(local) {
609609
return;
610610
}
611-
span_lint_and_then(cx, LET_UNIT_VALUE, stmt.span, "this let-binding has unit value", |diag| {
612-
if let Some(expr) = &local.init {
613-
let snip = snippet_with_macro_callsite(cx, expr.span, "()");
614-
diag.span_suggestion(
615-
stmt.span,
616-
"omit the `let` binding",
617-
format!("{};", snip),
618-
Applicability::MachineApplicable, // snippet
619-
);
620-
}
621-
});
611+
span_lint_and_then(
612+
cx,
613+
LET_UNIT_VALUE,
614+
stmt.span,
615+
"this let-binding has unit value",
616+
|diag| {
617+
if let Some(expr) = &local.init {
618+
let snip = snippet_with_macro_callsite(cx, expr.span, "()");
619+
diag.span_suggestion(
620+
stmt.span,
621+
"omit the `let` binding",
622+
format!("{};", snip),
623+
Applicability::MachineApplicable, // snippet
624+
);
625+
}
626+
},
627+
);
622628
}
623629
}
624630
}

0 commit comments

Comments
 (0)