]> git.proxmox.com Git - rustc.git/blame - src/test/ui/closures/2229_closure_analysis/preserve_field_drop_order2.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / closures / 2229_closure_analysis / preserve_field_drop_order2.rs
CommitLineData
94222f64
XL
1// run-pass
2// check-run-results
3// revisions: twenty_eighteen twenty_twentyone
4// [twenty_eighteen]compile-flags: --edition 2018
5// [twenty_twentyone]compile-flags: --edition 2021
6
7#[derive(Debug)]
8struct Dropable(&'static str);
9
10impl Drop for Dropable {
11 fn drop(&mut self) {
12 println!("Dropping {}", self.0)
13 }
14}
15
16#[derive(Debug)]
17struct A {
18 x: Dropable,
19 y: Dropable,
20}
21
22#[derive(Debug)]
23struct B {
24 c: A,
25 d: A,
26}
27
28#[derive(Debug)]
29struct R<'a> {
30 c: &'a A,
31 d: &'a A,
32}
33
34fn main() {
35 let a = A { x: Dropable("x"), y: Dropable("y") };
36
37 let c = move || println!("{:?} {:?}", a.y, a.x);
38
39 c();
40
41 let b = B {
42 c: A { x: Dropable("b.c.x"), y: Dropable("b.c.y") },
43 d: A { x: Dropable("b.d.x"), y: Dropable("b.d.y") },
44 };
45
46 let d = move || println!("{:?} {:?} {:?} {:?}", b.d.y, b.d.x, b.c.y, b.c.x);
47
48 d();
49
50 let r = R {
51 c: &A { x: Dropable("r.c.x"), y: Dropable("r.c.y") },
52 d: &A { x: Dropable("r.d.x"), y: Dropable("r.d.y") },
53 };
54
55 let e = move || println!("{:?} {:?} {:?} {:?}", r.d.y, r.d.x, r.c.y, r.c.x);
56
57 e();
58}