summaryrefslogtreecommitdiffstats
path: root/tests/ui/moves/moves-based-on-type-block-bad.rs
blob: eca33167f454ae6ea9ee7777c1c45a6815a86a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![feature(box_patterns)]


struct S {
    x: Box<E>
}

enum E {
    Foo(Box<S>),
    Bar(Box<isize>),
    Baz
}

fn f<G>(s: &S, g: G) where G: FnOnce(&S) {
    g(s)
}

fn main() {
    let s = S { x: Box::new(E::Bar(Box::new(42))) };
    loop {
        f(&s, |hellothere| {
            match hellothere.x { //~ ERROR cannot move out
                box E::Foo(_) => {}
                box E::Bar(x) => println!("{}", x.to_string()),
                box E::Baz => {}
            }
        })
    }
}