Aliasing rules for Unique
· Issue #384 · rust-lang/unsafe-code-guidelines (original) (raw)
Unique
is an ancient type that was originally intended to get noalias
semantics, but hasn't been treated specially by the compiler in a while. However it could be a useful building block to let programmers inform the compiler about optimization potential.
Unique
would be noalias
without dereferenceable
, which is not a combination that Stacked Borrows supports. However I hope that the next aliasing model will support that combination (it is also needed for the &Header issue), and then we could consider imbuing Unique
with special semantics again.
This is mostly orthogonal to #326, which boils down to deciding whether we want to use Unique
in standard library containers or not.