]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-partial-reinit-1.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-partial-reinit-1.rs
1 struct Test;
2
3 struct Test2 {
4     b: Option<Test>,
5 }
6
7 struct Test3(Option<Test>);
8
9 impl Drop for Test {
10     fn drop(&mut self) {
11         println!("dropping!");
12     }
13 }
14
15 impl Drop for Test2 {
16     fn drop(&mut self) {}
17 }
18
19 impl Drop for Test3 {
20     fn drop(&mut self) {}
21 }
22
23 fn stuff() {
24     let mut t = Test2 { b: None };
25     let u = Test;
26     drop(t);
27     t.b = Some(u);
28     //~^ ERROR assign of moved value: `t`
29
30     let mut t = Test3(None);
31     let u = Test;
32     drop(t);
33     t.0 = Some(u);
34     //~^ ERROR assign of moved value: `t`
35 }
36
37 fn main() {
38     stuff()
39 }