@@ -13,7 +13,7 @@ use stdx::never;
1313use crate :: {
1414 InferenceDiagnostic , Span , ValueTyDefId ,
1515 infer:: diagnostics:: InferenceTyLoweringContext as TyLoweringContext ,
16- lower:: { GenericPredicates , LifetimeElisionKind } ,
16+ lower:: { GenericPredicates , LifetimeElisionKind , TyLoweringInferVarsCtx } ,
1717 method_resolution:: { self , CandidateId , MethodError } ,
1818 next_solver:: {
1919 GenericArg , GenericArgs , TraitRef , Ty , Unnormalized , infer:: traits:: ObligationCause ,
@@ -38,7 +38,7 @@ impl<'db> InferenceContext<'_, 'db> {
3838 }
3939 ValuePathResolution :: NonGeneric ( ty) => return Some ( ( value, ty) ) ,
4040 } ;
41- let args = self . insert_type_vars ( substs, id . into ( ) ) ;
41+ let args = self . insert_type_vars ( substs) ;
4242
4343 self . add_required_obligations_for_value_path ( id, generic_def, args) ;
4444
@@ -117,7 +117,7 @@ impl<'db> InferenceContext<'_, 'db> {
117117 if let Some ( last_segment) = last_segment {
118118 path_ctx. set_current_segment ( last_segment)
119119 }
120- path_ctx. substs_from_path ( value_def, true , false )
120+ path_ctx. substs_from_path ( value_def, true , false , id . into ( ) )
121121 } )
122122 } ;
123123
@@ -147,8 +147,13 @@ impl<'db> InferenceContext<'_, 'db> {
147147 InferenceTyDiagnosticSource :: Body ,
148148 self . store_owner ,
149149 self . generic_def ,
150+ & self . generics ,
150151 LifetimeElisionKind :: Infer ,
151152 self . allow_using_generic_params ,
153+ Some ( TyLoweringInferVarsCtx {
154+ table : & mut self . table ,
155+ type_of_placeholder : & mut self . result . type_of_type_placeholder ,
156+ } ) ,
152157 & self . defined_anon_consts ,
153158 ) ;
154159 let mut path_ctx = if no_diagnostics {
@@ -160,12 +165,12 @@ impl<'db> InferenceContext<'_, 'db> {
160165 let last = path. segments ( ) . last ( ) ?;
161166
162167 let ( ty, orig_ns) = path_ctx. ty_ctx ( ) . lower_ty_ext ( type_ref) ;
163- let ty = self . table . process_user_written_ty ( type_ref . into ( ) , ty) ;
168+ let ty = path_ctx . expect_table ( ) . process_user_written_ty ( ty) ;
164169
165170 path_ctx. ignore_last_segment ( ) ;
166- let ( ty, _) = path_ctx. lower_ty_relative_path ( ty, orig_ns, true ) ;
171+ let ( ty, _) = path_ctx. lower_ty_relative_path ( ty, orig_ns, true , id . into ( ) ) ;
167172 drop_ctx ( ctx, no_diagnostics) ;
168- let ty = self . table . process_user_written_ty ( id . into ( ) , ty) ;
173+ let ty = self . table . process_user_written_ty ( ty) ;
169174 self . resolve_ty_assoc_item ( ty, last. name , id) . map ( |( it, substs) | ( it, Some ( substs) ) ) ?
170175 } else {
171176 let hygiene = self . store . expr_or_pat_path_hygiene ( id) ;
@@ -190,9 +195,13 @@ impl<'db> InferenceContext<'_, 'db> {
190195
191196 let ( resolution, substs) = match ( def, is_before_last) {
192197 ( TypeNs :: TraitId ( trait_) , true ) => {
193- let self_ty = self . table . next_ty_var ( id. into ( ) ) ;
194- let trait_ref =
195- path_ctx. lower_trait_ref_from_resolved_path ( trait_, self_ty, true ) ;
198+ let self_ty = path_ctx. expect_table ( ) . next_ty_var ( id. into ( ) ) ;
199+ let trait_ref = path_ctx. lower_trait_ref_from_resolved_path (
200+ trait_,
201+ self_ty,
202+ true ,
203+ id. into ( ) ,
204+ ) ;
196205 drop_ctx ( ctx, no_diagnostics) ;
197206 self . resolve_trait_assoc_item ( trait_ref, last_segment, id)
198207 }
@@ -202,13 +211,13 @@ impl<'db> InferenceContext<'_, 'db> {
202211 // should resolve to an associated type of that trait (e.g. `<T
203212 // as Iterator>::Item::default`)
204213 path_ctx. ignore_last_segment ( ) ;
205- let ( ty, _) = path_ctx. lower_partly_resolved_path ( def, true ) ;
214+ let ( ty, _) = path_ctx. lower_partly_resolved_path ( def, true , id . into ( ) ) ;
206215 drop_ctx ( ctx, no_diagnostics) ;
207216 if ty. is_ty_error ( ) {
208217 return None ;
209218 }
210219
211- let ty = self . process_user_written_ty ( id . into ( ) , ty) ;
220+ let ty = self . process_user_written_ty ( ty) ;
212221
213222 self . resolve_ty_assoc_item ( ty, last_segment. name , id)
214223 }
0 commit comments