Suggest removing value from break
when invalid
This commit is contained in:
parent
bacb5c58df
commit
b7437c56f8
@ -119,6 +119,11 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
||||
kind.name())
|
||||
.span_label(e.span,
|
||||
"can only break with a value inside `loop`")
|
||||
.span_suggestion(e.span,
|
||||
&format!("instead, use `break` on its own \
|
||||
without a value inside this `{}` loop",
|
||||
kind.name()),
|
||||
"break".to_string())
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,10 @@ error[E0571]: `break` with value from a `for` loop
|
||||
|
|
||||
22 | break 22 //~ ERROR `break` with value from a `for` loop
|
||||
| ^^^^^^^^ can only break with a value inside `loop`
|
||||
help: instead, use `break` on its own without a value inside this `for` loop
|
||||
|
|
||||
22 | break //~ ERROR `break` with value from a `for` loop
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user