@@ -55,10 +55,9 @@ use stdx::{always, never};
5555use triomphe:: Arc ;
5656
5757use crate :: {
58- AliasEq , AliasTy , Binders , ClosureId , Const , DomainGoal , GenericArg , Goal , ImplTraitId ,
59- ImplTraitIdx , InEnvironment , IncorrectGenericsLenKind , Interner , Lifetime , OpaqueTyId ,
60- ParamLoweringMode , PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty ,
61- TyBuilder , TyExt ,
58+ AliasEq , AliasTy , Binders , ClosureId , Const , DomainGoal , GenericArg , ImplTraitId , ImplTraitIdx ,
59+ IncorrectGenericsLenKind , Interner , Lifetime , OpaqueTyId , ParamLoweringMode ,
60+ PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty , TyBuilder , TyExt ,
6261 db:: HirDatabase ,
6362 fold_tys,
6463 generics:: Generics ,
@@ -70,6 +69,7 @@ use crate::{
7069 } ,
7170 lower:: { ImplTraitLoweringMode , LifetimeElisionKind , diagnostics:: TyLoweringDiagnostic } ,
7271 mir:: MirSpan ,
72+ next_solver:: { self , mapping:: ChalkToNextSolver } ,
7373 static_lifetime, to_assoc_type_id,
7474 traits:: FnTrait ,
7575 utils:: UnevaluatedConstEvaluatorFolder ,
@@ -182,13 +182,13 @@ impl BindingMode {
182182}
183183
184184#[ derive( Debug ) ]
185- pub ( crate ) struct InferOk < T > {
185+ pub ( crate ) struct InferOk < ' db , T > {
186186 value : T ,
187- goals : Vec < InEnvironment < Goal > > ,
187+ goals : Vec < next_solver :: Goal < ' db , next_solver :: Predicate < ' db > > > ,
188188}
189189
190- impl < T > InferOk < T > {
191- fn map < U > ( self , f : impl FnOnce ( T ) -> U ) -> InferOk < U > {
190+ impl < ' db , T > InferOk < ' db , T > {
191+ fn map < U > ( self , f : impl FnOnce ( T ) -> U ) -> InferOk < ' db , U > {
192192 InferOk { value : f ( self . value ) , goals : self . goals }
193193 }
194194}
@@ -203,7 +203,7 @@ pub enum InferenceTyDiagnosticSource {
203203
204204#[ derive( Debug ) ]
205205pub ( crate ) struct TypeError ;
206- pub ( crate ) type InferResult < T > = Result < InferOk < T > , TypeError > ;
206+ pub ( crate ) type InferResult < ' db , T > = Result < InferOk < ' db , T > , TypeError > ;
207207
208208#[ derive( Debug , PartialEq , Eq , Clone ) ]
209209pub enum InferenceDiagnostic {
@@ -832,6 +832,7 @@ impl<'db> InferenceContext<'db> {
832832 coercion_casts,
833833 diagnostics : _,
834834 } = & mut result;
835+ table. resolve_obligations_as_possible ( ) ;
835836 table. fallback_if_possible ( ) ;
836837
837838 // Comment from rustc:
@@ -1480,7 +1481,8 @@ impl<'db> InferenceContext<'db> {
14801481 }
14811482
14821483 fn push_obligation ( & mut self , o : DomainGoal ) {
1483- self . table . register_obligation ( o. cast ( Interner ) ) ;
1484+ let goal: crate :: Goal = o. cast ( Interner ) ;
1485+ self . table . register_obligation ( goal. to_nextsolver ( self . table . interner ) ) ;
14841486 }
14851487
14861488 fn unify ( & mut self , ty1 : & Ty , ty2 : & Ty ) -> bool {
@@ -1746,7 +1748,7 @@ impl<'db> InferenceContext<'db> {
17461748
17471749 ty = self . table . insert_type_vars ( ty) ;
17481750 ty = self . table . normalize_associated_types_in ( ty) ;
1749- ty = self . table . resolve_ty_shallow ( & ty) ;
1751+ ty = self . table . structurally_resolve_type ( & ty) ;
17501752 if ty. is_unknown ( ) {
17511753 return ( self . err_ty ( ) , None ) ;
17521754 }
@@ -1817,7 +1819,7 @@ impl<'db> InferenceContext<'db> {
18171819 let ty = match ty. kind ( Interner ) {
18181820 TyKind :: Alias ( AliasTy :: Projection ( proj_ty) ) => {
18191821 let ty = self . table . normalize_projection_ty ( proj_ty. clone ( ) ) ;
1820- self . table . resolve_ty_shallow ( & ty)
1822+ self . table . structurally_resolve_type ( & ty)
18211823 }
18221824 _ => ty,
18231825 } ;
@@ -2047,7 +2049,7 @@ impl Expectation {
20472049 fn adjust_for_branches ( & self , table : & mut unify:: InferenceTable < ' _ > ) -> Expectation {
20482050 match self {
20492051 Expectation :: HasType ( ety) => {
2050- let ety = table. resolve_ty_shallow ( ety) ;
2052+ let ety = table. structurally_resolve_type ( ety) ;
20512053 if ety. is_ty_var ( ) { Expectation :: None } else { Expectation :: HasType ( ety) }
20522054 }
20532055 Expectation :: RValueLikeUnsized ( ety) => Expectation :: RValueLikeUnsized ( ety. clone ( ) ) ,
0 commit comments