@@ -3,7 +3,7 @@ use crate::context::TypeLowering;
33use crate :: type_:: Type ;
44use rustc_codegen_ssa:: traits:: * ;
55use rustc_middle:: bug;
6- use rustc_middle:: ty:: layout:: { FnAbiOf , LayoutOf , TyAndLayout } ;
6+ use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
77use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
88use rustc_middle:: ty:: { self , Ty , TypeVisitableExt } ;
99use rustc_target:: abi:: HasDataLayout ;
@@ -215,20 +215,16 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
215215 /// of that field's type - this is useful for taking the address of
216216 /// that field and ensuring the struct has the right alignment.
217217 fn llvm_type < ' a > ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> & ' a Type {
218+ // This must produce the same result for `repr(transparent)` wrappers as for the inner type!
219+ // In other words, this should generally not look at the type at all, but only at the
220+ // layout.
218221 if let Abi :: Scalar ( scalar) = self . abi {
219222 // Use a different cache for scalars because pointers to DSTs
220223 // can be either fat or thin (data pointers of fat pointers).
221224 if let Some ( & llty) = cx. scalar_lltypes . borrow ( ) . get ( & self . ty ) {
222225 return llty;
223226 }
224- let llty = match * self . ty . kind ( ) {
225- ty:: Ref ( ..) | ty:: RawPtr ( _) => cx. type_ptr ( ) ,
226- ty:: Adt ( def, _) if def. is_box ( ) => cx. type_ptr ( ) ,
227- ty:: FnPtr ( sig) => {
228- cx. fn_ptr_backend_type ( cx. fn_abi_of_fn_ptr ( sig, ty:: List :: empty ( ) ) )
229- }
230- _ => self . scalar_llvm_type_at ( cx, scalar) ,
231- } ;
227+ let llty = self . scalar_llvm_type_at ( cx, scalar) ;
232228 cx. scalar_lltypes . borrow_mut ( ) . insert ( self . ty , llty) ;
233229 return llty;
234230 }
0 commit comments