]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-partial-reinit-1.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / borrowck-partial-reinit-1.rs
1 // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 struct Test;
12
13 struct Test2 {
14     b: Option<Test>,
15 }
16
17 struct Test3(Option<Test>);
18
19 impl Drop for Test {
20     fn drop(&mut self) {
21         println!("dropping!");
22     }
23 }
24
25 impl Drop for Test2 {
26     fn drop(&mut self) {}
27 }
28
29 impl Drop for Test3 {
30     fn drop(&mut self) {}
31 }
32
33 fn stuff() {
34     let mut t = Test2 { b: None };
35     let u = Test;
36     drop(t);
37     t.b = Some(u);
38     //~^ ERROR partial reinitialization of uninitialized structure `t`
39
40     let mut t = Test3(None);
41     let u = Test;
42     drop(t);
43     t.0 = Some(u);
44     //~^ ERROR partial reinitialization of uninitialized structure `t`
45 }
46
47 fn main() {
48     stuff()
49 }