]> git.proxmox.com Git - rustc.git/blob - tests/ui/borrowck/issue-81365-5.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / borrowck / issue-81365-5.rs
1 use std::ops::Deref;
2
3 struct DerefTarget {
4 target_field: bool,
5 }
6
7 impl DerefTarget {
8 fn get(&self) -> &bool {
9 &self.target_field
10 }
11 }
12
13 struct Container {
14 target: DerefTarget,
15 container_field: bool,
16 }
17
18 impl Deref for Container {
19 type Target = DerefTarget;
20 fn deref(&self) -> &Self::Target {
21 &self.target
22 }
23 }
24
25 impl Container {
26 fn bad_borrow(&mut self) {
27 let first = self.get();
28 self.container_field = true; //~ ERROR E0506
29 first;
30 }
31 }
32
33 fn main() {}