logoalt Hacker News

steveklabnikyesterday at 8:53 PM2 repliesview on HN

> if they want that information from the borrow checker how would they get it?

If you want to compare if two pointers point to the same place, you use https://doc.rust-lang.org/stable/std/ptr/fn.eq.html

Rust just defaults to value equality over reference equality. This is true for everything, not just ZSTs.

(I find the post's framing of "it's stored in the borrow checker" to be a bit odd, but I can't put my finger on exactly what it is. The borrow checker doesn't determine these sorts of semantics, it checks for liveliness and aliasing, so "do these pointers alias" isn't inherently not the borrow checker's job, it just strikes me as an odd way to put it. Maybe it's because you don't "ask the borrow checker for that information" really.)


Replies

ketzuyesterday at 9:02 PM

As the article itself discusses, pointers to zero sized objects are not necessarily different (they write it is only the case in debug mode).

> I find the post's framing of "it's stored in the borrow checker" to be a bit odd

That's exactly what I wanted to say as well.

I feel like it would have been better to just skip the borrow checker mention and just go "in rust this can not be done reliably ..(section about pointers being the same)"