]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-25793.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-25793.rs
1 #![feature(rustc_attrs)]
2 macro_rules! width(
3     ($this:expr) => {
4         $this.width.unwrap()
5         //~^ ERROR cannot use `self.width` because it was mutably borrowed
6     }
7 );
8
9 struct HasInfo {
10     width: Option<usize>
11 }
12
13 impl HasInfo {
14     fn get_size(&mut self, n: usize) -> usize {
15         n
16     }
17
18     fn get_other(&mut self) -> usize {
19         let r = &mut *self;
20         r.get_size(width!(self))
21     }
22     // Above is like `self.get_size(width!(self))`, but it
23     // deliberately avoids NLL's two phase borrow feature.
24 }
25
26 fn main() { }