Skip to content

Commit

Permalink
ptr::metadata: avoid references to extern types
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 17, 2024
1 parent f431b51 commit 51e54a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/ptr/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::hash::{Hash, Hasher};
use crate::intrinsics::aggregate_raw_ptr;
use crate::intrinsics::ptr_metadata;
use crate::marker::Freeze;
use crate::ptr::NonNull;

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

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

/// Returns the size of the type associated with this vtable.
Expand Down

0 comments on commit 51e54a4

Please sign in to comment.