-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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:
let mut a = std::mem::MaybeUninit::new(10);
unsafe { std::ptr::read(a.as_ptr()) } == 10;
Rust reports error:
error: expected expression, found `==`
--> src/main.rs:3:43
|
3 | unsafe { std::ptr::read(a.as_ptr()) } == 10;
| ^^ expected expression
However, if I change ==
to +
, Rust would instead mentions that a pair of parens should be added to wrap the block:
error: expected expression, found `+`
--> src/main.rs:3:43
|
3 | unsafe { std::ptr::read(a.as_ptr()) } + 10;
| ------------------------------------- ^ expected expression
| |
| help: parentheses are required to parse this as an expression: `(unsafe { std::ptr::read(a.as_ptr()) })`
I guess the error message should probably be updated for the ==
case as well.
Metadata
Metadata
Assignees
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.