Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMember destructor is always executed even if self is replaced in `Drop` #23611
Comments
This comment has been minimized.
This comment has been minimized.
|
cc @pnkfelix |
steveklabnik
added
the
A-typesystem
label
Mar 22, 2015
This comment has been minimized.
This comment has been minimized.
|
(a bit of a strange tag, but I wasn't 100% sure what to put this under. kinda works, but may need recategorized once we pin down what's up here) |
This comment has been minimized.
This comment has been minimized.
|
I just checked, the destructor is run also on the wrong (the new replaced one) value. The following code prints „Dropping deadbeef“
|
pnkfelix
added
the
A-destructors
label
Mar 22, 2015
This comment has been minimized.
This comment has been minimized.
|
hmm, I assume this has something to do with the drop glue assuming that the I'm not exactly sure what the best thing to do is. Ideally we would ensure the drop method would not be able to change the enum variant in this fashion. Nominating for discussion at triage meeting. Probably an I-needs-decision; probably can be decided by 1.0 (i.e. need not be resolved by the beta release itself.) |
pnkfelix
added
the
I-nominated
label
Mar 22, 2015
This comment has been minimized.
This comment has been minimized.
|
Current plan: Change the drop glue to inspect the discriminant after the destructor runs. 1.0 polish, P-backcompat-lang. |
pnkfelix
added
the
P-backcompat-lang
label
Mar 26, 2015
pnkfelix
added this to the 1.0 milestone
Mar 26, 2015
pnkfelix
removed
the
I-nominated
label
Mar 26, 2015
pnkfelix
self-assigned this
Mar 29, 2015
This comment has been minimized.
This comment has been minimized.
|
(i think i have a plausible patch for this worked out.) |
nwin commentedMar 22, 2015
The following code prints "Dropping!" although the corresponding variant had been removed and forgotten. Same happens if it is overwritten instead.
I’m not sure if this is a bug or intended behavior but it is not obvious to me that this would happen and might be documented in more detail.