@@ -537,12 +537,14 @@ impl<'tcx> Predicate<'tcx> {
537
537
pub fn allow_normalization ( self ) -> bool {
538
538
match self . kind ( ) . skip_binder ( ) {
539
539
PredicateKind :: WellFormed ( _) => false ,
540
+ // Only used by the new solver where we should not
541
+ // normalize any goals.
542
+ PredicateKind :: NormalizesTo ( ..) | PredicateKind :: AliasRelate ( ..) => false ,
540
543
PredicateKind :: Clause ( Clause :: Trait ( _) )
541
544
| PredicateKind :: Clause ( Clause :: RegionOutlives ( _) )
542
545
| PredicateKind :: Clause ( Clause :: TypeOutlives ( _) )
543
546
| PredicateKind :: Clause ( Clause :: Projection ( _) )
544
547
| PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
545
- | PredicateKind :: AliasRelate ( ..)
546
548
| PredicateKind :: ObjectSafe ( _)
547
549
| PredicateKind :: ClosureKind ( _, _, _)
548
550
| PredicateKind :: Subtype ( _)
@@ -653,10 +655,19 @@ pub enum PredicateKind<'tcx> {
653
655
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
654
656
Ambiguous ,
655
657
658
+ /// The alias normalizes to `term`. Unlike `Projection`, this always fails if the alias
659
+ /// cannot be normalized in the current context.
660
+ ///
661
+ /// `Projection(<T as Trait>::Assoc, ?x)` results in `?x == <T as Trait>::Assoc` while
662
+ /// `NormalizesTo(<T as Trait>::Assoc, ?x)` results in `NoSolution`.
663
+ ///
664
+ /// Only used in the new solver.
665
+ NormalizesTo ( ProjectionPredicate < ' tcx > ) ,
666
+
656
667
/// Separate from `Clause::Projection` which is used for normalization in new solver.
657
668
/// This predicate requires two terms to be equal to eachother.
658
669
///
659
- /// Only used for new solver
670
+ /// Only used in the new solver.
660
671
AliasRelate ( Term < ' tcx > , Term < ' tcx > , AliasRelationDirection ) ,
661
672
}
662
673
@@ -1320,6 +1331,7 @@ impl<'tcx> Predicate<'tcx> {
1320
1331
PredicateKind :: Clause ( Clause :: Trait ( t) ) => Some ( predicate. rebind ( t) ) ,
1321
1332
PredicateKind :: Clause ( Clause :: Projection ( ..) )
1322
1333
| PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
1334
+ | PredicateKind :: NormalizesTo ( ..)
1323
1335
| PredicateKind :: AliasRelate ( ..)
1324
1336
| PredicateKind :: Subtype ( ..)
1325
1337
| PredicateKind :: Coerce ( ..)
@@ -1341,6 +1353,7 @@ impl<'tcx> Predicate<'tcx> {
1341
1353
PredicateKind :: Clause ( Clause :: Projection ( t) ) => Some ( predicate. rebind ( t) ) ,
1342
1354
PredicateKind :: Clause ( Clause :: Trait ( ..) )
1343
1355
| PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
1356
+ | PredicateKind :: NormalizesTo ( ..)
1344
1357
| PredicateKind :: AliasRelate ( ..)
1345
1358
| PredicateKind :: Subtype ( ..)
1346
1359
| PredicateKind :: Coerce ( ..)
@@ -1363,6 +1376,7 @@ impl<'tcx> Predicate<'tcx> {
1363
1376
PredicateKind :: Clause ( Clause :: Trait ( ..) )
1364
1377
| PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
1365
1378
| PredicateKind :: Clause ( Clause :: Projection ( ..) )
1379
+ | PredicateKind :: NormalizesTo ( ..)
1366
1380
| PredicateKind :: AliasRelate ( ..)
1367
1381
| PredicateKind :: Subtype ( ..)
1368
1382
| PredicateKind :: Coerce ( ..)
0 commit comments