diff options
| author | bors <bors@rust-lang.org> | 2022-07-12 06:43:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-12 06:43:42 +0000 |
| commit | eabad8ea53235103e86688b2e39f63067a17ea87 (patch) | |
| tree | cf3fd0077181747429ae2f27c5d68b785eb27f85 | |
| parent | 3206fb4eb172600ff666c6409d112f2cfa0f88f9 (diff) | |
| parent | 134d0dee41846d1c0867fa3745b8de25b52ae7af (diff) | |
| download | rust-eabad8ea53235103e86688b2e39f63067a17ea87.tar.gz rust-eabad8ea53235103e86688b2e39f63067a17ea87.zip | |
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`
| -rw-r--r-- | clippy_lints/src/loops/explicit_counter_loop.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index fc50e8addcc..8e3ab26a947 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -34,7 +34,8 @@ pub(super) fn check<'tcx>( if let Some((name, ty, initializer)) = initialize_visitor.get_result(); if is_integer_const(cx, initializer, 0); then { - let mut applicability = Applicability::MachineApplicable; + let mut applicability = Applicability::MaybeIncorrect; + let span = expr.span.with_hi(arg.span.hi()); let int_name = match ty.map(Ty::kind) { // usize or inferred @@ -42,7 +43,7 @@ pub(super) fn check<'tcx>( span_lint_and_sugg( cx, EXPLICIT_COUNTER_LOOP, - expr.span.with_hi(arg.span.hi()), + span, &format!("the variable `{}` is used as a loop counter", name), "consider using", format!( @@ -63,11 +64,11 @@ pub(super) fn check<'tcx>( span_lint_and_then( cx, EXPLICIT_COUNTER_LOOP, - expr.span.with_hi(arg.span.hi()), + span, &format!("the variable `{}` is used as a loop counter", name), |diag| { diag.span_suggestion( - expr.span.with_hi(arg.span.hi()), + span, "consider using", format!( "for ({}, {}) in (0_{}..).zip({})", |
