@@ -16,8 +16,8 @@ use triomphe::Arc;
1616
1717use super :: { InferOk , InferResult , InferenceContext , TypeError } ;
1818use crate :: {
19- consteval:: unknown_const, db:: HirDatabase , fold_generic_args , fold_tys_and_consts ,
20- static_lifetime , to_chalk_trait_id, traits:: FnTrait , AliasEq , AliasTy , BoundVar , Canonical ,
19+ consteval:: unknown_const, db:: HirDatabase , error_lifetime , fold_generic_args ,
20+ fold_tys_and_consts , to_chalk_trait_id, traits:: FnTrait , AliasEq , AliasTy , BoundVar , Canonical ,
2121 Const , ConstValue , DebruijnIndex , DomainGoal , GenericArg , GenericArgData , Goal , GoalData ,
2222 Guidance , InEnvironment , InferenceVar , Interner , Lifetime , OpaqueTyId , ParamKind , ProjectionTy ,
2323 ProjectionTyExt , Scalar , Solution , Substitution , TraitEnvironment , Ty , TyBuilder , TyExt ,
@@ -43,40 +43,21 @@ impl InferenceContext<'_> {
4343 let obligations = pending_obligations
4444 . iter ( )
4545 . filter_map ( |obligation| match obligation. value . value . goal . data ( Interner ) {
46- GoalData :: DomainGoal ( DomainGoal :: Holds (
47- clause @ WhereClause :: AliasEq ( AliasEq {
48- alias : AliasTy :: Projection ( projection) ,
49- ..
50- } ) ,
51- ) ) => {
52- let projection_self = projection. self_type_parameter ( self . db ) ;
53- let uncanonical = chalk_ir:: Substitute :: apply (
54- & obligation. free_vars ,
55- projection_self,
56- Interner ,
57- ) ;
58- if matches ! (
59- self . resolve_ty_shallow( & uncanonical) . kind( Interner ) ,
60- TyKind :: InferenceVar ( iv, TyVariableKind :: General ) if * iv == root,
61- ) {
62- Some ( chalk_ir:: Substitute :: apply (
63- & obligation. free_vars ,
64- clause. clone ( ) ,
65- Interner ,
66- ) )
67- } else {
68- None
69- }
70- }
71- GoalData :: DomainGoal ( DomainGoal :: Holds (
72- clause @ WhereClause :: Implemented ( trait_ref) ,
73- ) ) => {
74- let trait_ref_self = trait_ref. self_type_parameter ( Interner ) ;
75- let uncanonical = chalk_ir:: Substitute :: apply (
76- & obligation. free_vars ,
77- trait_ref_self,
78- Interner ,
79- ) ;
46+ GoalData :: DomainGoal ( DomainGoal :: Holds ( clause) ) => {
47+ let ty = match clause {
48+ WhereClause :: AliasEq ( AliasEq {
49+ alias : AliasTy :: Projection ( projection) ,
50+ ..
51+ } ) => projection. self_type_parameter ( self . db ) ,
52+ WhereClause :: Implemented ( trait_ref) => {
53+ trait_ref. self_type_parameter ( Interner )
54+ }
55+ WhereClause :: TypeOutlives ( to) => to. ty . clone ( ) ,
56+ _ => return None ,
57+ } ;
58+
59+ let uncanonical =
60+ chalk_ir:: Substitute :: apply ( & obligation. free_vars , ty, Interner ) ;
8061 if matches ! (
8162 self . resolve_ty_shallow( & uncanonical) . kind( Interner ) ,
8263 TyKind :: InferenceVar ( iv, TyVariableKind :: General ) if * iv == root,
@@ -121,8 +102,9 @@ impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
121102 VariableKind :: Ty ( TyVariableKind :: General ) => ctx. new_type_var ( ) . cast ( Interner ) ,
122103 VariableKind :: Ty ( TyVariableKind :: Integer ) => ctx. new_integer_var ( ) . cast ( Interner ) ,
123104 VariableKind :: Ty ( TyVariableKind :: Float ) => ctx. new_float_var ( ) . cast ( Interner ) ,
124- // Chalk can sometimes return new lifetime variables. We just use the static lifetime everywhere
125- VariableKind :: Lifetime => static_lifetime ( ) . cast ( Interner ) ,
105+ // Chalk can sometimes return new lifetime variables. We just replace them by errors
106+ // for now.
107+ VariableKind :: Lifetime => error_lifetime ( ) . cast ( Interner ) ,
126108 VariableKind :: Const ( ty) => ctx. new_const_var ( ty. clone ( ) ) . cast ( Interner ) ,
127109 } ) ,
128110 ) ;
@@ -1020,11 +1002,11 @@ mod resolve {
10201002 _var : InferenceVar ,
10211003 _outer_binder : DebruijnIndex ,
10221004 ) -> Lifetime {
1023- // fall back all lifetimes to 'static -- currently we don't deal
1005+ // fall back all lifetimes to 'error -- currently we don't deal
10241006 // with any lifetimes, but we can sometimes get some lifetime
10251007 // variables through Chalk's unification, and this at least makes
10261008 // sure we don't leak them outside of inference
1027- crate :: static_lifetime ( )
1009+ crate :: error_lifetime ( )
10281010 }
10291011 }
10301012}
0 commit comments