@@ -55,10 +55,9 @@ use stdx::{always, never};
55
55
use triomphe:: Arc ;
56
56
57
57
use 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 ,
62
61
db:: HirDatabase ,
63
62
fold_tys,
64
63
generics:: Generics ,
@@ -70,6 +69,7 @@ use crate::{
70
69
} ,
71
70
lower:: { ImplTraitLoweringMode , LifetimeElisionKind , diagnostics:: TyLoweringDiagnostic } ,
72
71
mir:: MirSpan ,
72
+ next_solver:: { self , mapping:: ChalkToNextSolver } ,
73
73
static_lifetime, to_assoc_type_id,
74
74
traits:: FnTrait ,
75
75
utils:: UnevaluatedConstEvaluatorFolder ,
@@ -182,13 +182,13 @@ impl BindingMode {
182
182
}
183
183
184
184
#[ derive( Debug ) ]
185
- pub ( crate ) struct InferOk < T > {
185
+ pub ( crate ) struct InferOk < ' db , T > {
186
186
value : T ,
187
- goals : Vec < InEnvironment < Goal > > ,
187
+ goals : Vec < next_solver :: Goal < ' db , next_solver :: Predicate < ' db > > > ,
188
188
}
189
189
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 > {
192
192
InferOk { value : f ( self . value ) , goals : self . goals }
193
193
}
194
194
}
@@ -203,7 +203,7 @@ pub enum InferenceTyDiagnosticSource {
203
203
204
204
#[ derive( Debug ) ]
205
205
pub ( 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 > ;
207
207
208
208
#[ derive( Debug , PartialEq , Eq , Clone ) ]
209
209
pub enum InferenceDiagnostic {
@@ -832,6 +832,7 @@ impl<'db> InferenceContext<'db> {
832
832
coercion_casts,
833
833
diagnostics : _,
834
834
} = & mut result;
835
+ table. resolve_obligations_as_possible ( ) ;
835
836
table. fallback_if_possible ( ) ;
836
837
837
838
// Comment from rustc:
@@ -1480,7 +1481,8 @@ impl<'db> InferenceContext<'db> {
1480
1481
}
1481
1482
1482
1483
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 ) ) ;
1484
1486
}
1485
1487
1486
1488
fn unify ( & mut self , ty1 : & Ty , ty2 : & Ty ) -> bool {
@@ -1746,7 +1748,7 @@ impl<'db> InferenceContext<'db> {
1746
1748
1747
1749
ty = self . table . insert_type_vars ( ty) ;
1748
1750
ty = self . table . normalize_associated_types_in ( ty) ;
1749
- ty = self . table . resolve_ty_shallow ( & ty) ;
1751
+ ty = self . table . structurally_resolve_type ( & ty) ;
1750
1752
if ty. is_unknown ( ) {
1751
1753
return ( self . err_ty ( ) , None ) ;
1752
1754
}
@@ -1817,7 +1819,7 @@ impl<'db> InferenceContext<'db> {
1817
1819
let ty = match ty. kind ( Interner ) {
1818
1820
TyKind :: Alias ( AliasTy :: Projection ( proj_ty) ) => {
1819
1821
let ty = self . table . normalize_projection_ty ( proj_ty. clone ( ) ) ;
1820
- self . table . resolve_ty_shallow ( & ty)
1822
+ self . table . structurally_resolve_type ( & ty)
1821
1823
}
1822
1824
_ => ty,
1823
1825
} ;
@@ -2047,7 +2049,7 @@ impl Expectation {
2047
2049
fn adjust_for_branches ( & self , table : & mut unify:: InferenceTable < ' _ > ) -> Expectation {
2048
2050
match self {
2049
2051
Expectation :: HasType ( ety) => {
2050
- let ety = table. resolve_ty_shallow ( ety) ;
2052
+ let ety = table. structurally_resolve_type ( ety) ;
2051
2053
if ety. is_ty_var ( ) { Expectation :: None } else { Expectation :: HasType ( ety) }
2052
2054
}
2053
2055
Expectation :: RValueLikeUnsized ( ety) => Expectation :: RValueLikeUnsized ( ety. clone ( ) ) ,
0 commit comments