Closed
Description
Code
fn test() {
loop {
let closure = || {
if true {
Err(1)
}
Ok(())
};
}
}
Current output
error[E0308]: mismatched types
--> src/lib.rs:5:17
|
4 | / if true {
5 | | Err(1)
| | ^^^^^^ expected `()`, found `Result<_, {integer}>`
6 | | }
| |_____________- expected this to be `()`
|
= note: expected unit type `()`
found enum `Result<_, {integer}>`
help: you might have meant to break the loop with this value
|
5 | break Err(1);
| +++++ +
Desired output
error[E0308]: mismatched types
--> src/lib.rs:4:13
|
4 | / if true {
5 | | Err(1)
| | ^^^^^^ expected `()`, found `Result<_, {integer}>`
6 | | }
| |_________- expected this to be `()`
|
= note: expected unit type `()`
found enum `Result<_, {integer}>`
Rationale and extra context
No response
Other cases
No response
Anything else?
No response