@@ -255,7 +255,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
255
255
Prefixed ( Size , Align ) ,
256
256
}
257
257
258
- let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
258
+ let univariant_uninterned = |fields : & [ TyLayout < ' _ > ] ,
259
+ repr : & ReprOptions ,
260
+ kind|
261
+ -> Result < _ , LayoutError < ' tcx > > {
259
262
let packed = repr. packed ( ) ;
260
263
if packed && repr. align > 0 {
261
264
bug ! ( "struct cannot be packed and aligned" ) ;
@@ -464,9 +467,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
464
467
size
465
468
} )
466
469
} ;
467
- let univariant = |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| {
468
- Ok ( tcx. intern_layout ( univariant_uninterned ( fields, repr, kind) ?) )
469
- } ;
470
+ let univariant =
471
+ |fields : & [ TyLayout < ' _ > ] , repr : & ReprOptions , kind| -> Result < _ , LayoutError < ' tcx > > {
472
+ Ok ( tcx. intern_layout ( univariant_uninterned ( fields, repr, kind) ?) )
473
+ } ;
470
474
debug_assert ! ( !ty. has_infer_types( ) ) ;
471
475
472
476
Ok ( match ty. sty {
@@ -641,7 +645,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
641
645
align = align. max ( variant. align ) ;
642
646
643
647
Ok ( variant)
644
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
648
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
645
649
646
650
let abi = if prefix. abi . is_uninhabited ( ) ||
647
651
variants. iter ( ) . all ( |v| v. abi . is_uninhabited ( ) ) {
@@ -939,7 +943,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
939
943
align = align. max ( st. align ) ;
940
944
941
945
Ok ( st)
942
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
946
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
943
947
944
948
let offset = st[ i] . fields . offset ( field_index) + niche. offset ;
945
949
let size = st[ i] . size ;
@@ -1054,7 +1058,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
1054
1058
size = cmp:: max ( size, st. size ) ;
1055
1059
align = align. max ( st. align ) ;
1056
1060
Ok ( st)
1057
- } ) . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
1061
+ } ) . collect :: < Result < IndexVec < VariantIdx , _ > , LayoutError < ' tcx > > > ( ) ?;
1058
1062
1059
1063
// Align the maximum variant size to the largest alignment.
1060
1064
size = size. align_to ( align. abi ) ;
0 commit comments