Skip to content

Commit 20cdd65

Browse files
committed
Do not suggest using ! with break
1 parent 9cb664c commit 20cdd65

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/librustc_typeck/check/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
559559
ty::Char => "'a'",
560560
ty::Int(_) | ty::Uint(_) => "42",
561561
ty::Float(_) => "3.14159",
562+
ty::Error | ty::Never => return,
562563
_ => "value",
563564
});
564565
err.span_suggestion(expr.span, msg, sugg, Applicability::HasPlaceholders);

src/test/ui/loops/loop-break-value.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ error[E0308]: mismatched types
9090
--> $DIR/loop-break-value.rs:4:31
9191
|
9292
LL | let val: ! = loop { break break; };
93-
| ^^^^^
94-
| |
95-
| expected !, found ()
96-
| help: give it a value of the expected type: `break value`
93+
| ^^^^^ expected !, found ()
9794
|
9895
= note: expected type `!`
9996
found type `()`

0 commit comments

Comments
 (0)