3 #![feature(rustc_attrs)]
5 // Test that we can't move out of struct that impls `Drop`.
10 // Test that we restrict precision when moving not-`Copy` types, if any of the parent paths
11 // implement `Drop`. This is to ensure that we don't move out of a type that implements Drop.
16 fn drop(self: &mut Foo) {}
19 let f = Foo(Rc::new(1));
20 let x = #[rustc_capture_analysis] move || {
21 //~^ ERROR: attributes on expressions are experimental
22 //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
23 //~| ERROR: First Pass analysis includes:
24 //~| ERROR: Min Capture analysis includes:
25 println!("{:?}", f.0);
26 //~^ NOTE: Capturing f[(0, 0)] -> ImmBorrow
27 //~| NOTE: Min Capture f[] -> ByValue
33 // Test that we don't restrict precision when moving `Copy` types(i.e. when copying),
34 // even if any of the parent paths implement `Drop`.
41 impl Drop for Character {
45 let character = Character { hp: 100, name: format!("A") };
47 let c = #[rustc_capture_analysis] move || {
48 //~^ ERROR: attributes on expressions are experimental
49 //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
50 //~| ERROR: First Pass analysis includes:
51 //~| ERROR: Min Capture analysis includes:
52 println!("{}", character.hp)
53 //~^ NOTE: Capturing character[(0, 0)] -> ImmBorrow
54 //~| NOTE: Min Capture character[(0, 0)] -> ByValue
59 println!("{}", character.name);