1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
//@ edition:2021
// Tests that in cases where we individually capture all the fields of a type,
// we still drop them in the order they would have been dropped in the 2018 edition.
// NOTE: It is *critical* that the order of the min capture NOTES in the stderr output
// does *not* change!
#![feature(rustc_attrs)]
#[derive(Debug)]
struct HasDrop;
impl Drop for HasDrop {
fn drop(&mut self) {
println!("dropped");
}
}
fn test_one() {
let a = (HasDrop, HasDrop);
let b = (HasDrop, HasDrop);
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|| {
//~^ ERROR: Min Capture analysis includes:
//~| ERROR
println!("{:?}", a.0);
//~^ NOTE: Min Capture a[(0, 0)] -> Immutable
//~| NOTE
println!("{:?}", a.1);
//~^ NOTE: Min Capture a[(1, 0)] -> Immutable
//~| NOTE
println!("{:?}", b.0);
//~^ NOTE: Min Capture b[(0, 0)] -> Immutable
//~| NOTE
println!("{:?}", b.1);
//~^ NOTE: Min Capture b[(1, 0)] -> Immutable
//~| NOTE
};
}
fn test_two() {
let a = (HasDrop, HasDrop);
let b = (HasDrop, HasDrop);
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|| {
//~^ ERROR: Min Capture analysis includes:
//~| ERROR
println!("{:?}", a.1);
//~^ NOTE: Min Capture a[(1, 0)] -> Immutable
//~| NOTE
println!("{:?}", a.0);
//~^ NOTE: Min Capture a[(0, 0)] -> Immutable
//~| NOTE
println!("{:?}", b.1);
//~^ NOTE: Min Capture b[(1, 0)] -> Immutable
//~| NOTE
println!("{:?}", b.0);
//~^ NOTE: Min Capture b[(0, 0)] -> Immutable
//~| NOTE
};
}
fn test_three() {
let a = (HasDrop, HasDrop);
let b = (HasDrop, HasDrop);
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|| {
//~^ ERROR: Min Capture analysis includes:
//~| ERROR
println!("{:?}", b.1);
//~^ NOTE: Min Capture b[(1, 0)] -> Immutable
//~| NOTE
println!("{:?}", a.1);
//~^ NOTE: Min Capture a[(1, 0)] -> Immutable
//~| NOTE
println!("{:?}", a.0);
//~^ NOTE: Min Capture a[(0, 0)] -> Immutable
//~| NOTE
println!("{:?}", b.0);
//~^ NOTE: Min Capture b[(0, 0)] -> Immutable
//~| NOTE
};
}
fn main() {
test_one();
test_two();
test_three();
}
|