summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/issue-81365-7.rs
blob: cbf70f11a9acfaf0f42edad0d0778d3b62654fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::ops::Deref;

struct DerefTarget {
    target_field: bool,
}
struct Container {
    target: DerefTarget,
    container_field: bool,
}

impl Deref for Container {
    type Target = DerefTarget;
    fn deref(&self) -> &Self::Target {
        &self.target
    }
}

fn bad_borrow(c: &mut Container) {
    let first = &c.target_field;
    c.container_field = true; //~ ERROR E0506
    first;
}

fn main() {}