@@ -58,24 +58,23 @@ pub fn type_is_fat_ptr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) ->
58
58
}
59
59
60
60
pub fn type_is_immediate < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > , ty : Ty < ' tcx > ) -> bool {
61
- use machine :: llsize_of_alloc ;
62
- use type_of :: sizing_type_of ;
63
-
64
- let simple = ty . is_scalar ( ) | |
65
- ty . is_unique ( ) || ty . is_region_ptr ( ) ||
66
- ty . is_simd ( ) ;
67
- if simple && ! type_is_fat_ptr ( ccx , ty ) {
68
- return true ;
69
- }
70
- if !ccx . shared ( ) . type_is_sized ( ty ) {
71
- return false ;
72
- }
73
- match ty . sty {
74
- ty :: TyAdt ( .. ) | ty :: TyTuple ( .. ) | ty :: TyArray ( .. ) | ty :: TyClosure ( .. ) => {
75
- let llty = sizing_type_of ( ccx, ty ) ;
76
- llsize_of_alloc ( ccx , llty ) <= llsize_of_alloc ( ccx , ccx . int_type ( ) )
61
+ let layout = ccx . layout_of ( ty ) ;
62
+ match * layout {
63
+ Layout :: CEnum { .. } |
64
+ Layout :: Scalar { .. } |
65
+ Layout :: Vector { .. } => true ,
66
+
67
+ Layout :: FatPointer { .. } => false ,
68
+
69
+ Layout :: Array { .. } |
70
+ Layout :: Univariant { .. } |
71
+ Layout :: General { .. } |
72
+ Layout :: UntaggedUnion { .. } |
73
+ Layout :: RawNullablePointer { .. } |
74
+ Layout :: StructWrappedNullablePointer { .. } => {
75
+ let dl = & ccx. tcx ( ) . data_layout ;
76
+ !layout . is_unsized ( ) && layout . size ( dl ) <= dl . pointer_size
77
77
}
78
- _ => type_is_zero_size ( ccx, ty)
79
78
}
80
79
}
81
80
0 commit comments