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

struct Test;
struct Container(Test);

impl Test {
    fn test(&mut self) {}
}

impl<'a> Index<&'a bool> for Container {
    type Output = Test;

    fn index(&self, _index: &'a bool) -> &Test {
        &self.0
    }
}

fn main() {
    let container = Container(Test);
    let mut val = true;
    container[&mut val].test(); //~ ERROR: cannot borrow data
}