rust/tests/ui/borrowck/issue-81365-6.rs
2023-01-11 09:32:08 +00:00

24 lines
380 B
Rust

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() {}