Closed
Description
The following program surprisingly does not compile:
fn main() {
let x = &mut 2;
let _val = {{x} as *mut i32};
}
The error is rather confusing, somehow it expects something to be ()
:
error: expected expression, found keyword `as`
--> src/main.rs:3:21
|
3 | let _val = {{x} as *mut i32};
| ^^ expected expression
error[E0308]: mismatched types
--> src/main.rs:3:18
|
1 | fn main() {
| - expected `()` because of default return type
2 | let x = &mut 2;
3 | let _val = {{x} as *mut i32};
| ^ expected (), found mutable reference
|
= note: expected type `()`
found type `&mut {integer}`
If I remove either of the pair of braces in the last line, it works as expected.