Skip to content

Commit 05a5a11

Browse files
author
Tor Hovland
committed
More tests.
1 parent 8bc81a0 commit 05a5a11

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
fn main() {
2-
let x: i8 = loop {
3-
10 //~ ERROR mismatched types
2+
let a: i8 = loop {
3+
1 //~ ERROR mismatched types
44
};
5+
6+
let b: i8 = loop {
7+
break 1;
8+
};
9+
}
10+
11+
fn foo() -> i8 {
12+
let a: i8 = loop {
13+
1 //~ ERROR mismatched types
14+
};
15+
16+
let b: i8 = loop {
17+
break 1;
18+
};
19+
20+
loop {
21+
1 //~ ERROR mismatched types
22+
}
23+
24+
loop {
25+
return 1;
26+
}
527
}
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
error[E0308]: mismatched types
22
--> $DIR/loop-no-implicit-break.rs:3:9
33
|
4-
LL | 10
5-
| ^^ expected `()`, found integer
4+
LL | 1
5+
| ^ expected `()`, found integer
66
|
77
help: you might have meant to break the loop with this value
88
|
9-
LL | break 10;
10-
| ^^^^^ ^
9+
LL | break 1;
10+
| ^^^^^ ^
1111

12-
error: aborting due to previous error
12+
error[E0308]: mismatched types
13+
--> $DIR/loop-no-implicit-break.rs:13:9
14+
|
15+
LL | 1
16+
| ^ expected `()`, found integer
17+
|
18+
help: you might have meant to break the loop with this value
19+
|
20+
LL | break 1;
21+
| ^^^^^ ^
22+
23+
error[E0308]: mismatched types
24+
--> $DIR/loop-no-implicit-break.rs:21:9
25+
|
26+
LL | 1
27+
| ^ expected `()`, found integer
28+
|
29+
help: you might have meant to return this value
30+
|
31+
LL | return 1;
32+
| ^^^^^^ ^
33+
34+
error: aborting due to 3 previous errors
1335

1436
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)