@@ -662,7 +662,7 @@ pub enum PredicateKind<'tcx> {
662
662
/// `NormalizesTo(<T as Trait>::Assoc, ?x)` results in `NoSolution`.
663
663
///
664
664
/// Only used in the new solver.
665
- NormalizesTo ( ProjectionPredicate < ' tcx > ) ,
665
+ NormalizesTo ( NormalizesTo < ' tcx > ) ,
666
666
667
667
/// Separate from `Clause::Projection` which is used for normalization in new solver.
668
668
/// This predicate requires two terms to be equal to eachother.
@@ -1184,6 +1184,33 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
1184
1184
}
1185
1185
}
1186
1186
1187
+ /// Used by the new solver. Unlike a `ProjectionPredicate` this can only be
1188
+ /// proven by actually normalizing `alias`.
1189
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , TyEncodable , TyDecodable ) ]
1190
+ #[ derive( HashStable , TypeFoldable , TypeVisitable , Lift ) ]
1191
+ pub struct NormalizesTo < ' tcx > {
1192
+ pub alias : AliasTy < ' tcx > ,
1193
+ pub term : Term < ' tcx > ,
1194
+ }
1195
+
1196
+ impl < ' tcx > NormalizesTo < ' tcx > {
1197
+ pub fn self_ty ( self ) -> Ty < ' tcx > {
1198
+ self . alias . self_ty ( )
1199
+ }
1200
+
1201
+ pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> NormalizesTo < ' tcx > {
1202
+ Self { alias : self . alias . with_self_ty ( tcx, self_ty) , ..self }
1203
+ }
1204
+
1205
+ pub fn trait_def_id ( self , tcx : TyCtxt < ' tcx > ) -> DefId {
1206
+ self . alias . trait_def_id ( tcx)
1207
+ }
1208
+
1209
+ pub fn def_id ( self ) -> DefId {
1210
+ self . alias . def_id
1211
+ }
1212
+ }
1213
+
1187
1214
pub trait ToPolyTraitRef < ' tcx > {
1188
1215
fn to_poly_trait_ref ( & self ) -> PolyTraitRef < ' tcx > ;
1189
1216
}
@@ -1306,6 +1333,12 @@ impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
1306
1333
}
1307
1334
}
1308
1335
1336
+ impl < ' tcx > ToPredicate < ' tcx > for ProjectionPredicate < ' tcx > {
1337
+ fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1338
+ ty:: Binder :: dummy ( self ) . to_predicate ( tcx)
1339
+ }
1340
+ }
1341
+
1309
1342
impl < ' tcx > ToPredicate < ' tcx > for PolyProjectionPredicate < ' tcx > {
1310
1343
fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1311
1344
self . map_bound ( |p| PredicateKind :: Clause ( Clause :: Projection ( p) ) ) . to_predicate ( tcx)
@@ -1324,6 +1357,18 @@ impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
1324
1357
}
1325
1358
}
1326
1359
1360
+ impl < ' tcx > ToPredicate < ' tcx > for NormalizesTo < ' tcx > {
1361
+ fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1362
+ PredicateKind :: NormalizesTo ( self ) . to_predicate ( tcx)
1363
+ }
1364
+ }
1365
+
1366
+ impl < ' tcx > ToPredicate < ' tcx > for ty:: Binder < ' tcx , NormalizesTo < ' tcx > > {
1367
+ fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1368
+ self . map_bound ( |p| PredicateKind :: NormalizesTo ( p) ) . to_predicate ( tcx)
1369
+ }
1370
+ }
1371
+
1327
1372
impl < ' tcx > Predicate < ' tcx > {
1328
1373
pub fn to_opt_poly_trait_pred ( self ) -> Option < PolyTraitPredicate < ' tcx > > {
1329
1374
let predicate = self . kind ( ) ;
@@ -1395,7 +1440,8 @@ impl<'tcx> Predicate<'tcx> {
1395
1440
let predicate = self . kind ( ) ;
1396
1441
match predicate. skip_binder ( ) {
1397
1442
PredicateKind :: Clause ( clause) => Some ( predicate. rebind ( clause) ) ,
1398
- PredicateKind :: AliasRelate ( ..)
1443
+ PredicateKind :: NormalizesTo ( ..)
1444
+ | PredicateKind :: AliasRelate ( ..)
1399
1445
| PredicateKind :: Subtype ( ..)
1400
1446
| PredicateKind :: Coerce ( ..)
1401
1447
| PredicateKind :: WellFormed ( ..)
0 commit comments