Suggest removing value from break when invalid

This commit is contained in:
Esteban Küber 2018-01-28 11:14:09 -08:00
parent bacb5c58df
commit b7437c56f8
2 changed files with 9 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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