]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/cannot-move-block-spans.rs
Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum
[rust.git] / src / test / ui / nll / cannot-move-block-spans.rs
1 // Test that the we point to the inner expression when moving out to initialize
2 // a variable, and that we don't give a useless suggestion such as &{ *r }.
3
4 pub fn deref(r: &String) {
5     let x = { *r }; //~ ERROR
6     let y = unsafe { *r }; //~ ERROR
7     let z = loop { break *r; }; //~ ERROR
8 }
9
10 pub fn index(arr: [String; 2]) {
11     let x = { arr[0] }; //~ ERROR
12     let y = unsafe { arr[0] }; //~ ERROR
13     let z = loop { break arr[0]; }; //~ ERROR
14 }
15
16 pub fn additional_statement_cases(r: &String) {
17     let x = { let mut u = 0; u += 1; *r }; //~ ERROR
18     let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR
19     let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR
20 }
21
22 fn main() {}