-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.