fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
1.2 KiB32 linesraw
1error[E0506]: cannot assign to `greeting` because it is borrowed
2  --> $DIR/issue-58776-borrowck-scans-children.rs:5:5
3   |
4LL |     let res = (|| (|| &greeting)())();
5   |                --      -------- borrow occurs due to use in closure
6   |                |
7   |                borrow of `greeting` occurs here
8LL | 
9LL |     greeting = "DEALLOCATED".to_string();
10   |     ^^^^^^^^ assignment to borrowed `greeting` occurs here
11...
12LL |     println!("thread result: {:?}", res);
13   |                                     --- borrow later used here
14
15error[E0505]: cannot move out of `greeting` because it is borrowed
16  --> $DIR/issue-58776-borrowck-scans-children.rs:7:10
17   |
18LL |     let res = (|| (|| &greeting)())();
19   |                --      -------- borrow occurs due to use in closure
20   |                |
21   |                borrow of `greeting` occurs here
22...
23LL |     drop(greeting);
24   |          ^^^^^^^^ move out of `greeting` occurs here
25...
26LL |     println!("thread result: {:?}", res);
27   |                                     --- borrow later used here
28
29error: aborting due to 2 previous errors
30
31Some errors have detailed explanations: E0505, E0506.
32For more information about an error, try `rustc --explain E0505`.