]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-81365-7.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-81365-7.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 fn bad_borrow(c: &mut Container) {
19     let first = &c.target_field;
20     c.container_field = true; //~ ERROR E0506
21     first;
22 }
23
24 fn main() {}