1
1
use rustc_hir as hir;
2
2
use rustc_index:: bit_set:: BitSet ;
3
- use rustc_index:: vec:: { Idx , IndexVec } ;
3
+ use rustc_index:: vec:: IndexVec ;
4
4
use rustc_middle:: mir:: { GeneratorLayout , GeneratorSavedLocal } ;
5
5
use rustc_middle:: ty:: layout:: {
6
6
IntegerExt , LayoutCx , LayoutError , LayoutOf , TyAndLayout , MAX_SIMD_LANES ,
@@ -201,44 +201,16 @@ fn align_of_uncached<'tcx>(
201
201
202
202
let count = count. try_eval_usize ( tcx, param_env) . ok_or ( LayoutError :: Unknown ( ty) ) ?;
203
203
let element = cx. layout_of ( element) ?;
204
- let size = element. size . checked_mul ( count, dl) . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?;
204
+ element. size . checked_mul ( count, dl) . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?;
205
205
206
- let abi = if count != 0 && ty. is_privately_uninhabited ( tcx, param_env) {
207
- Abi :: Uninhabited
208
- } else {
209
- Abi :: Aggregate { sized : true }
210
- } ;
211
-
212
- let largest_niche = if count != 0 { element. largest_niche } else { None } ;
213
-
214
- tcx. intern_layout ( LayoutS {
215
- variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
216
- fields : FieldsShape :: Array { stride : element. size , count } ,
217
- abi,
218
- largest_niche,
219
- align : element. align ,
220
- size,
221
- } ) . align ( )
206
+ element. align
222
207
}
223
208
ty:: Slice ( element) => {
224
209
let element = cx. layout_of ( element) ?;
225
- tcx. intern_layout ( LayoutS {
226
- variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
227
- fields : FieldsShape :: Array { stride : element. size , count : 0 } ,
228
- abi : Abi :: Aggregate { sized : false } ,
229
- largest_niche : None ,
230
- align : element. align ,
231
- size : Size :: ZERO ,
232
- } ) . align ( )
233
- }
234
- ty:: Str => tcx. intern_layout ( LayoutS {
235
- variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
236
- fields : FieldsShape :: Array { stride : Size :: from_bytes ( 1 ) , count : 0 } ,
237
- abi : Abi :: Aggregate { sized : false } ,
238
- largest_niche : None ,
239
- align : dl. i8_align ,
240
- size : Size :: ZERO ,
241
- } ) . align ( ) ,
210
+ element. align
211
+ } ,
212
+
213
+ ty:: Str => dl. i8_align ,
242
214
243
215
// Odd unit types.
244
216
ty:: FnDef ( ..) => univariant ( & [ ] , & ReprOptions :: default ( ) , StructKind :: AlwaysSized ) ?. align ( ) ,
@@ -322,7 +294,7 @@ fn align_of_uncached<'tcx>(
322
294
// the first field is of array type, or
323
295
//
324
296
// * the homogeneous field type and the number of fields.
325
- let ( e_ty, e_len, is_array ) = if let ty:: Array ( e_ty, _) = f0_ty. kind ( ) {
297
+ let ( e_ty, e_len) = if let ty:: Array ( e_ty, _) = f0_ty. kind ( ) {
326
298
// First ADT field is an array:
327
299
328
300
// SIMD vectors with multiple array fields are not supported:
@@ -339,10 +311,10 @@ fn align_of_uncached<'tcx>(
339
311
return Err ( LayoutError :: Unknown ( ty) ) ;
340
312
} ;
341
313
342
- ( * e_ty, * count, true )
314
+ ( * e_ty, * count)
343
315
} else {
344
316
// First ADT field is not an array:
345
- ( f0_ty, def. non_enum_variant ( ) . fields . len ( ) as _ , false )
317
+ ( f0_ty, def. non_enum_variant ( ) . fields . len ( ) as _ )
346
318
} ;
347
319
348
320
// SIMD vectors of zero length are not supported.
@@ -361,7 +333,7 @@ fn align_of_uncached<'tcx>(
361
333
362
334
// Compute the ABI of the element type:
363
335
let e_ly = cx. layout_of ( e_ty) ?;
364
- let Abi :: Scalar ( e_abi ) = e_ly. abi else {
336
+ let Abi :: Scalar ( _ ) = e_ly. abi else {
365
337
// This error isn't caught in typeck, e.g., if
366
338
// the element type of the vector is generic.
367
339
tcx. sess . fatal ( & format ! (
@@ -373,24 +345,7 @@ fn align_of_uncached<'tcx>(
373
345
374
346
// Compute the size and alignment of the vector:
375
347
let size = e_ly. size . checked_mul ( e_len, dl) . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?;
376
- let align = dl. vector_align ( size) ;
377
- let size = size. align_to ( align. abi ) ;
378
-
379
- // Compute the placement of the vector fields:
380
- let fields = if is_array {
381
- FieldsShape :: Arbitrary { offsets : vec ! [ Size :: ZERO ] , memory_index : vec ! [ 0 ] }
382
- } else {
383
- FieldsShape :: Array { stride : e_ly. size , count : e_len }
384
- } ;
385
-
386
- tcx. intern_layout ( LayoutS {
387
- variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
388
- fields,
389
- abi : Abi :: Vector { element : e_abi, count : e_len } ,
390
- largest_niche : e_ly. largest_niche ,
391
- size,
392
- align,
393
- } ) . align ( )
348
+ dl. vector_align ( size)
394
349
}
395
350
396
351
// ADTs.
0 commit comments