@@ -12,7 +12,6 @@ use rustc_infer::traits::solve::Goal;
1212use rustc_middle:: traits:: query:: NoSolution ;
1313use rustc_middle:: traits:: solve:: Certainty ;
1414use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeFoldable , TypeVisitableExt as _, TypingMode } ;
15- use rustc_next_trait_solver:: solve:: HasChanged ;
1615use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
1716
1817use crate :: traits:: { EvaluateConstErr , ObligationCause , specialization_graph} ;
@@ -61,19 +60,19 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
6160 & self ,
6261 goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
6362 span : Span ,
64- ) -> Option < HasChanged > {
63+ ) -> Option < Certainty > {
6564 let pred = goal. predicate . kind ( ) ;
6665 match pred. no_bound_vars ( ) ? {
6766 ty:: PredicateKind :: DynCompatible ( def_id) if self . 0 . tcx . is_dyn_compatible ( def_id) => {
68- Some ( HasChanged :: No )
67+ Some ( Certainty :: Yes )
6968 }
7069 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives ( outlives) ) => {
7170 self . 0 . sub_regions (
7271 SubregionOrigin :: RelateRegionParamBound ( span, None ) ,
7372 outlives. 1 ,
7473 outlives. 0 ,
7574 ) ;
76- Some ( HasChanged :: No )
75+ Some ( Certainty :: Yes )
7776 }
7877 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives ( outlives) ) => {
7978 self . 0 . register_type_outlives_constraint (
@@ -82,23 +81,34 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
8281 & ObligationCause :: dummy_with_span ( span) ,
8382 ) ;
8483
85- Some ( HasChanged :: No )
84+ Some ( Certainty :: Yes )
8685 }
8786 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( trait_pred) ) => {
8887 match self . 0 . tcx . as_lang_item ( trait_pred. def_id ( ) ) {
8988 Some ( LangItem :: Sized )
9089 if trait_pred. self_ty ( ) . is_trivially_sized ( self . 0 . tcx ) =>
9190 {
92- Some ( HasChanged :: No )
91+ Some ( Certainty :: Yes )
9392 }
9493 Some ( LangItem :: Copy | LangItem :: Clone )
9594 if trait_pred. self_ty ( ) . is_trivially_pure_clone_copy ( ) =>
9695 {
97- Some ( HasChanged :: No )
96+ Some ( Certainty :: Yes )
9897 }
9998 _ => None ,
10099 }
101100 }
101+ ty:: PredicateKind :: Subtype ( ty:: SubtypePredicate { a, b, .. } )
102+ | ty:: PredicateKind :: Coerce ( ty:: CoercePredicate { a, b } ) => {
103+ if self . shallow_resolve ( a) . is_ty_var ( ) && self . shallow_resolve ( b) . is_ty_var ( ) {
104+ // FIXME: We also need to register a subtype relation between these vars
105+ // when those are added, and if they aren't in the same sub root then
106+ // we should mark this goal as `has_changed`.
107+ Some ( Certainty :: AMBIGUOUS )
108+ } else {
109+ None
110+ }
111+ }
102112 _ => None ,
103113 }
104114 }
0 commit comments