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 upconsider removing/revising test/run-pass/zero-size-type-destructors.rs #33237
Comments
pnkfelix
added
I-nominated
T-lang
labels
Apr 27, 2016
eddyb
referenced this issue
Apr 27, 2016
Closed
Ban #[unsafe_no_drop_flag] on zero-sized types. #33238
pnkfelix
removed
the
I-nominated
label
Apr 28, 2016
This comment has been minimized.
This comment has been minimized.
|
discussed a bit with lang team. @nikomatsakis pointed out that a |
This comment has been minimized.
This comment has been minimized.
|
That said, my feeling is that the |
This comment has been minimized.
This comment has been minimized.
|
The test no longer uses |
pnkfelix commentedApr 27, 2016
•
edited
(spawned off of #rustc IRC discussion)
This test:
https://github.com/rust-lang/rust/blob/master/src/test/run-pass/zero-size-type-destructors.rs
leverages
#[unsafe_no_drop_flag], coupled with aDropimpl that deliberately does not attempt to observe whether the value has already been dropped, to count the number of actual drops are executed by the generated code.The problem with this is that small variations on the same program exhibit semantics that probably should not be considered stable.
For example (playpen: http://is.gd/BwiZ17):
prints:
We continue to assert that there are three drops of
Foo, sincexis moved into_x[0]. But due tounsafe_no_drop_flag, there is no dynamic tracking of whetherxis dropped or not, and therefore we end up executing the destructor four times. (The code above prints out the addresses of the local variables and of the&mut selfin the destructor to make this very explicit; note that the0x1dbit pattern is the way we mark a value as dropped/uninitialized.)I am filing this issue to point out that the test in the respository may be overly-conservative, in that it is explicitly testing the behavior of
unsafe_no_drop_flagwith code for which we do not guarantee the current behavior.In particular, this test is one of the things that is "blocking" MIR i.e.
-Z orbitin its current state, but I would argue that we do not guarantee the current behavior, at least not to this degree of specificity.