]> git.lizzy.rs Git - rust.git/blob - src/test/ui/moves/moves-based-on-type-block-bad.rs
Auto merge of #55519 - fhartwig:hashmap-index-example, r=Centril
[rust.git] / src / test / ui / moves / moves-based-on-type-block-bad.rs
1 // ignore-tidy-linelength
2
3 #![feature(box_patterns)]
4 #![feature(box_syntax)]
5
6 struct S {
7     x: Box<E>
8 }
9
10 enum E {
11     Foo(Box<S>),
12     Bar(Box<isize>),
13     Baz
14 }
15
16 fn f<G>(s: &S, g: G) where G: FnOnce(&S) {
17     g(s)
18 }
19
20 fn main() {
21     let s = S { x: box E::Bar(box 42) };
22     loop {
23         f(&s, |hellothere| {
24             match hellothere.x { //~ ERROR cannot move out
25                                  //~| cannot move out of borrowed content
26                 box E::Foo(_) => {}
27                 box E::Bar(x) => println!("{}", x.to_string()),
28                 box E::Baz => {}
29             }
30         })
31     }
32 }