pub static WRITES_THROUGH_IMMUTABLE_POINTER: &'static Lint
Expand description
The writes_through_immutable_pointer
lint detects writes through pointers derived from
shared references.
§Example
ⓘ
#![feature(const_mut_refs)]
const WRITE_AFTER_CAST: () = unsafe {
let mut x = 0;
let ptr = &x as *const i32 as *mut i32;
*ptr = 0;
};
{{produces}}
§Explanation
Shared references are immutable (when there is no UnsafeCell
involved),
and writing through them or through pointers derived from them is Undefined Behavior.
The compiler recently learned to detect such Undefined Behavior during compile-time
evaluation, and in the future this will raise a hard error.