]>
Commit | Line | Data |
---|---|---|
6a06907d XL |
1 | use std::ops::Deref; |
2 | ||
3 | struct DerefTarget { | |
4 | target_field: bool, | |
5 | } | |
6 | struct Container { | |
7 | target: DerefTarget, | |
8 | container_field: bool, | |
9 | } | |
10 | ||
11 | impl Deref for Container { | |
12 | type Target = DerefTarget; | |
13 | fn deref(&self) -> &Self::Target { | |
14 | &self.target | |
15 | } | |
16 | } | |
17 | ||
18 | impl Container { | |
19 | fn bad_borrow(&mut self) { | |
20 | let first = &(*self).target_field; | |
21 | self.container_field = true; //~ ERROR E0506 | |
22 | first; | |
23 | } | |
24 | } | |
25 | ||
26 | fn main() {} |