logoalt Hacker News

maufl • today at 1:53 PM • 2 replies • view on HN

How likely is it that such a borrow checker could be "backported" to Rust? Maybe in a new edition?


Replies

verdagon • today at 2:13 PM

You know, it's not crazy. Niko wrote about lifetimes based on places back in 2024, [0] though it was in the context of shared-xor-mutable, which is consistent with Rust's spirit.

And Rust already supports forms of mutable aliasing already, such as with Cell, and GhostCell which is halfway towards Valen's approach. I would love to see someone augment GhostCell to have the sort of "invalidation" logic that group borrowing does. In fact, Plecra is working on something like that with their (WIP) "Exclusion Typing". [1]

On top of that, Polonius already thinks in terms of "paths", just like Valen does. So it's not so much a question of compiler design, but of language design, and how Rust would expose it to the user.

[0] https://smallcultfollowing.com/babysteps/blog/2024/06/02/the...

[1] https://dilated.me/blog/posts/introduction-to-exclusion-typi...

zozbot234 • today at 3:46 PM

It would have to take &Cell<T> references or the like in order to preserve the existing uniqueness properties for &mut T references. Not so different ultimately from what GhostCell, QCell, LCell etc. do already, except possibly simpler in some ways.