2018-04-10 22:20:05 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2016-01-21 21:14:09 +00:00
|
|
|
macro_rules! width(
|
|
|
|
($this:expr) => {
|
|
|
|
$this.width.unwrap()
|
|
|
|
//~^ ERROR cannot use `self.width` because it was mutably borrowed
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
struct HasInfo {
|
|
|
|
width: Option<usize>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl HasInfo {
|
|
|
|
fn get_size(&mut self, n: usize) -> usize {
|
|
|
|
n
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_other(&mut self) -> usize {
|
2018-05-25 10:36:58 +00:00
|
|
|
let r = &mut *self;
|
|
|
|
r.get_size(width!(self))
|
2016-01-21 21:14:09 +00:00
|
|
|
}
|
2018-05-25 10:36:58 +00:00
|
|
|
// Above is like `self.get_size(width!(self))`, but it
|
|
|
|
// deliberately avoids NLL's two phase borrow feature.
|
2016-01-21 21:14:09 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 10:36:58 +00:00
|
|
|
fn main() { }
|