rust-lang/project-rfc-2229

Drop order affected because of use order

Closed this issue · 1 comments

Consider the following example

let x : DropType;
let y : DropType;

let p = P { x, y };
let c = || {
   move(p.y);
   move(p.x);
};

Even though the closure captures all paths starting from p, without the feature the fields are dropped in order, so p.x and then p.y. However, with the feature enabled, we would drop p.y, and then p.x because that's the order (use within the closure) in which we would place them in the desugared closure structure.

Closing since the PR was merged.