You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Borrowing a unique pointer temporarily invalidates its type (the pointer is no longer unique). We need to ensure that the original unique pointer is inaccessible while the borrow alias exists (except, possibly to create other borrows). This will be done in a separate pass (I've actually implemented most of the code as part of #2046) which will check when a ~T is borrowed that either:
the borrowee is an rvalue, in which case the only accessible copy is the borrowed ptr and everything is fine.
the borrowee is an lvalue that is rooted in a local variable. This local variable is then made inaccessible for the scope of the borrow.
The text was updated successfully, but these errors were encountered:
That may be true that preventing any kind of move is sufficient. It makes me a bit... worried to have a type that is untrue (a value with ~T might not, in fact, be the only pointer), but perhaps it does not lead to any problems so long as we prevent the actions that ~T would allow which are now unsafe (namely, moves).
Yeah, this is the origin of the concept of "immutable rooting" in the current safe reference checker.
Unique pointer is unique in the sense of the sole owner; there's no way to ensure that a temporary reference to its content isn't duplicated temporarily in some sub function, anyways.
Naturally there is no way to prevent the borrowed pointer from being duplicated, but that doesn't bother me, as the borrowed pointer has type &T (it does not promise to be unique, unlike the ~T). Still, I think you are correct and we can use a more liberal rule than I had originally envisioned.
Borrowing a unique pointer temporarily invalidates its type (the pointer is no longer unique). We need to ensure that the original unique pointer is inaccessible while the borrow alias exists (except, possibly to create other borrows). This will be done in a separate pass (I've actually implemented most of the code as part of #2046) which will check when a
~T
is borrowed that either:The text was updated successfully, but these errors were encountered: