@@ -3,7 +3,7 @@ use crate::context::TypeLowering;
3
3
use crate :: type_:: Type ;
4
4
use rustc_codegen_ssa:: traits:: * ;
5
5
use rustc_middle:: bug;
6
- use rustc_middle:: ty:: layout:: { FnAbiOf , LayoutOf , TyAndLayout } ;
6
+ use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
7
7
use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
8
8
use rustc_middle:: ty:: { self , Ty , TypeVisitableExt } ;
9
9
use rustc_target:: abi:: HasDataLayout ;
@@ -215,20 +215,16 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
215
215
/// of that field's type - this is useful for taking the address of
216
216
/// that field and ensuring the struct has the right alignment.
217
217
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.
218
221
if let Abi :: Scalar ( scalar) = self . abi {
219
222
// Use a different cache for scalars because pointers to DSTs
220
223
// can be either fat or thin (data pointers of fat pointers).
221
224
if let Some ( & llty) = cx. scalar_lltypes . borrow ( ) . get ( & self . ty ) {
222
225
return llty;
223
226
}
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) ;
232
228
cx. scalar_lltypes . borrow_mut ( ) . insert ( self . ty , llty) ;
233
229
return llty;
234
230
}
0 commit comments