@@ -334,7 +334,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
334334 let mut local_visitor = FindInferSourceVisitor :: new ( & self , typeck_results, arg) ;
335335 if let Some ( body_id) = body_id {
336336 let expr = self . tcx . hir ( ) . expect_expr ( body_id. hir_id ) ;
337- debug ! ( ?expr) ;
338337 local_visitor. visit_expr ( expr) ;
339338 }
340339
@@ -550,6 +549,7 @@ impl<'tcx> InferSourceKind<'tcx> {
550549 }
551550}
552551
552+ #[ derive( Debug ) ]
553553struct InsertableGenericArgs < ' tcx > {
554554 insert_span : Span ,
555555 substs : SubstsRef < ' tcx > ,
@@ -735,10 +735,20 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
735735 return self . path_inferred_subst_iter ( expr. hir_id , substs, path) ;
736736 }
737737 }
738- hir:: ExprKind :: Struct ( path, _, _) => {
738+ // FIXME(#98711): Ideally we would also deal with type relative
739+ // paths here, even if that is quite rare.
740+ //
741+ // See the `need_type_info/expr-struct-type-relative-gat.rs` test
742+ // for an example where that would be needed.
743+ //
744+ // However, the `type_dependent_def_id` for `Self::Output` in an
745+ // impl is currently the `DefId` of `Output` in the trait definition
746+ // which makes this somewhat difficult and prevents us from just
747+ // using `self.path_inferred_subst_iter` here.
748+ hir:: ExprKind :: Struct ( & hir:: QPath :: Resolved ( _self_ty, path) , _, _) => {
739749 if let Some ( ty) = self . opt_node_type ( expr. hir_id ) {
740750 if let ty:: Adt ( _, substs) = ty. kind ( ) {
741- return self . path_inferred_subst_iter ( expr . hir_id , substs, path ) ;
751+ return Box :: new ( self . resolved_path_inferred_subst_iter ( path , substs) ) ;
742752 }
743753 }
744754 }
@@ -945,6 +955,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
945955 intravisit:: walk_body ( self , body) ;
946956 }
947957
958+ #[ instrument( level = "debug" , skip( self ) ) ]
948959 fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
949960 let tcx = self . infcx . tcx ;
950961 match expr. kind {
@@ -959,9 +970,9 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
959970 _ => intravisit:: walk_expr ( self , expr) ,
960971 }
961972
962- for InsertableGenericArgs { insert_span , substs , generics_def_id , def_id } in
963- self . expr_inferred_subst_iter ( expr )
964- {
973+ for args in self . expr_inferred_subst_iter ( expr ) {
974+ debug ! ( ?args ) ;
975+ let InsertableGenericArgs { insert_span , substs , generics_def_id , def_id } = args ;
965976 let generics = tcx. generics_of ( generics_def_id) ;
966977 if let Some ( argument_index) =
967978 generics. own_substs ( substs) . iter ( ) . position ( |& arg| self . generic_arg_is_target ( arg) )
0 commit comments