summary refs log tree commit diff
path: root/src/test/compile-fail/by-move-pattern-binding.rs
blob: 8c0cf68c164b12901c8589dc11e3ceee17688ed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
enum E {
    Foo,
    Bar(~str)
}

struct S {
    x: E
}

fn f(x: ~str) {}

fn main() {
    let s = S { x: Bar(~"hello") };
    match &s.x {
        &Foo => {}
        &Bar(identifier) => f(copy identifier)  //~ ERROR cannot move
    };
    match &s.x {
        &Foo => {}
        &Bar(ref identifier) => println(*identifier)
    };
}