1 // Tests that references to move-by-default values trigger moves when
2 // they occur as part of various kinds of expressions.
6 fn guard(_s: String) -> bool {panic!()}
10 let x = "hi".to_string();
12 touch(&x); //~ ERROR borrow of moved value: `x`
16 let x = "hi".to_string();
18 touch(&x); //~ ERROR borrow of moved value: `x`
22 let x = vec![1, 2, 3];
28 let x = "hi".to_string();
29 let y = "ho".to_string();
35 touch(&x); //~ ERROR borrow of moved value: `x`
36 touch(&y); //~ ERROR borrow of moved value: `y`
40 let x = "hi".to_string();
41 let y = "ho".to_string();
46 touch(&x); //~ ERROR borrow of moved value: `x`
47 touch(&y); //~ ERROR borrow of moved value: `y`
51 let x = "hi".to_string();
52 let y = "ho".to_string();
58 touch(&x); //~ ERROR borrow of moved value: `x`
63 let x = "hi".to_string();
65 touch(&x); //~ ERROR borrow of moved value: `x`
69 let x = "hi".to_string();
71 touch(&x); //~ ERROR borrow of moved value: `x`
75 let x = vec!["hi".to_string()];
76 let _y = x.into_iter().next().unwrap();
77 touch(&x); //~ ERROR borrow of moved value: `x`
81 let x = vec!["hi".to_string()];
82 let _y = [x.into_iter().next().unwrap(); 1];
83 touch(&x); //~ ERROR borrow of moved value: `x`
87 let mut x = vec!["hi".to_string(), "ho".to_string()];