-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
A-dropTopic: related to droppingTopic: related to droppingC-supportCategory: Supporting a user to solve a concrete problemCategory: Supporting a user to solve a concrete problem
Description
Are we guaranteed that enum discriminants have trivial drop impls? In other words:
fn foo<T> {
assert_eq!(std::mem::needs_drop<T>(), std::mem::needs_drop<Option<T>>());
}
The context is that I have the following code:
match self {
Ok(...) => ...,
Err(x) => {
unsafe {
let x = ptr::read(x);
let new = // compute on x
ptr::write(self, new);
}
}
}
Am I guaranteed that ptr::write(self, new)
is fine even though it clobbers the enum discriminants, which are technically still initialized?
Metadata
Metadata
Assignees
Labels
A-dropTopic: related to droppingTopic: related to droppingC-supportCategory: Supporting a user to solve a concrete problemCategory: Supporting a user to solve a concrete problem