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 upTracking issue for drop_in_place #27908
Comments
Gankro
added
the
B-unstable
label
Aug 19, 2015
This comment has been minimized.
This comment has been minimized.
|
Are there any plans to stabilize this? |
Marwes
referenced this issue
Jan 10, 2016
Closed
Freeing garbage collected objects does not call drop #18
This comment has been minimized.
This comment has been minimized.
|
@nagy24 it seems your message got garbbled up? |
sfackler
added
the
T-libs
label
Jan 10, 2016
This comment has been minimized.
This comment has been minimized.
|
This won't really work with |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 it would definitely have to be unsafe. Making the value invalid isn't necessarily a problem unless you're picturing more advanced analysis. I do kind've like the idea of a convention where invalidating ops are only exposed on raw pointers, though. |
sfackler
added
the
I-nominated
label
Jan 26, 2016
This comment has been minimized.
This comment has been minimized.
|
The libs team is somewhat up in the air about whether this function should take One one hand this method is only actually safe to call if you have a valid unique reference (e.g. We're curious if others have opinions! |
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Jan 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Is there a lint to warn about use after drop? |
This comment has been minimized.
This comment has been minimized.
|
Since For the choice between |
This comment has been minimized.
This comment has been minimized.
|
@KalitaAlexey not currently, no. @Marwes perhaps yeah, although the placement of My thinking for using a raw pointer is that if you're calling |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Feb 1, 2016
Why not change how |
This comment has been minimized.
This comment has been minimized.
|
@briansmith this isn't necessarily related to compiler optimizations, it's just replacing the old method of dropping a value by doing so via |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage yesterday and the conclusion was to stabilize in the |
Gankro commentedAug 19, 2015
This calls the "drop glue" for a given type without having to explicitly read it out onto the stack to be dropped. All types have a drop glue implementation, which involves calling the types Drop impl (if it exists), and the recursively running drop glue on its fields.
drop_in_place is both a performance improvement (in the case of e.g. Vec, it avoids ptr::reading the elements out), and a semantic necessity (in the case of DSTs, it's impossible to ptr::read the value, but the vtable always contains a drop glue impl).
It is currently exposed in the
ptrmodule because it's maximally expressive to take a*mutand because "that's what the intrinsic took" at the time it was exposed outside of std::intrinsics. It may be desirable to instead expose it inmemto parallelmem::drop, and require an&mut. For most cases you probably already have an &mut anyway, and it's trivial to upgrade.