Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time
Rust Internals [Unofficial]
May 21, 2026
I just realized the previous version can already prevent that, just not by default because it needs to place additional guard block manually. I added macro that will place this additional guard block automatically. I also updated the detection setting in raw pointer guard, within there immutable and mutable raw pointer can alias freely, the guard will give compile time error automatically if we accidentally call reference there. I also add new guard where immutable reference and immutable pointer can alias freely, the guard will give compile time error automatically if we accidentally call &mut T or *mut T there
The link to the repository of the new code is updated in the opening post
Discussion in the ATmosphere