Skip to content

Handle borrowing of unique pointers correctly #2204

Description

@nikomatsakis

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:

  1. the borrowee is an rvalue, in which case the only accessible copy is the borrowed ptr and everything is fine.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regions

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions