2020-10-13 00:16:02 +00:00
|
|
|
// FIXME(arora-aman) add run-pass once 2229 is implemented
|
|
|
|
|
|
|
|
#![feature(capture_disjoint_fields)]
|
|
|
|
//~^ WARNING the feature `capture_disjoint_fields` is incomplete
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
|
|
|
struct Point {
|
|
|
|
x: i32,
|
|
|
|
y: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut p = Point { x: 10, y: 10 };
|
|
|
|
|
|
|
|
let c = #[rustc_capture_analysis]
|
|
|
|
//~^ ERROR: attributes on expressions are experimental
|
|
|
|
|| {
|
|
|
|
println!("{}", p.x);
|
2020-10-28 03:41:52 +00:00
|
|
|
//~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow
|
2020-11-10 08:05:50 +00:00
|
|
|
//~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow
|
2020-10-13 00:16:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// `c` should only capture `p.x`, therefore mutating `p.y` is allowed.
|
|
|
|
let py = &mut p.y;
|
|
|
|
|
|
|
|
c();
|
|
|
|
*py = 20;
|
|
|
|
}
|