]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs
Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum
[rust.git] / src / test / ui / nll / maybe-initialized-drop-implicit-fragment-drop.rs
1 struct Wrap<'p> { p: &'p mut i32 }
2
3 impl<'p> Drop for Wrap<'p> {
4     fn drop(&mut self) {
5         *self.p += 1;
6     }
7 }
8
9 struct Foo<'p> { a: String, b: Wrap<'p> }
10
11 fn main() {
12     let mut x = 0;
13     let wrap = Wrap { p: &mut x };
14     let s = String::from("str");
15     let foo = Foo { a: s, b: wrap };
16     std::mem::drop(foo.b);
17     x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
18     // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
19 }