@@ -103,26 +103,31 @@ fn align_of_uncached<'tcx>(
103103
104104 Ok ( match * ty. kind ( ) {
105105 // 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 ( ) ,
120124 ty:: Int ( ity) => scalar ( Int ( Integer :: from_int_ty ( dl, ity) , true ) ) . align ( ) ,
121125 ty:: Uint ( ity) => scalar ( Int ( Integer :: from_uint_ty ( dl, ity) , false ) ) . align ( ) ,
122126 ty:: Float ( fty) => scalar ( match fty {
123127 ty:: FloatTy :: F32 => F32 ,
124128 ty:: FloatTy :: F64 => F64 ,
125- } ) . align ( ) ,
129+ } )
130+ . align ( ) ,
126131 ty:: FnPtr ( _) => {
127132 let mut ptr = scalar_unit ( Pointer ( dl. instruction_address_space ) ) ;
128133 ptr. valid_range_mut ( ) . start = 1 ;
@@ -198,35 +203,21 @@ fn align_of_uncached<'tcx>(
198203 return Err ( LayoutError :: Unknown ( ty) ) ;
199204 }
200205 }
201-
202- let count = count. try_eval_usize ( tcx, param_env) . ok_or ( LayoutError :: Unknown ( ty) ) ?;
203206 let element = cx. layout_of ( element) ?;
204- element. size . checked_mul ( count, dl) . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?;
205-
206207 element. align
207208 }
208209 ty:: Slice ( element) => {
209210 let element = cx. layout_of ( element) ?;
210211 element. align
211- } ,
212+ }
212213
213214 ty:: Str => dl. i8_align ,
214215
215216 // Odd unit types.
216217 ty:: FnDef ( ..) => univariant ( & [ ] , & ReprOptions :: default ( ) , StructKind :: AlwaysSized ) ?. align ( ) ,
217218 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
230221 }
231222
232223 ty:: Generator ( def_id, substs, _) => generator_layout ( cx, ty, def_id, substs) ?. align ( ) ,
@@ -237,7 +228,8 @@ fn align_of_uncached<'tcx>(
237228 & tys. map ( |ty| cx. layout_of ( ty) ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
238229 & ReprOptions :: default ( ) ,
239230 StructKind :: AlwaysSized ,
240- ) ?. align ( )
231+ ) ?
232+ . align ( )
241233 }
242234
243235 ty:: Tuple ( tys) => {
@@ -248,7 +240,8 @@ fn align_of_uncached<'tcx>(
248240 & tys. iter ( ) . map ( |k| cx. layout_of ( k) ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
249241 & ReprOptions :: default ( ) ,
250242 kind,
251- ) ?. align ( )
243+ ) ?
244+ . align ( )
252245 }
253246
254247 // SIMD vector types.
@@ -371,9 +364,12 @@ fn align_of_uncached<'tcx>(
371364 return Err ( LayoutError :: Unknown ( ty) ) ;
372365 }
373366
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 ( ) ) ;
377373 }
378374
379375 tcx. intern_layout (
@@ -405,7 +401,8 @@ fn align_of_uncached<'tcx>(
405401 } ,
406402 )
407403 . ok_or ( LayoutError :: SizeOverflow ( ty) ) ?,
408- ) . align ( )
404+ )
405+ . align ( )
409406 }
410407
411408 // Types with no meaningful known layout.
0 commit comments