ptr-meta: DynMetadata and Pointee::Metadata are not UnwindSafe #86235
Labels
A-DSTs
Area: Dynamically-sized types (DSTs)
A-lang-item
Area: Language items
A-raw-pointers
Area: raw pointers, MaybeUninit, NonNull
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
requires-nightly
This issue requires a nightly compiler in some way.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
DynMetadata
is onlyUnwindSafe
if itsDyn
type argument is as well. This is a bit strange asDynMetadata
is, data-wise, just a&'static
to an immutable virtual table. There's not a way to observe broken invariant involving such a reference unless somehow the shared library containing the vtable is unloaded -- which violates'static
, would be super-mega-bad, and probably shouldn't be happening during unwind.https://rust-lang.github.io/rfcs/2580-ptr-meta.html (#81513) states that
Pointee::Metadata
isCopy + Send + Sync + Ord + Hash + Unpin
. Given these constraints, as well as the current types being()
,usize
, andDynMetadata
, it seems reasonable to me thatPointee::Metadata
also therefore beUnwindSafe
.I understand that
UnwindSafe
is currently instd
, but with #84662 it will move intolibcore
. Provided that we indeed want it as a bound ofPointee::Metadata
, we should definitely land this before exposing the ability for users to create custom metadata types.Changing the bounds on
Pointee::Metadata
is explicitly mentioned as a concern in these meeting minutes.(Also, the shared library unloading thing may indicate that we may want to drop the
&'static
in favor of*const
.)The text was updated successfully, but these errors were encountered: