External Publication
Visit Post

Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time

Rust Internals [Unofficial] May 17, 2026
Source

So right now, there is still no warning for it. A ready to use compile time check is better than a compile time check that requires a complex Clippy setup, because realistically, most general users not using that setup anyway, which means the end result for the majority of users is effectively the same

I just learned that Rust built in macros do not use syn :]. In that case, this could be implemented as built in macro using the method like the other built in macros, since it would have access to much broader contextual information than user space code that relies on syn

I mean, as long as a check can be performed at compile time, Rust usually performs it. Even having two &mut references to the same memory is checked at compile time, so why not also check for two pointer and reference pointing to the same memory, especially if it is already possible to detect it?

If the macro were implemented the same way as Rust’s built in proc macros, this check should have overhead characteristics similar to existing built in attribute macros like #[test], #[derive], and others, because it would likely have direct access to the token context at the compiler level

And this check does not limit the language’s flexibility, because we can leave the checked area at any time simply by writing code outside the guard. So I do not really understand what you mean by “limiting productivity”. This should improve productivity instead, because errors appear immediately at compile time so feedback is fast, errors are not silent

Discussion in the ATmosphere

Loading comments...