@@ -689,10 +689,35 @@ pub fn encode_vtable_param_res(ecx: &e::EncodeContext,
689
689
} ) . unwrap ( )
690
690
}
691
691
692
+ pub fn encode_unboxed_closure_kind ( ebml_w : & mut Encoder ,
693
+ kind : ty:: UnboxedClosureKind ) {
694
+ ebml_w. emit_enum ( "UnboxedClosureKind" , |ebml_w| {
695
+ match kind {
696
+ ty:: FnUnboxedClosureKind => {
697
+ ebml_w. emit_enum_variant ( "FnUnboxedClosureKind" , 0 , 3 , |_| {
698
+ Ok ( ( ) )
699
+ } )
700
+ }
701
+ ty:: FnMutUnboxedClosureKind => {
702
+ ebml_w. emit_enum_variant ( "FnMutUnboxedClosureKind" , 1 , 3 , |_| {
703
+ Ok ( ( ) )
704
+ } )
705
+ }
706
+ ty:: FnOnceUnboxedClosureKind => {
707
+ ebml_w. emit_enum_variant ( "FnOnceUnboxedClosureKind" ,
708
+ 2 ,
709
+ 3 ,
710
+ |_| {
711
+ Ok ( ( ) )
712
+ } )
713
+ }
714
+ }
715
+ } ) . unwrap ( )
716
+ }
692
717
693
718
pub fn encode_vtable_origin ( ecx : & e:: EncodeContext ,
694
- rbml_w : & mut Encoder ,
695
- vtable_origin : & typeck:: vtable_origin ) {
719
+ rbml_w : & mut Encoder ,
720
+ vtable_origin : & typeck:: vtable_origin ) {
696
721
rbml_w. emit_enum ( "vtable_origin" , |rbml_w| {
697
722
match * vtable_origin {
698
723
typeck:: vtable_static( def_id, ref substs, ref vtable_res) => {
@@ -1210,14 +1235,15 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
1210
1235
} )
1211
1236
}
1212
1237
1213
- for unboxed_closure_type in tcx. unboxed_closure_types
1214
- . borrow ( )
1215
- . find ( & ast_util:: local_def ( id) )
1216
- . iter ( ) {
1217
- rbml_w. tag ( c:: tag_table_unboxed_closure_type , |rbml_w| {
1238
+ for unboxed_closure in tcx. unboxed_closures
1239
+ . borrow ( )
1240
+ . find ( & ast_util:: local_def ( id) )
1241
+ . iter ( ) {
1242
+ rbml_w. tag ( c:: tag_table_unboxed_closures , |rbml_w| {
1218
1243
rbml_w. id ( id) ;
1219
1244
rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1220
- rbml_w. emit_closure_type ( ecx, * unboxed_closure_type)
1245
+ rbml_w. emit_closure_type ( ecx, & unboxed_closure. closure_type ) ;
1246
+ encode_unboxed_closure_kind ( rbml_w, unboxed_closure. kind )
1221
1247
} )
1222
1248
} )
1223
1249
}
@@ -1244,8 +1270,8 @@ trait rbml_decoder_decoder_helpers {
1244
1270
-> ty:: Polytype ;
1245
1271
fn read_substs ( & mut self , xcx : & ExtendedDecodeContext ) -> subst:: Substs ;
1246
1272
fn read_auto_adjustment ( & mut self , xcx : & ExtendedDecodeContext ) -> ty:: AutoAdjustment ;
1247
- fn read_unboxed_closure_type ( & mut self , xcx : & ExtendedDecodeContext )
1248
- -> ty:: ClosureTy ;
1273
+ fn read_unboxed_closure ( & mut self , xcx : & ExtendedDecodeContext )
1274
+ -> ty:: UnboxedClosure ;
1249
1275
fn convert_def_id ( & mut self ,
1250
1276
xcx : & ExtendedDecodeContext ,
1251
1277
source : DefIdSource ,
@@ -1418,16 +1444,33 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
1418
1444
} ) . unwrap ( )
1419
1445
}
1420
1446
1421
- fn read_unboxed_closure_type ( & mut self , xcx : & ExtendedDecodeContext )
1422
- -> ty:: ClosureTy {
1423
- self . read_opaque ( |this, doc| {
1447
+ fn read_unboxed_closure ( & mut self , xcx : & ExtendedDecodeContext )
1448
+ -> ty:: UnboxedClosure {
1449
+ let closure_type = self . read_opaque ( |this, doc| {
1424
1450
Ok ( tydecode:: parse_ty_closure_data (
1425
1451
doc. data ,
1426
1452
xcx. dcx . cdata . cnum ,
1427
1453
doc. start ,
1428
1454
xcx. dcx . tcx ,
1429
1455
|s, a| this. convert_def_id ( xcx, s, a) ) )
1430
- } ) . unwrap ( )
1456
+ } ) . unwrap ( ) ;
1457
+ let variants = [
1458
+ "FnUnboxedClosureKind" ,
1459
+ "FnMutUnboxedClosureKind" ,
1460
+ "FnOnceUnboxedClosureKind"
1461
+ ] ;
1462
+ let kind = self . read_enum_variant ( variants, |_, i| {
1463
+ Ok ( match i {
1464
+ 0 => ty:: FnUnboxedClosureKind ,
1465
+ 1 => ty:: FnMutUnboxedClosureKind ,
1466
+ 2 => ty:: FnOnceUnboxedClosureKind ,
1467
+ _ => fail ! ( "bad enum variant for ty::UnboxedClosureKind" ) ,
1468
+ } )
1469
+ } ) . unwrap ( ) ;
1470
+ ty:: UnboxedClosure {
1471
+ closure_type : closure_type,
1472
+ kind : kind,
1473
+ }
1431
1474
}
1432
1475
1433
1476
fn convert_def_id ( & mut self ,
@@ -1566,14 +1609,14 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
1566
1609
let adj: ty:: AutoAdjustment = val_dsr. read_auto_adjustment ( xcx) ;
1567
1610
dcx. tcx . adjustments . borrow_mut ( ) . insert ( id, adj) ;
1568
1611
}
1569
- c:: tag_table_unboxed_closure_type => {
1570
- let unboxed_closure_type =
1571
- val_dsr. read_unboxed_closure_type ( xcx) ;
1612
+ c:: tag_table_unboxed_closures => {
1613
+ let unboxed_closure =
1614
+ val_dsr. read_unboxed_closure ( xcx) ;
1572
1615
dcx. tcx
1573
- . unboxed_closure_types
1616
+ . unboxed_closures
1574
1617
. borrow_mut ( )
1575
1618
. insert ( ast_util:: local_def ( id) ,
1576
- unboxed_closure_type ) ;
1619
+ unboxed_closure ) ;
1577
1620
}
1578
1621
_ => {
1579
1622
xcx. dcx . tcx . sess . bug (
0 commit comments