-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New destructor semantics #8861
Copy link
Copy link
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-type-systemArea: Type systemArea: Type systemP-mediumMedium priorityMedium priority
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-type-systemArea: Type systemArea: Type systemP-mediumMedium priorityMedium priority
Type
Fields
Give feedbackNo fields configured for issues without a type.
Tracking issue for RFC #769, Sound Generic Drop.
Original description follows:
We agreed in a meeting to replace the unsafe destructor code with the rule that a value with a destructor must only contain values of lifetime strictly greater than the value to be destructed. The idea is to prevent values from referencing one another. Permitting borrowed values in destructors enables a number of RAII causes and helps to eliminate the need for once fns. This also relies on the change to prevent
&pointers from being placed within managed boxes (which I think has already been made).I have to figure out precisely how to formalize this rule still. =)
Nominating for backwards compat.
Update from @pnkfelix : Much of this is implemented, and so pnkfelix is listing out specific subtasks, issues, and/or PRs, to try to track what is done and what is left to do:
CodeExtent::Remaindervariant; pre-req for new scoping/drop rules. #21657Dropfrom adding new bounds on a type param; Issue Prohibit specialized drops #8142<iterator-expr>only live for the for-loop itself. (i.e. turn for-loops into a terminating scope). Addresses the bulk Issue new scoping rules for safe dtors can yield spurious semi-colon or trailing unit expr #21114. Resolved by makefor PAT in ITER_EXPR { ... }a terminating-scope for ITER_EXPR. #21984#[unsafe_destructor]attribute entirely; Issue Once confident in dropck: remove#[unsafe_destructor]attribute #22196Far future / No longer deemed necessary
Vec<T>,Box<T>,Rc<T>, etc, covariant with respect toT. Discussed on issue new scoping rules for safe dtors may benefit from variance on type params #21198 (may not be a strict requirement for landing new destructor semantics).(See also #22321)