-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
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 main() {
b"abc".iter().for_each(|x| dbg!(x))
}
Current output
error[E0308]: mismatched types
--> src/main.rs:2:32
|
2 | b"abc".iter().for_each(|x| dbg!(x))
| -^^^^^^^ expected `()`, found `&u8`
| |
| help: try adding a return type: `-> &u8`
|
Desired output
error[E0308]: mismatched types
--> src/main.rs:2:32
|
2 | b"abc".iter().for_each(|x| dbg!(x))
| -^^^^^^^ expected `()`, found `&u8`
| |
| help: try ignoring this value: `_ = dbg!(x)`
Rationale and extra context
closures have their return type inferred if not specified, so adding a return type to a closure will never fix a type mismatch error.
Other cases
No response
Rust Version
1.80.0
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.