@@ -148,36 +148,15 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
148
148
}
149
149
}
150
150
}
151
- layout:: General { discr, size, align, primitive_align, .. } => {
152
- // We need a representation that has:
153
- // * The alignment of the most-aligned field
154
- // * The size of the largest variant (rounded up to that alignment)
155
- // * No alignment padding anywhere any variant has actual data
156
- // (currently matters only for enums small enough to be immediate)
157
- // * The discriminant in an obvious place.
158
- //
159
- // So we start with the discriminant, pad it up to the alignment with
160
- // more of its own type, then use alignment-sized ints to get the rest
161
- // of the size.
162
- let discr_ty = Type :: from_integer ( cx, discr) ;
163
- let discr_size = discr. size ( ) . bytes ( ) ;
164
- let padded_discr_size = discr. size ( ) . abi_align ( align) ;
165
- let variant_part_size = size - padded_discr_size;
166
-
167
- // Ensure discr_ty can fill pad evenly
168
- assert_eq ! ( padded_discr_size. bytes( ) % discr_size, 0 ) ;
169
- let fields = [
170
- discr_ty,
171
- Type :: array ( & discr_ty, padded_discr_size. bytes ( ) / discr_size - 1 ) ,
172
- union_fill ( cx, variant_part_size, primitive_align)
173
- ] ;
151
+ layout:: General { size, align, .. } => {
152
+ let fill = union_fill ( cx, size, align) ;
174
153
match name {
175
154
None => {
176
- Type :: struct_ ( cx, & fields , false )
155
+ Type :: struct_ ( cx, & [ fill ] , false )
177
156
}
178
157
Some ( name) => {
179
158
let mut llty = Type :: named_struct ( cx, name) ;
180
- llty. set_struct_body ( & fields , false ) ;
159
+ llty. set_struct_body ( & [ fill ] , false ) ;
181
160
llty
182
161
}
183
162
}
0 commit comments