]>
Commit | Line | Data |
---|---|---|
ff7c6d11 XL |
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 | 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 | } |