]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/maybe-initialized-drop-uninitialized.rs
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
[rust.git] / tests / ui / nll / maybe-initialized-drop-uninitialized.rs
1 // check-pass
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 fn main() {
14     let mut x = 0;
15     let wrap = Wrap { p: &mut x };
16     std::mem::drop(wrap);
17     x = 1; // OK, drop is inert
18 }