Skip to content

Destructuring struct with dtor by-ref #6344

Closed
@huonw

Description

@huonw
struct A { x: uint }

impl Drop for A {
    fn finalize(&self) {}
}

fn main() {
    let a = A { x: 0 };

    let x = &a.x;

    match a {
        A { x : ref x } => {}
    }
}
dtor-struct.rs:13:8: 13:26 error: deconstructing struct not allowed in pattern (it has a destructor)
dtor-struct.rs:13         A { x : ref x } => {}
                          ^~~~~~~~~~~~~~~~~~
error: aborting due to previous error

The let and match seem to be morally identical, but one is invalid. (Making the match form valid makes syntax extensions/macros easier.)

(Caused #6341.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions