Skip to content

Commit eabad8e

Browse files
committed
Auto merge of #9149 - kyoto7250:issue_9013, r=Jarcho
change applicability type to MaybeIncorrect in `explicit_counter_loop` close #9013 This PR changes applicability type to `MaybeIncorrect`, because the suggestion is not `MachineApplicable`. changelog: change applicability type to MaybeIncorrect in `explicit_counter_loop`
2 parents 3206fb4 + 134d0de commit eabad8e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clippy_lints/src/loops/explicit_counter_loop.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ pub(super) fn check<'tcx>(
3434
if let Some((name, ty, initializer)) = initialize_visitor.get_result();
3535
if is_integer_const(cx, initializer, 0);
3636
then {
37-
let mut applicability = Applicability::MachineApplicable;
37+
let mut applicability = Applicability::MaybeIncorrect;
38+
let span = expr.span.with_hi(arg.span.hi());
3839

3940
let int_name = match ty.map(Ty::kind) {
4041
// usize or inferred
4142
Some(ty::Uint(UintTy::Usize)) | None => {
4243
span_lint_and_sugg(
4344
cx,
4445
EXPLICIT_COUNTER_LOOP,
45-
expr.span.with_hi(arg.span.hi()),
46+
span,
4647
&format!("the variable `{}` is used as a loop counter", name),
4748
"consider using",
4849
format!(
@@ -63,11 +64,11 @@ pub(super) fn check<'tcx>(
6364
span_lint_and_then(
6465
cx,
6566
EXPLICIT_COUNTER_LOOP,
66-
expr.span.with_hi(arg.span.hi()),
67+
span,
6768
&format!("the variable `{}` is used as a loop counter", name),
6869
|diag| {
6970
diag.span_suggestion(
70-
expr.span.with_hi(arg.span.hi()),
71+
span,
7172
"consider using",
7273
format!(
7374
"for ({}, {}) in (0_{}..).zip({})",

0 commit comments

Comments
 (0)