#![feature(never_type)]
fn main() {
- let _: ! = { //~ ERROR mismatched types
- 'a: while break 'a {};
- };
+ // The `if false` expressions are simply to
+ // make sure we don't avoid checking everything
+ // simply because a few expressions are unreachable.
+
+ if false {
+ let _: ! = { //~ ERROR mismatched types
+ 'a: while break 'a {};
+ };
+ }
+
+ if false {
+ let _: ! = { //~ ERROR mismatched types
+ while false {
+ break
+ }
+ };
+ }
+
+ if false {
+ let _: ! = { //~ ERROR mismatched types
+ while false {
+ return
+ }
+ };
+ }
}
error[E0308]: mismatched types
- --> $DIR/break-while-condition.rs:14:16
+ --> $DIR/break-while-condition.rs:19:20
|
-LL | let _: ! = { //~ ERROR mismatched types
- | ________________^
-LL | | 'a: while break 'a {};
-LL | | };
- | |_____^ expected !, found ()
+LL | let _: ! = { //~ ERROR mismatched types
+ | ____________________^
+LL | | 'a: while break 'a {};
+LL | | };
+ | |_________^ expected !, found ()
|
= note: expected type `!`
found type `()`
-error: aborting due to previous error
+error[E0308]: mismatched types
+ --> $DIR/break-while-condition.rs:26:13
+ |
+LL | fn main() {
+ | - expected `()` because of default return type
+...
+LL | / while false {
+LL | | break
+LL | | }
+ | |_____________^ expected !, found ()
+ |
+ = note: expected type `!`
+ found type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/break-while-condition.rs:34:13
+ |
+LL | fn main() {
+ | - expected `()` because of default return type
+...
+LL | / while false {
+LL | | return
+LL | | }
+ | |_____________^ expected !, found ()
+ |
+ = note: expected type `!`
+ found type `()`
+
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.