-
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 lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-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
fn main() {
let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n) ).sum();
}
This will suggest adding a ;
error[E0308]: mismatched types
--> src/main.rs:3:43
|
3 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n) ).sum();
| ^^^^^^^
| |
| expected `()`, found `&&{integer}`
| expected this to be `()`
| help: consider using a semicolon here
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
But doing so will "break" the code even more and not fix the error:
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
--> src/main.rs:2:50
|
2 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n); ).sum();
| ^ expected one of `)`, `,`, `.`, `?`, or an operator
error[E0308]: mismatched types
--> src/main.rs:2:43
|
2 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n); ).sum();
| ^^^^^^^
| |
| expected `()`, found `&&{integer}`
| expected this to be `()`
| help: consider using a semicolon here
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Could rust suggest adding { }
around the macro?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-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.