Open
Description
openedon Oct 24, 2023
The following program compiles and runs fine, but rust-analyzer shows an error
at **wrap = 6;
line.
cannot mutate immutable variable `wrap`
struct WrapPtr(*mut u32);
impl std::ops::Deref for WrapPtr {
type Target = *mut u32;
fn deref(&self) -> &Self::Target {
&self.0
}
}
fn main() {
let mut x = 0u32;
{
let wrap = WrapPtr(&mut x);
unsafe {
**wrap = 6;
}
}
assert_eq!(x, 6);
}
rust-analyzer version: VS Code: rust-analyzer version: 0.3.1705-standalone (10872952c 2023-10-22)
rustc version: rustc 1.75.0-nightly (cd674d617 2023-10-24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment