Closed
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