]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs
fix merge conflicts
[rust.git] / src / test / ui / nll / maybe-initialized-drop-with-uninitialized-fragments.rs
1 //compile-flags: -Zborrowck=mir
2
3 #![allow(warnings)]
4
5 struct Wrap<'p> { p: &'p mut i32 }
6
7 impl<'p> Drop for Wrap<'p> {
8     fn drop(&mut self) {
9         *self.p += 1;
10     }
11 }
12
13 struct Foo<'p> { a: String, b: Wrap<'p> }
14
15 fn main() {
16     let mut x = 0;
17     let wrap = Wrap { p: &mut x };
18     let s = String::from("str");
19     let foo = Foo { a: s, b: wrap };
20     std::mem::drop(foo.a);
21     std::mem::drop(foo.b);
22     x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
23     // FIXME ^ This currently errors and it should not.
24 }