Skip to content

Commit 464239d

Browse files
committed
Improve "Why is this bad" section and inline sugg variable
1 parent e8dee28 commit 464239d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clippy_lints/src/manual_ilog2.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare_clippy_lint! {
1515
/// Checks for expressions like `31 - x.leading_zeros()` or `x.ilog(2)` which are manual
1616
/// reimplementations of `x.ilog2()`
1717
/// ### Why is this bad?
18-
/// It is easier to read and understand
18+
/// Manual reimplementations of `ilog2` increase code complexity for little benefit.
1919
/// ### Example
2020
/// ```no_run
2121
/// let x: u32 = 5;
@@ -90,14 +90,13 @@ impl LateLintPass<'_> for ManualIlog2 {
9090
&& let LitKind::Int(Pu128(2), _) = lit.node
9191
&& cx.typeck_results().expr_ty(reciever).is_integral()
9292
{
93-
let sugg = snippet_with_applicability(cx, reciever.span, "..", &mut applicability);
9493
span_lint_and_sugg(
9594
cx,
9695
MANUAL_ILOG2,
9796
expr.span,
9897
"manually reimplementing `ilog2`",
9998
"consider using .ilog2()",
100-
format!("{sugg}.ilog2()"),
99+
format!("{}.ilog2()", snippet_with_applicability(cx, reciever.span, "..", &mut applicability)),
101100
applicability,
102101
);
103102
}

0 commit comments

Comments
 (0)