Skip to content

Moves into patterns (also irrefutable patterns) always copy #3097

Closed
@nikomatsakis

Description

@nikomatsakis

The following test:

struct foo {
    x: int;

    new(x: int) {
        self.x = x;
    }

    drop {
        error!{"Hello, world!"};
    }
}

fn main() {
    let x = ~foo(1);
    error!{"x.x: %d", x.x};
    let ~y <- x;
    error!{"y.x: %d", y.x};

    alt move y {
      copy z {}
    }
}

prints Hello World! three times. I think that patterns (both refutable/irrefutable, which are different code paths) just always copy in trans.

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions