@@ -249,7 +249,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
249249 Prefixed ( Size , Align ) ,
250250 }
251251
252- let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
252+ let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] ,
253+ repr : & ReprOptions ,
254+ kind|
255+ -> Result < _ , LayoutError < ' tcx > > {
253256 let packed = repr. packed ( ) ;
254257 if packed && repr. align > 0 {
255258 bug ! ( "struct cannot be packed and aligned" ) ;
@@ -458,9 +461,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
458461 size
459462 } )
460463 } ;
461- let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
462- Ok ( tcx. intern_layout ( univariant_uninterned ( fields, repr, kind) ?) )
463- } ;
464+ let univariant =
465+ |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| -> Result < _ , LayoutError < ' tcx > > {
466+ Ok ( tcx. intern_layout ( univariant_uninterned ( fields, repr, kind) ?) )
467+ } ;
464468 debug_assert ! ( !ty. has_infer_types( ) ) ;
465469
466470 Ok ( match ty. sty {
@@ -635,7 +639,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
635639 align = align. max ( variant. align ) ;
636640
637641 Ok ( variant)
638- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
642+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
639643
640644 let abi = if prefix. abi . is_uninhabited ( ) ||
641645 variants. iter ( ) . all ( |v| v. abi . is_uninhabited ( ) ) {
@@ -933,7 +937,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
933937 align = align. max ( st. align ) ;
934938
935939 Ok ( st)
936- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
940+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
937941
938942 let offset = st[ i] . fields . offset ( field_index) + niche. offset ;
939943 let size = st[ i] . size ;
@@ -1048,7 +1052,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
10481052 size = cmp:: max ( size, st. size ) ;
10491053 align = align. max ( st. align ) ;
10501054 Ok ( st)
1051- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
1055+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
10521056
10531057 // Align the maximum variant size to the largest alignment.
10541058 size = size. align_to ( align. abi ) ;
0 commit comments