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