-
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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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
Given the following code:
unsafe fn id(x: u32) -> u32 {
x
}
fn main() {
let y = unsafe {
unsafe { id(3) } + unsafe { id(4) }
};
println!("{}", y);
}
The current output is:
error: expected expression, found `+`
--> src/main.rs:7:26
|
7 | unsafe { id(3) } + unsafe { id(4) }
| ^ expected expression
error[E0308]: mismatched types
--> src/main.rs:7:18
|
7 | unsafe { id(3) } + unsafe { id(4) }
| ^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `u32`
For more information about this error, try `rustc --explain E0308`.
Ideally the output should look like:
error: expected expression, found `+`
--> src/main.rs:7:26
|
7 | unsafe { id(3) } + unsafe { id(4) }
| ^ expected expression
|
help: parentheses are required to parse this as an expression
|
7 | (unsafe { id(3) }) + unsafe { id(4) }
| + +
Related to #67347
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.