@@ -16,8 +16,8 @@ use triomphe::Arc;
16
16
17
17
use super :: { InferOk , InferResult , InferenceContext , TypeError } ;
18
18
use 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 ,
21
21
Const , ConstValue , DebruijnIndex , DomainGoal , GenericArg , GenericArgData , Goal , GoalData ,
22
22
Guidance , InEnvironment , InferenceVar , Interner , Lifetime , OpaqueTyId , ParamKind , ProjectionTy ,
23
23
ProjectionTyExt , Scalar , Solution , Substitution , TraitEnvironment , Ty , TyBuilder , TyExt ,
@@ -43,40 +43,21 @@ impl InferenceContext<'_> {
43
43
let obligations = pending_obligations
44
44
. iter ( )
45
45
. 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 ) ;
80
61
if matches ! (
81
62
self . resolve_ty_shallow( & uncanonical) . kind( Interner ) ,
82
63
TyKind :: InferenceVar ( iv, TyVariableKind :: General ) if * iv == root,
@@ -121,8 +102,9 @@ impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
121
102
VariableKind :: Ty ( TyVariableKind :: General ) => ctx. new_type_var ( ) . cast ( Interner ) ,
122
103
VariableKind :: Ty ( TyVariableKind :: Integer ) => ctx. new_integer_var ( ) . cast ( Interner ) ,
123
104
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 ) ,
126
108
VariableKind :: Const ( ty) => ctx. new_const_var ( ty. clone ( ) ) . cast ( Interner ) ,
127
109
} ) ,
128
110
) ;
@@ -1020,11 +1002,11 @@ mod resolve {
1020
1002
_var : InferenceVar ,
1021
1003
_outer_binder : DebruijnIndex ,
1022
1004
) -> 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
1024
1006
// with any lifetimes, but we can sometimes get some lifetime
1025
1007
// variables through Chalk's unification, and this at least makes
1026
1008
// sure we don't leak them outside of inference
1027
- crate :: static_lifetime ( )
1009
+ crate :: error_lifetime ( )
1028
1010
}
1029
1011
}
1030
1012
}
0 commit comments