@@ -249,7 +249,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
249
249
Prefixed ( Size , Align ) ,
250
250
}
251
251
252
- let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
252
+ let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] ,
253
+ repr : & ReprOptions ,
254
+ kind|
255
+ -> Result < _ , LayoutError < ' tcx > > {
253
256
let packed = repr. packed ( ) ;
254
257
if packed && repr. align > 0 {
255
258
bug ! ( "struct cannot be packed and aligned" ) ;
@@ -458,9 +461,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
458
461
size
459
462
} )
460
463
} ;
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
+ } ;
464
468
debug_assert ! ( !ty. has_infer_types( ) ) ;
465
469
466
470
Ok ( match ty. sty {
@@ -635,7 +639,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
635
639
align = align. max ( variant. align ) ;
636
640
637
641
Ok ( variant)
638
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
642
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
639
643
640
644
let abi = if prefix. abi . is_uninhabited ( ) ||
641
645
variants. iter ( ) . all ( |v| v. abi . is_uninhabited ( ) ) {
@@ -933,7 +937,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
933
937
align = align. max ( st. align ) ;
934
938
935
939
Ok ( st)
936
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
940
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
937
941
938
942
let offset = st[ i] . fields . offset ( field_index) + niche. offset ;
939
943
let size = st[ i] . size ;
@@ -1048,7 +1052,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
1048
1052
size = cmp:: max ( size, st. size ) ;
1049
1053
align = align. max ( st. align ) ;
1050
1054
Ok ( st)
1051
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
1055
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
1052
1056
1053
1057
// Align the maximum variant size to the largest alignment.
1054
1058
size = size. align_to ( align. abi ) ;
0 commit comments