@@ -537,12 +537,14 @@ impl<'tcx> Predicate<'tcx> {
537537 pub fn allow_normalization ( self ) -> bool {
538538 match self . kind ( ) . skip_binder ( ) {
539539 PredicateKind :: WellFormed ( _) => false ,
540+ // Only used by the new solver where we should not
541+ // normalize any goals.
542+ PredicateKind :: NormalizesTo ( ..) | PredicateKind :: AliasRelate ( ..) => false ,
540543 PredicateKind :: Clause ( Clause :: Trait ( _) )
541544 | PredicateKind :: Clause ( Clause :: RegionOutlives ( _) )
542545 | PredicateKind :: Clause ( Clause :: TypeOutlives ( _) )
543546 | PredicateKind :: Clause ( Clause :: Projection ( _) )
544547 | PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
545- | PredicateKind :: AliasRelate ( ..)
546548 | PredicateKind :: ObjectSafe ( _)
547549 | PredicateKind :: ClosureKind ( _, _, _)
548550 | PredicateKind :: Subtype ( _)
@@ -653,10 +655,19 @@ pub enum PredicateKind<'tcx> {
653655 /// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
654656 Ambiguous ,
655657
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+
656667 /// Separate from `Clause::Projection` which is used for normalization in new solver.
657668 /// This predicate requires two terms to be equal to eachother.
658669 ///
659- /// Only used for new solver
670+ /// Only used in the new solver.
660671 AliasRelate ( Term < ' tcx > , Term < ' tcx > , AliasRelationDirection ) ,
661672}
662673
@@ -1320,6 +1331,7 @@ impl<'tcx> Predicate<'tcx> {
13201331 PredicateKind :: Clause ( Clause :: Trait ( t) ) => Some ( predicate. rebind ( t) ) ,
13211332 PredicateKind :: Clause ( Clause :: Projection ( ..) )
13221333 | PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
1334+ | PredicateKind :: NormalizesTo ( ..)
13231335 | PredicateKind :: AliasRelate ( ..)
13241336 | PredicateKind :: Subtype ( ..)
13251337 | PredicateKind :: Coerce ( ..)
@@ -1341,6 +1353,7 @@ impl<'tcx> Predicate<'tcx> {
13411353 PredicateKind :: Clause ( Clause :: Projection ( t) ) => Some ( predicate. rebind ( t) ) ,
13421354 PredicateKind :: Clause ( Clause :: Trait ( ..) )
13431355 | PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
1356+ | PredicateKind :: NormalizesTo ( ..)
13441357 | PredicateKind :: AliasRelate ( ..)
13451358 | PredicateKind :: Subtype ( ..)
13461359 | PredicateKind :: Coerce ( ..)
@@ -1363,6 +1376,7 @@ impl<'tcx> Predicate<'tcx> {
13631376 PredicateKind :: Clause ( Clause :: Trait ( ..) )
13641377 | PredicateKind :: Clause ( Clause :: ConstArgHasType ( ..) )
13651378 | PredicateKind :: Clause ( Clause :: Projection ( ..) )
1379+ | PredicateKind :: NormalizesTo ( ..)
13661380 | PredicateKind :: AliasRelate ( ..)
13671381 | PredicateKind :: Subtype ( ..)
13681382 | PredicateKind :: Coerce ( ..)
0 commit comments