2017-11-11 14:32:07 -06:00
|
|
|
//revisions: ast mir
|
2018-04-09 04:28:00 -05:00
|
|
|
//[mir] compile-flags: -Z borrowck=mir
|
2017-11-09 23:07:32 -06:00
|
|
|
|
|
|
|
#![allow(unused_assignments)]
|
|
|
|
|
|
|
|
struct Wrap<'a> { w: &'a mut u32 }
|
|
|
|
|
|
|
|
fn foo() {
|
2017-11-11 14:32:07 -06:00
|
|
|
let mut x = 22;
|
2017-11-09 23:07:32 -06:00
|
|
|
let wrapper = Wrap { w: &mut x };
|
2017-11-11 14:32:07 -06:00
|
|
|
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
2018-02-05 16:31:56 -06:00
|
|
|
//[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503]
|
2017-11-09 23:07:32 -06:00
|
|
|
*wrapper.w += 1;
|
|
|
|
}
|
|
|
|
|
2017-11-19 16:37:59 -06:00
|
|
|
fn main() { }
|