]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-move-error-with-note.rs
Auto merge of #59887 - eddyb:safer-metadata, r=Zoxc
[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         //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
31         //~| cannot move out of here
32         S {
33             f: _s,
34             g: _t
35         } => {}
36     }
37 }
38
39 // from issue-8064
40 struct A {
41     a: Box<isize>,
42 }
43
44 fn free<T>(_: T) {}
45
46 fn blah2() {
47     let a = &A { a: box 1 };
48     match a.a {           //~ ERROR cannot move out of
49                           //~| cannot move out
50         n => {
51             free(n)
52         }
53     }
54     free(a)
55 }
56
57 fn main() {}