External Publication
Visit Post

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

Rust Internals [Unofficial] May 17, 2026
Source

fuji-184:

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

Unless the respondents to this survey are extremely unrepresentative, the vast majority of Rust users do in fact run cargo clippy (and roughly a quarter, including myself, do so after every code change): Rust compiler performance survey 2025 results | Rust Blog

Running that two-word cargo clippy command currently has 67 deny-by-default lints (Clippy Lints) and a little over 400 warn-by-default lints. Incredibly useful, even without a more thorough setup.

fuji-184:

So I do not really understand what you mean by “limiting productivity”.

I was referring to a language where "as many errors as possible are checked at compile time" -- namely, where all errors are checked at compile time -- not just your suggestion. Imagine a language which lets you use all the powers you could in C or unsafe Rust but requires you to provide a rigorous computer-readable mathematical proof that your program is sound. That's an extreme which would be difficult to work with. Presumably, it could still be worth its cost in rare cases, but not usually.

fuji-184:

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?

I think detecting it in Miri would be quite feasible. I'm not sure how hard it would be to check at compile time, I've never tried to implement a lint.

Discussion in the ATmosphere

Loading comments...