Description
DynMetadata
is only UnwindSafe
if its Dyn
type argument is as well. This is a bit strange as DynMetadata
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
is Copy + Send + Sync + Ord + Hash + Unpin
. Given these constraints, as well as the current types being ()
, usize
, and DynMetadata
, it seems reasonable to me that Pointee::Metadata
also therefore be UnwindSafe
.
I understand that UnwindSafe
is currently in std
, but with #84662 it will move into libcore
. Provided that we indeed want it as a bound of Pointee::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
.)