rust/tests/ui/issues/issue-44405.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
378 B
Rust
Raw Normal View History

2019-08-08 23:37:55 +00:00
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
}