]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-move-error-with-note.rs
Rollup merge of #59880 - solson:transmute-float, r=alexcrichton
[rust.git] / src / test / ui / borrowck / borrowck-move-error-with-note.rs
1 #![feature(box_syntax)]
2
3 enum Foo {
4     Foo1(Box<u32>, Box<u32>),
5     Foo2(Box<u32>),
6     Foo3,
7 }
8
9 fn blah() {
10     let f = &Foo::Foo1(box 1, box 2);
11     match *f {             //~ ERROR cannot move out of
12                            //~| cannot move out
13         Foo::Foo1(num1,
14                   num2) => (),
15         Foo::Foo2(num) => (),
16         Foo::Foo3 => ()
17     }
18 }
19
20 struct S {
21     f: String,
22     g: String
23 }
24 impl Drop for S {
25     fn drop(&mut self) { println!("{}", self.f); }
26 }
27
28 fn move_in_match() {
29     match (S {f: "foo".to_string(), g: "bar".to_string()}) {
30         S {         //~ ERROR cannot move out of type `S`, which implements the `Drop` trait
31         //~| cannot move out of here
32             f: _s,
33             g: _t
34         } => {}
35     }
36 }
37
38 // from issue-8064
39 struct A {
40     a: Box<isize>,
41 }
42
43 fn free<T>(_: T) {}
44
45 fn blah2() {
46     let a = &A { a: box 1 };
47     match a.a {           //~ ERROR cannot move out of
48                           //~| cannot move out
49         n => {
50             free(n)
51         }
52     }
53     free(a)
54 }
55
56 fn main() {}