]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/moves-based-on-type-exprs.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Tests that references to move-by-default values trigger moves when
12 // they occur as part of various kinds of expressions.
15 struct Foo
<A
> { f: A }
16 fn guard(_s
: String
) -> bool {panic!()}
17 fn touch
<A
>(_a
: &A
) {}
20 let x
= "hi".to_string();
22 touch(&x
); //~ ERROR use of moved value: `x`
26 let x
= "hi".to_string();
28 touch(&x
); //~ ERROR use of moved value: `x`
32 let x
= vec
!(1, 2, 3);
38 let x
= "hi".to_string();
39 let y
= "ho".to_string();
45 touch(&x
); //~ ERROR use of moved value: `x`
46 touch(&y
); //~ ERROR use of moved value: `y`
50 let x
= "hi".to_string();
51 let y
= "ho".to_string();
56 touch(&x
); //~ ERROR use of moved value: `x`
57 touch(&y
); //~ ERROR use of moved value: `y`
61 let x
= "hi".to_string();
62 let y
= "ho".to_string();
68 touch(&x
); //~ ERROR use of moved value: `x`
73 let x
= "hi".to_string();
75 touch(&x
); //~ ERROR use of moved value: `x`
79 let x
= "hi".to_string();
81 touch(&x
); //~ ERROR use of moved value: `x`
85 let x
= vec
!("hi".to_string());
86 let _y
= x
.into_iter().next().unwrap();
87 touch(&x
); //~ ERROR use of moved value: `x`
91 let x
= vec
!("hi".to_string());
92 let _y
= [x
.into_iter().next().unwrap(); 1];
93 touch(&x
); //~ ERROR use of moved value: `x`
97 let mut x
= vec
!("hi".to_string(), "ho".to_string());