-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Mark NoFinalize
as unsafe and document it.
#40
Mark NoFinalize
as unsafe and document it.
#40
Conversation
library/core/src/gc.rs
Outdated
/// Unsafe because this should be used with care. Preventing drop from | ||
/// running can lead to surprising behaviour. In particular, this will also | ||
/// prevent the finalization of all component types of T. | ||
pub unsafe fn new(value: T) -> NonFinalizable<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be awkward, since this is ManuallyDrop
in disguise, I think it's OK for this to not be marked as unsafe
(ManuallyDrop::new
is not unsafe
). I don't feel strongly about that though!
I notice that the PR has conflicts? Maybe push a merge commit to master in here? |
@jacob-hughes Where are we with this one? |
I'm not sure what happened there which made my local branch so out of sync with the softdev repo, anyway I've added a merge commit which can be squashed away later. |
Please squash. |
5838776
to
d62c55b
Compare
The `NoFinalize` trait prevents a type `T` from being finalized when its passed to `Gc<T>`.
d62c55b
to
5ebb0fa
Compare
Squashed |
bors r+ |
Build succeeded: |
The
NoFinalize
trait prevents a typeT
from being finalized when itspassed to
Gc<T>
.Now that we've settled on a preferred semantics for
NoFinalize
, the implementation here was already correct. I've tweaked it to be unsafe, added a couple more tests, and documented it.