Hacker News new | ask | show | jobs
by kibwen 4129 days ago
Note that Rust doesn't eliminate aliasing, it merely tracks it very precisely. Taking a reference is a trivial way to create an alias, though obviously while the alias is alive you are restricted in what you can do to the referent.
2 comments

Aliasing is only a problem because they prevent you assuming two values are independent of each other: a write to one could affect the other, if they are aliased.

When you enforce immutability of aliases, as Rust does, aliasing stops being a special case. The underlying value may be the same, but the behaviour is identical to when they are independent.

The only time you have problems thereafter is when you do weird things with the value's address which only coincidentally works. For example, comparing interned strings or Java's Integer objects using == works for other interned strings and small integers, respectively.

How about "eliminating problems caused by aliasing", which I suppose is a subset of memory safety.