@@ -200,7 +200,7 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
200
200
stable_mir:: mir:: Rvalue :: Repeat ( op. stable ( tables) , len)
201
201
}
202
202
Ref ( region, kind, place) => stable_mir:: mir:: Rvalue :: Ref (
203
- opaque ( region) ,
203
+ region. stable ( tables ) ,
204
204
kind. stable ( tables) ,
205
205
place. stable ( tables) ,
206
206
) ,
@@ -842,12 +842,9 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
842
842
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
843
843
use stable_mir:: ty:: GenericArgKind ;
844
844
match self {
845
- ty:: GenericArgKind :: Lifetime ( region) => GenericArgKind :: Lifetime ( opaque ( region) ) ,
845
+ ty:: GenericArgKind :: Lifetime ( region) => GenericArgKind :: Lifetime ( region. stable ( tables ) ) ,
846
846
ty:: GenericArgKind :: Type ( ty) => GenericArgKind :: Type ( tables. intern_ty ( * ty) ) ,
847
- ty:: GenericArgKind :: Const ( cnst) => {
848
- let cnst = ConstantKind :: from_const ( * cnst, tables. tcx ) ;
849
- GenericArgKind :: Const ( stable_mir:: ty:: Const { literal : cnst. stable ( tables) } )
850
- }
847
+ ty:: GenericArgKind :: Const ( cnst) => GenericArgKind :: Const ( cnst. stable ( tables) ) ,
851
848
}
852
849
}
853
850
}
@@ -1053,16 +1050,14 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
1053
1050
}
1054
1051
ty:: Str => TyKind :: RigidTy ( RigidTy :: Str ) ,
1055
1052
ty:: Array ( ty, constant) => {
1056
- let cnst = ConstantKind :: from_const ( * constant, tables. tcx ) ;
1057
- let cnst = stable_mir:: ty:: Const { literal : cnst. stable ( tables) } ;
1058
- TyKind :: RigidTy ( RigidTy :: Array ( tables. intern_ty ( * ty) , cnst) )
1053
+ TyKind :: RigidTy ( RigidTy :: Array ( tables. intern_ty ( * ty) , constant. stable ( tables) ) )
1059
1054
}
1060
1055
ty:: Slice ( ty) => TyKind :: RigidTy ( RigidTy :: Slice ( tables. intern_ty ( * ty) ) ) ,
1061
1056
ty:: RawPtr ( ty:: TypeAndMut { ty, mutbl } ) => {
1062
1057
TyKind :: RigidTy ( RigidTy :: RawPtr ( tables. intern_ty ( * ty) , mutbl. stable ( tables) ) )
1063
1058
}
1064
1059
ty:: Ref ( region, ty, mutbl) => TyKind :: RigidTy ( RigidTy :: Ref (
1065
- opaque ( region) ,
1060
+ region. stable ( tables ) ,
1066
1061
tables. intern_ty ( * ty) ,
1067
1062
mutbl. stable ( tables) ,
1068
1063
) ) ,
@@ -1077,7 +1072,7 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
1077
1072
. iter ( )
1078
1073
. map ( |existential_predicate| existential_predicate. stable ( tables) )
1079
1074
. collect ( ) ,
1080
- opaque ( region) ,
1075
+ region. stable ( tables ) ,
1081
1076
dyn_kind. stable ( tables) ,
1082
1077
) )
1083
1078
}
@@ -1112,6 +1107,15 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
1112
1107
}
1113
1108
}
1114
1109
1110
+ impl < ' tcx > Stable < ' tcx > for ty:: Const < ' tcx > {
1111
+ type T = stable_mir:: ty:: Const ;
1112
+
1113
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1114
+ let cnst = ConstantKind :: from_const ( * self , tables. tcx ) ;
1115
+ stable_mir:: ty:: Const { literal : cnst. stable ( tables) }
1116
+ }
1117
+ }
1118
+
1115
1119
impl < ' tcx > Stable < ' tcx > for ty:: ParamTy {
1116
1120
type T = stable_mir:: ty:: ParamTy ;
1117
1121
fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
@@ -1276,3 +1280,179 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDef {
1276
1280
}
1277
1281
}
1278
1282
}
1283
+
1284
+ impl < ' tcx > Stable < ' tcx > for ty:: PredicateKind < ' tcx > {
1285
+ type T = stable_mir:: ty:: PredicateKind ;
1286
+
1287
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1288
+ use ty:: PredicateKind ;
1289
+ match self {
1290
+ PredicateKind :: Clause ( clause_kind) => {
1291
+ stable_mir:: ty:: PredicateKind :: Clause ( clause_kind. stable ( tables) )
1292
+ }
1293
+ PredicateKind :: ObjectSafe ( did) => {
1294
+ stable_mir:: ty:: PredicateKind :: ObjectSafe ( tables. trait_def ( * did) )
1295
+ }
1296
+ PredicateKind :: ClosureKind ( did, generic_args, closure_kind) => {
1297
+ stable_mir:: ty:: PredicateKind :: ClosureKind (
1298
+ tables. closure_def ( * did) ,
1299
+ generic_args. stable ( tables) ,
1300
+ closure_kind. stable ( tables) ,
1301
+ )
1302
+ }
1303
+ PredicateKind :: Subtype ( subtype_predicate) => {
1304
+ stable_mir:: ty:: PredicateKind :: SubType ( subtype_predicate. stable ( tables) )
1305
+ }
1306
+ PredicateKind :: Coerce ( coerce_predicate) => {
1307
+ stable_mir:: ty:: PredicateKind :: Coerce ( coerce_predicate. stable ( tables) )
1308
+ }
1309
+ PredicateKind :: ConstEquate ( a, b) => {
1310
+ stable_mir:: ty:: PredicateKind :: ConstEquate ( a. stable ( tables) , b. stable ( tables) )
1311
+ }
1312
+ PredicateKind :: Ambiguous => stable_mir:: ty:: PredicateKind :: Ambiguous ,
1313
+ PredicateKind :: AliasRelate ( a, b, alias_relation_direction) => {
1314
+ stable_mir:: ty:: PredicateKind :: AliasRelate (
1315
+ a. unpack ( ) . stable ( tables) ,
1316
+ b. unpack ( ) . stable ( tables) ,
1317
+ alias_relation_direction. stable ( tables) ,
1318
+ )
1319
+ }
1320
+ }
1321
+ }
1322
+ }
1323
+
1324
+ impl < ' tcx > Stable < ' tcx > for ty:: ClauseKind < ' tcx > {
1325
+ type T = stable_mir:: ty:: ClauseKind ;
1326
+
1327
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1328
+ use ty:: ClauseKind :: * ;
1329
+ match * self {
1330
+ Trait ( trait_object) => stable_mir:: ty:: ClauseKind :: Trait ( trait_object. stable ( tables) ) ,
1331
+ RegionOutlives ( region_outlives) => {
1332
+ stable_mir:: ty:: ClauseKind :: RegionOutlives ( region_outlives. stable ( tables) )
1333
+ }
1334
+ TypeOutlives ( type_outlives) => {
1335
+ let ty:: OutlivesPredicate :: < _ , _ > ( a, b) = type_outlives;
1336
+ stable_mir:: ty:: ClauseKind :: TypeOutlives ( stable_mir:: ty:: OutlivesPredicate (
1337
+ tables. intern_ty ( a) ,
1338
+ b. stable ( tables) ,
1339
+ ) )
1340
+ }
1341
+ Projection ( projection_predicate) => {
1342
+ stable_mir:: ty:: ClauseKind :: Projection ( projection_predicate. stable ( tables) )
1343
+ }
1344
+ ConstArgHasType ( const_, ty) => stable_mir:: ty:: ClauseKind :: ConstArgHasType (
1345
+ const_. stable ( tables) ,
1346
+ tables. intern_ty ( ty) ,
1347
+ ) ,
1348
+ WellFormed ( generic_arg) => {
1349
+ stable_mir:: ty:: ClauseKind :: WellFormed ( generic_arg. unpack ( ) . stable ( tables) )
1350
+ }
1351
+ ConstEvaluatable ( const_) => {
1352
+ stable_mir:: ty:: ClauseKind :: ConstEvaluatable ( const_. stable ( tables) )
1353
+ }
1354
+ }
1355
+ }
1356
+ }
1357
+
1358
+ impl < ' tcx > Stable < ' tcx > for ty:: ClosureKind {
1359
+ type T = stable_mir:: ty:: ClosureKind ;
1360
+
1361
+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1362
+ use ty:: ClosureKind :: * ;
1363
+ match self {
1364
+ Fn => stable_mir:: ty:: ClosureKind :: Fn ,
1365
+ FnMut => stable_mir:: ty:: ClosureKind :: FnMut ,
1366
+ FnOnce => stable_mir:: ty:: ClosureKind :: FnOnce ,
1367
+ }
1368
+ }
1369
+ }
1370
+
1371
+ impl < ' tcx > Stable < ' tcx > for ty:: SubtypePredicate < ' tcx > {
1372
+ type T = stable_mir:: ty:: SubtypePredicate ;
1373
+
1374
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1375
+ let ty:: SubtypePredicate { a, b, a_is_expected : _ } = self ;
1376
+ stable_mir:: ty:: SubtypePredicate { a : tables. intern_ty ( * a) , b : tables. intern_ty ( * b) }
1377
+ }
1378
+ }
1379
+
1380
+ impl < ' tcx > Stable < ' tcx > for ty:: CoercePredicate < ' tcx > {
1381
+ type T = stable_mir:: ty:: CoercePredicate ;
1382
+
1383
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1384
+ let ty:: CoercePredicate { a, b } = self ;
1385
+ stable_mir:: ty:: CoercePredicate { a : tables. intern_ty ( * a) , b : tables. intern_ty ( * b) }
1386
+ }
1387
+ }
1388
+
1389
+ impl < ' tcx > Stable < ' tcx > for ty:: AliasRelationDirection {
1390
+ type T = stable_mir:: ty:: AliasRelationDirection ;
1391
+
1392
+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1393
+ use ty:: AliasRelationDirection :: * ;
1394
+ match self {
1395
+ Equate => stable_mir:: ty:: AliasRelationDirection :: Equate ,
1396
+ Subtype => stable_mir:: ty:: AliasRelationDirection :: Subtype ,
1397
+ }
1398
+ }
1399
+ }
1400
+
1401
+ impl < ' tcx > Stable < ' tcx > for ty:: TraitPredicate < ' tcx > {
1402
+ type T = stable_mir:: ty:: TraitPredicate ;
1403
+
1404
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1405
+ let ty:: TraitPredicate { trait_ref, polarity } = self ;
1406
+ stable_mir:: ty:: TraitPredicate {
1407
+ trait_ref : trait_ref. stable ( tables) ,
1408
+ polarity : polarity. stable ( tables) ,
1409
+ }
1410
+ }
1411
+ }
1412
+
1413
+ impl < ' tcx , A , B , U , V > Stable < ' tcx > for ty:: OutlivesPredicate < A , B >
1414
+ where
1415
+ A : Stable < ' tcx , T = U > ,
1416
+ B : Stable < ' tcx , T = V > ,
1417
+ {
1418
+ type T = stable_mir:: ty:: OutlivesPredicate < U , V > ;
1419
+
1420
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1421
+ let ty:: OutlivesPredicate ( a, b) = self ;
1422
+ stable_mir:: ty:: OutlivesPredicate ( a. stable ( tables) , b. stable ( tables) )
1423
+ }
1424
+ }
1425
+
1426
+ impl < ' tcx > Stable < ' tcx > for ty:: ProjectionPredicate < ' tcx > {
1427
+ type T = stable_mir:: ty:: ProjectionPredicate ;
1428
+
1429
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1430
+ let ty:: ProjectionPredicate { projection_ty, term } = self ;
1431
+ stable_mir:: ty:: ProjectionPredicate {
1432
+ projection_ty : projection_ty. stable ( tables) ,
1433
+ term : term. unpack ( ) . stable ( tables) ,
1434
+ }
1435
+ }
1436
+ }
1437
+
1438
+ impl < ' tcx > Stable < ' tcx > for ty:: ImplPolarity {
1439
+ type T = stable_mir:: ty:: ImplPolarity ;
1440
+
1441
+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1442
+ use ty:: ImplPolarity :: * ;
1443
+ match self {
1444
+ Positive => stable_mir:: ty:: ImplPolarity :: Positive ,
1445
+ Negative => stable_mir:: ty:: ImplPolarity :: Negative ,
1446
+ Reservation => stable_mir:: ty:: ImplPolarity :: Reservation ,
1447
+ }
1448
+ }
1449
+ }
1450
+
1451
+ impl < ' tcx > Stable < ' tcx > for ty:: Region < ' tcx > {
1452
+ type T = stable_mir:: ty:: Region ;
1453
+
1454
+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1455
+ // FIXME: add a real implementation of stable regions
1456
+ opaque ( self )
1457
+ }
1458
+ }
0 commit comments