summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-partial-reinit-2.rs
blob: 06cd322e77ea784ebe28fc868b3c3d03fa1c697e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct Test {
    a: isize,
    b: Option<Box<Test>>,
}

impl Drop for Test {
    fn drop(&mut self) {
        println!("Dropping {}", self.a);
    }
}

fn stuff() {
    let mut t = Test { a: 1, b: None};
    let mut u = Test { a: 2, b: Some(Box::new(t))};
    t.b = Some(Box::new(u));
    //~^ ERROR assign of moved value: `t`
    println!("done");
}

fn main() {
    stuff();
    println!("Hello, world!")
}