Skip to content

Commit 51e54a4

Browse files
committed
ptr::metadata: avoid references to extern types
1 parent f431b51 commit 51e54a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/ptr/metadata.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::hash::{Hash, Hasher};
55
use crate::intrinsics::aggregate_raw_ptr;
66
use crate::intrinsics::ptr_metadata;
77
use crate::marker::Freeze;
8+
use crate::ptr::NonNull;
89

910
/// Provides the pointer metadata type of any pointed-to type.
1011
///
@@ -153,7 +154,7 @@ pub const fn from_raw_parts_mut<T: ?Sized>(
153154
/// compare equal (since identical vtables can be deduplicated within a codegen unit).
154155
#[lang = "dyn_metadata"]
155156
pub struct DynMetadata<Dyn: ?Sized> {
156-
_vtable_ptr: &'static VTable,
157+
_vtable_ptr: NonNull<VTable>,
157158
_phantom: crate::marker::PhantomData<Dyn>,
158159
}
159160

@@ -174,7 +175,7 @@ impl<Dyn: ?Sized> DynMetadata<Dyn> {
174175
fn vtable_ptr(self) -> *const VTable {
175176
// SAFETY: this layout assumption is hard-coded into the compiler.
176177
// If it's somehow not a size match, the transmute will error.
177-
unsafe { crate::mem::transmute::<Self, &'static VTable>(self) }
178+
unsafe { crate::mem::transmute::<Self, *const VTable>(self) }
178179
}
179180

180181
/// Returns the size of the type associated with this vtable.

0 commit comments

Comments
 (0)