2018-11-10 17:02:13 -06:00
|
|
|
// compile-flags: -Zborrowck=mir
|
2019-07-02 16:30:28 -05:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2017-11-17 03:34:02 -06:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
|
|
|
struct Wrap<'p> { p: &'p mut i32 }
|
|
|
|
|
|
|
|
impl<'p> Drop for Wrap<'p> {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
*self.p += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 0;
|
|
|
|
let wrap = Wrap { p: &mut x };
|
|
|
|
std::mem::drop(wrap);
|
|
|
|
x = 1; // OK, drop is inert
|
|
|
|
}
|