File tree 2 files changed +9
-21
lines changed
compiler/rustc_middle/src/ty
2 files changed +9
-21
lines changed Original file line number Diff line number Diff line change @@ -853,23 +853,10 @@ where
853
853
// fall back to structurally deducing metadata.
854
854
&& !pointee. references_error ( )
855
855
{
856
- let metadata = tcx. normalize_erasing_regions (
856
+ tcx. normalize_erasing_regions (
857
857
cx. param_env ( ) ,
858
858
Ty :: new_projection ( tcx, metadata_def_id, [ pointee] ) ,
859
- ) ;
860
-
861
- // Map `Metadata = DynMetadata<dyn Trait>` back to a vtable, since it
862
- // offers better information than `std::ptr::metadata::VTable`,
863
- // and we rely on this layout information to trigger a panic in
864
- // `std::mem::uninitialized::<&dyn Trait>()`, for example.
865
- if let ty:: Adt ( def, args) = metadata. kind ( )
866
- && Some ( def. did ( ) ) == tcx. lang_items ( ) . dyn_metadata ( )
867
- && args. type_at ( 0 ) . is_trait ( )
868
- {
869
- mk_dyn_vtable ( )
870
- } else {
871
- metadata
872
- }
859
+ )
873
860
} else {
874
861
match tcx. struct_tail_erasing_lifetimes ( pointee, cx. param_env ( ) ) . kind ( ) {
875
862
ty:: Slice ( _) | ty:: Str => tcx. types . usize ,
Original file line number Diff line number Diff line change @@ -177,17 +177,18 @@ impl<T: ?Sized> Clone for PtrComponents<T> {
177
177
/// duplicated in multiple codegen units), and pointers to vtables of *different* types/traits can
178
178
/// compare equal (since identical vtables can be deduplicated within a codegen unit).
179
179
#[ lang = "dyn_metadata" ]
180
+ // codegen assumes it can treat this as a single pointer
181
+ #[ repr( transparent) ]
180
182
pub struct DynMetadata < Dyn : ?Sized > {
181
183
vtable_ptr : & ' static VTable ,
182
184
phantom : crate :: marker:: PhantomData < Dyn > ,
183
185
}
184
186
185
- extern "C" {
186
- /// Opaque type for accessing vtables.
187
- ///
188
- /// Private implementation detail of `DynMetadata::size_of` etc.
189
- /// There is conceptually not actually any Abstract Machine memory behind this pointer.
190
- type VTable ;
187
+ /// This is not really what's behind a vtable, but the codegen tests want the
188
+ /// pointers to get `dereferencable` metadata, for example, and there's currently
189
+ /// no way to get that with `extern type`, which would otherwise be nicer.
190
+ struct VTable {
191
+ _stub : usize ,
191
192
}
192
193
193
194
impl < Dyn : ?Sized > DynMetadata < Dyn > {
You can’t perform that action at this time.
0 commit comments