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

struct Container {
    target: Vec<()>,
    container_field: bool,
}

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

impl Container {
    fn bad_borrow(&mut self) {
        let first = &self[0];
        self.container_field = true; //~ ERROR E0506
        first;
    }
}

fn main() {}