Fix control flow check for breaking with diverging values
This commit is contained in:
parent
1d2726726f
commit
5a440f1bc2
3 changed files with 28 additions and 1 deletions
13
src/test/ui/break-diverging-value.rs
Normal file
13
src/test/ui/break-diverging-value.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
fn loop_break_return() -> i32 {
|
||||
let loop_value = loop { break return 0 }; // ok
|
||||
}
|
||||
|
||||
fn loop_break_loop() -> i32 {
|
||||
let loop_value = loop { break loop {} }; // ok
|
||||
}
|
||||
|
||||
fn loop_break_break() -> i32 { //~ ERROR mismatched types
|
||||
let loop_value = loop { break break };
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
11
src/test/ui/break-diverging-value.stderr
Normal file
11
src/test/ui/break-diverging-value.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/break-diverging-value.rs:9:26
|
||||
|
|
||||
LL | fn loop_break_break() -> i32 {
|
||||
| ---------------- ^^^ expected `i32`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue