summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/maybe-initialized-drop.rs
blob: 44a7ede788feb8b925fa77f370d9e59c33ee17c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#![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 };
    x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
}