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`
This commit is contained in:
commit
eabad8ea53
1 changed files with 5 additions and 4 deletions
|
|
@ -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({})",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue