]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-81365-9.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-81365-9.rs
1 use std::ops::Deref;
2
3 struct DerefTarget {
4     target_field: bool,
5 }
6 struct Container {
7     target: DerefTarget,
8     container_field: bool,
9 }
10
11 impl Deref for Container {
12     type Target = DerefTarget;
13     fn deref(&self) -> &Self::Target {
14         &self.target
15     }
16 }
17
18 impl Container {
19     fn bad_borrow(&mut self) {
20         let first = &Deref::deref(self).target_field;
21         self.container_field = true; //~ ERROR E0506
22         first;
23     }
24 }
25
26 fn main() {}