about summary refs log tree commit diff
path: root/src/test/compile-fail/by-move-pattern-binding.rs
blob: f05931d7fb40885ff793dd0cc9c81b69749a95d1 (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(identifier.clone())  //~ ERROR cannot move
    };
    match &s.x {
        &Foo => {}
        &Bar(ref identifier) => println!("{}", *identifier)
    };
}