Skip to content

amend RFC 769 (sound generic drop) re: drop via &mut T overwrite #1103

Closed
@pnkfelix

Description

@pnkfelix

spawned off of: #769 (comment) :

@glaebhoerl notes:

The impl Drop for T can also be invoked through an &mut T, e.g. assignment through it invokes the destructor on the previous value. This possibility doesn't appear to be covered by "the type of v owns data of type T".

@pnkfelix replies:

any destructor that actually writes to a contained &'a mut T or &'a RefCell<T> within a value v will need to either:

  • be attached to a type that is parametric in 'a (which will force 'a to strictly outlive v, and thus I think will force T also to strictly outlive v), or
  • be hidden behind a generic type with some method that does the write to &'a mut T or &'a RefCell<T> -- but again, I think we will again here see the 'a leak up and end up being forced to strictly outlive v?

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions