Skip to content

Destructors and wild-card patterns (when do destructors run?) #3181

Closed
@catamorphism

Description

@catamorphism

Context: #2735

I added a special-case to trans for let _ = e; where e has a destructor, so this gets treated the same way as e;. However, @nikomatsakis points out that this isn't an entirely satisfactory solution, because for consistency, we'd also want to drop the RHS of the tuple in let (x, _) = e; early, or indeed, any sub-component of a data structure that's bound to a pattern with a deeply-nested _ in the corresponding position.

Since we don't have a semantics for when destructors run, it's a little hard to say what the right thing is, but whatever we do should be consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-destructorsArea: Destructors (`Drop`, …)E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions