More tests.

This commit is contained in:
Tor Hovland 2021-04-24 19:00:24 +02:00
parent 8bc81a0e4d
commit 05a5a1128f
2 changed files with 51 additions and 7 deletions

View File

@ -1,5 +1,27 @@
fn main() {
let x: i8 = loop {
10 //~ ERROR mismatched types
let a: i8 = loop {
1 //~ ERROR mismatched types
};
let b: i8 = loop {
break 1;
};
}
fn foo() -> i8 {
let a: i8 = loop {
1 //~ ERROR mismatched types
};
let b: i8 = loop {
break 1;
};
loop {
1 //~ ERROR mismatched types
}
loop {
return 1;
}
}

View File

@ -1,14 +1,36 @@
error[E0308]: mismatched types
--> $DIR/loop-no-implicit-break.rs:3:9
|
LL | 10
| ^^ expected `()`, found integer
LL | 1
| ^ expected `()`, found integer
|
help: you might have meant to break the loop with this value
|
LL | break 10;
| ^^^^^ ^
LL | break 1;
| ^^^^^ ^
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/loop-no-implicit-break.rs:13:9
|
LL | 1
| ^ expected `()`, found integer
|
help: you might have meant to break the loop with this value
|
LL | break 1;
| ^^^^^ ^
error[E0308]: mismatched types
--> $DIR/loop-no-implicit-break.rs:21:9
|
LL | 1
| ^ expected `()`, found integer
|
help: you might have meant to return this value
|
LL | return 1;
| ^^^^^^ ^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.