Skip to content

Borrow check needs to consider moves into patterns #3024

Closed
@bblum

Description

@bblum
struct Dummy {
    x: int
}

impl Dummy {
    fn new(x: int) -> Dummy {
        Dummy { x: x }
    }
}

impl Drop for Dummy {
    fn drop(&self) {
        error!("Destructor %d", self.x);
    }
}

fn welp<T>(a: ~T) -> T {
    let ~x = a;
    x
}

fn main() {
    let o = ~Dummy::new(5);
    welp(o);
}

(edit: a similar problem appears for let a@b = c; see comment below.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions