Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Drop order affected because of use order #42

Closed
arora-aman opened this issue Feb 12, 2021 · 1 comment · Fixed by rust-lang/rust#89208
Closed

Drop order affected because of use order #42

arora-aman opened this issue Feb 12, 2021 · 1 comment · Fixed by rust-lang/rust#89208
Assignees
Projects

Comments

@arora-aman
Copy link
Member

arora-aman commented Feb 12, 2021

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.

@arora-aman arora-aman added this to To-do in RFC-2229 via automation Feb 12, 2021
@nikomatsakis nikomatsakis added this to the Polish complete milestone Feb 17, 2021
@wesleywiser wesleywiser self-assigned this Sep 23, 2021
wesleywiser added a commit to wesleywiser/rust that referenced this issue Sep 23, 2021
Currently, with the new 2021 edition, if a closure captures all of the
fields of an upvar, we'll drop those fields in the order they are used
within the closure instead of the normal drop order (the definition
order of the fields in the type).

This changes that so we sort the captured fields by the definition order
which causes them to drop in that same order as well.

Fixes rust-lang/project-rfc-2229#42
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 24, 2021
…ikomatsakis

[rfc 2229] Drop fully captured upvars in the same order as the regular drop code

Currently, with the new 2021 edition, if a closure captures all of the
fields of an upvar, we'll drop those fields in the order they are used
within the closure instead of the normal drop order (the definition
order of the fields in the type).

This changes that so we sort the captured fields by the definition order
which causes them to drop in that same order as well.

Fixes rust-lang/project-rfc-2229#42

r? `@nikomatsakis`
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 24, 2021
…ikomatsakis

[rfc 2229] Drop fully captured upvars in the same order as the regular drop code

Currently, with the new 2021 edition, if a closure captures all of the
fields of an upvar, we'll drop those fields in the order they are used
within the closure instead of the normal drop order (the definition
order of the fields in the type).

This changes that so we sort the captured fields by the definition order
which causes them to drop in that same order as well.

Fixes rust-lang/project-rfc-2229#42

r? `@nikomatsakis`
@arora-aman arora-aman moved this from To-do to Done in RFC-2229 Sep 29, 2021
@wesleywiser
Copy link
Member

Closing since the PR was merged.

ehuss pushed a commit to ehuss/rust that referenced this issue Oct 4, 2021
…ikomatsakis

[rfc 2229] Drop fully captured upvars in the same order as the regular drop code

Currently, with the new 2021 edition, if a closure captures all of the
fields of an upvar, we'll drop those fields in the order they are used
within the closure instead of the normal drop order (the definition
order of the fields in the type).

This changes that so we sort the captured fields by the definition order
which causes them to drop in that same order as well.

Fixes rust-lang/project-rfc-2229#42

r? `@nikomatsakis`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
RFC-2229
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants