]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-move-error-with-note.rs
Auto merge of #101969 - reez12g:issue-101306, r=reez12g
[rust.git] / src / test / ui / borrowck / borrowck-move-error-with-note.rs
1 enum Foo {
2     Foo1(Box<u32>, Box<u32>),
3     Foo2(Box<u32>),
4     Foo3,
5 }
6
7
8
9 fn blah() {
10     let f = &Foo::Foo1(Box::new(1), Box::new(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::new(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() {}