@@ -103,26 +103,31 @@ fn align_of_uncached<'tcx>(
103
103
104
104
Ok ( match * ty. kind ( ) {
105
105
// Basic scalars.
106
- ty:: Bool => tcx. intern_layout ( LayoutS :: scalar (
107
- cx,
108
- Scalar :: Initialized {
109
- value : Int ( I8 , false ) ,
110
- valid_range : WrappingRange { start : 0 , end : 1 } ,
111
- } ,
112
- ) ) . align ( ) ,
113
- ty:: Char => tcx. intern_layout ( LayoutS :: scalar (
114
- cx,
115
- Scalar :: Initialized {
116
- value : Int ( I32 , false ) ,
117
- valid_range : WrappingRange { start : 0 , end : 0x10FFFF } ,
118
- } ,
119
- ) ) . align ( ) ,
106
+ ty:: Bool => tcx
107
+ . intern_layout ( LayoutS :: scalar (
108
+ cx,
109
+ Scalar :: Initialized {
110
+ value : Int ( I8 , false ) ,
111
+ valid_range : WrappingRange { start : 0 , end : 1 } ,
112
+ } ,
113
+ ) )
114
+ . align ( ) ,
115
+ ty:: Char => tcx
116
+ . intern_layout ( LayoutS :: scalar (
117
+ cx,
118
+ Scalar :: Initialized {
119
+ value : Int ( I32 , false ) ,
120
+ valid_range : WrappingRange { start : 0 , end : 0x10FFFF } ,
121
+ } ,
122
+ ) )
123
+ . align ( ) ,
120
124
ty:: Int ( ity) => scalar ( Int ( Integer :: from_int_ty ( dl, ity) , true ) ) . align ( ) ,
121
125
ty:: Uint ( ity) => scalar ( Int ( Integer :: from_uint_ty ( dl, ity) , false ) ) . align ( ) ,
122
126
ty:: Float ( fty) => scalar ( match fty {
123
127
ty:: FloatTy :: F32 => F32 ,
124
128
ty:: FloatTy :: F64 => F64 ,
125
- } ) . align ( ) ,
129
+ } )
130
+ . align ( ) ,
126
131
ty:: FnPtr ( _) => {
127
132
let mut ptr = scalar_unit ( Pointer ( dl. instruction_address_space ) ) ;
128
133
ptr. valid_range_mut ( ) . start = 1 ;
@@ -198,35 +203,21 @@ fn align_of_uncached<'tcx>(
198
203
return Err ( LayoutError :: Unknown ( ty) ) ;
199
204
}
200
205
}
201
-
202
- let count = count. try_eval_usize ( tcx, param_env) . ok_or ( LayoutError :: Unknown ( ty) ) ?;
203
206
let element = cx. layout_of ( element) ?;
204
- element. size . checked_mul ( count, dl) . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?;
205
-
206
207
element. align
207
208
}
208
209
ty:: Slice ( element) => {
209
210
let element = cx. layout_of ( element) ?;
210
211
element. align
211
- } ,
212
+ }
212
213
213
214
ty:: Str => dl. i8_align ,
214
215
215
216
// Odd unit types.
216
217
ty:: FnDef ( ..) => univariant ( & [ ] , & ReprOptions :: default ( ) , StructKind :: AlwaysSized ) ?. align ( ) ,
217
218
ty:: Dynamic ( _, _, ty:: Dyn ) | ty:: Foreign ( ..) => {
218
- let mut unit = univariant_uninterned (
219
- cx,
220
- ty,
221
- & [ ] ,
222
- & ReprOptions :: default ( ) ,
223
- StructKind :: AlwaysSized ,
224
- ) ?;
225
- match unit. abi {
226
- Abi :: Aggregate { ref mut sized } => * sized = false ,
227
- _ => bug ! ( ) ,
228
- }
229
- tcx. intern_layout ( unit) . align ( )
219
+ univariant_uninterned ( cx, ty, & [ ] , & ReprOptions :: default ( ) , StructKind :: AlwaysSized ) ?
220
+ . align
230
221
}
231
222
232
223
ty:: Generator ( def_id, substs, _) => generator_layout ( cx, ty, def_id, substs) ?. align ( ) ,
@@ -237,7 +228,8 @@ fn align_of_uncached<'tcx>(
237
228
& tys. map ( |ty| cx. layout_of ( ty) ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
238
229
& ReprOptions :: default ( ) ,
239
230
StructKind :: AlwaysSized ,
240
- ) ?. align ( )
231
+ ) ?
232
+ . align ( )
241
233
}
242
234
243
235
ty:: Tuple ( tys) => {
@@ -248,7 +240,8 @@ fn align_of_uncached<'tcx>(
248
240
& tys. iter ( ) . map ( |k| cx. layout_of ( k) ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
249
241
& ReprOptions :: default ( ) ,
250
242
kind,
251
- ) ?. align ( )
243
+ ) ?
244
+ . align ( )
252
245
}
253
246
254
247
// SIMD vector types.
@@ -371,9 +364,12 @@ fn align_of_uncached<'tcx>(
371
364
return Err ( LayoutError :: Unknown ( ty) ) ;
372
365
}
373
366
374
- return Ok ( tcx. intern_layout (
375
- cx. layout_of_union ( & def. repr ( ) , & variants) . ok_or ( LayoutError :: Unknown ( ty) ) ?,
376
- ) . align ( ) ) ;
367
+ return Ok ( tcx
368
+ . intern_layout (
369
+ cx. layout_of_union ( & def. repr ( ) , & variants)
370
+ . ok_or ( LayoutError :: Unknown ( ty) ) ?,
371
+ )
372
+ . align ( ) ) ;
377
373
}
378
374
379
375
tcx. intern_layout (
@@ -405,7 +401,8 @@ fn align_of_uncached<'tcx>(
405
401
} ,
406
402
)
407
403
. ok_or ( LayoutError :: SizeOverflow ( ty) ) ?,
408
- ) . align ( )
404
+ )
405
+ . align ( )
409
406
}
410
407
411
408
// Types with no meaningful known layout.
0 commit comments