@@ -27,10 +27,10 @@ use ra_prof::profile;
2727use test_utils:: tested_by;
2828
2929use super :: {
30- autoderef, method_resolution, op, primitive,
30+ autoderef, lower , method_resolution, op, primitive,
3131 traits:: { Guidance , Obligation , ProjectionPredicate , Solution } ,
32- ApplicationTy , CallableDef , InEnvironment , ProjectionTy , Substs , TraitRef , Ty , TypableDef ,
33- TypeCtor ,
32+ ApplicationTy , CallableDef , Environment , InEnvironment , ProjectionTy , Substs , TraitRef , Ty ,
33+ TypableDef , TypeCtor ,
3434} ;
3535use crate :: {
3636 adt:: VariantDef ,
@@ -166,6 +166,7 @@ struct InferenceContext<'a, D: HirDatabase> {
166166 body : Arc < Body > ,
167167 resolver : Resolver ,
168168 var_unification_table : InPlaceUnificationTable < TypeVarId > ,
169+ trait_env : Arc < Environment > ,
169170 obligations : Vec < Obligation > ,
170171 method_resolutions : FxHashMap < ExprId , Function > ,
171172 field_resolutions : FxHashMap < ExprId , StructField > ,
@@ -189,6 +190,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
189190 var_unification_table : InPlaceUnificationTable :: new ( ) ,
190191 obligations : Vec :: default ( ) ,
191192 return_ty : Ty :: Unknown , // set in collect_fn_signature
193+ trait_env : lower:: trait_env ( db, & resolver) ,
192194 db,
193195 body,
194196 resolver,
@@ -331,8 +333,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
331333 for obligation in obligations {
332334 match & obligation {
333335 Obligation :: Trait ( tr) => {
334- let env = Arc :: new ( super :: Environment ) ; // FIXME add environment
335- let in_env = InEnvironment :: new ( env, tr. clone ( ) ) ;
336+ let in_env = InEnvironment :: new ( self . trait_env . clone ( ) , tr. clone ( ) ) ;
336337 let canonicalized = self . canonicalizer ( ) . canonicalize_trait_ref ( in_env) ;
337338 let solution = self
338339 . db
0 commit comments