]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/maybe-initialized-drop-with-fragment.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / ui / nll / maybe-initialized-drop-with-fragment.rs
1 #![allow(warnings)]
2
3 struct Wrap<'p> { p: &'p mut i32 }
4
5 impl<'p> Drop for Wrap<'p> {
6     fn drop(&mut self) {
7         *self.p += 1;
8     }
9 }
10
11 struct Foo<'p> { a: String, b: Wrap<'p> }
12
13 fn 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     x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
20 }