]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-move-error-with-note.rs
Update tests for changes to cannot move errors
[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         Foo::Foo1(num1,
13                   num2) => (),
14         Foo::Foo2(num) => (),
15         Foo::Foo3 => ()
16     }
17 }
18
19 struct S {
20     f: String,
21     g: String
22 }
23 impl Drop for S {
24     fn drop(&mut self) { println!("{}", self.f); }
25 }
26
27 fn move_in_match() {
28     match (S {f: "foo".to_string(), g: "bar".to_string()}) {
29         //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
30         S {
31             f: _s,
32             g: _t
33         } => {}
34     }
35 }
36
37 // from issue-8064
38 struct A {
39     a: Box<isize>,
40 }
41
42 fn free<T>(_: T) {}
43
44 fn blah2() {
45     let a = &A { a: box 1 };
46     match a.a {           //~ ERROR cannot move out of
47         n => {
48             free(n)
49         }
50     }
51     free(a)
52 }
53
54 fn main() {}