@@ -334,7 +334,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
334
334
let mut local_visitor = FindInferSourceVisitor :: new ( & self , typeck_results, arg) ;
335
335
if let Some ( body_id) = body_id {
336
336
let expr = self . tcx . hir ( ) . expect_expr ( body_id. hir_id ) ;
337
- debug ! ( ?expr) ;
338
337
local_visitor. visit_expr ( expr) ;
339
338
}
340
339
@@ -550,6 +549,7 @@ impl<'tcx> InferSourceKind<'tcx> {
550
549
}
551
550
}
552
551
552
+ #[ derive( Debug ) ]
553
553
struct InsertableGenericArgs < ' tcx > {
554
554
insert_span : Span ,
555
555
substs : SubstsRef < ' tcx > ,
@@ -735,10 +735,20 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
735
735
return self . path_inferred_subst_iter ( expr. hir_id , substs, path) ;
736
736
}
737
737
}
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) , _, _) => {
739
749
if let Some ( ty) = self . opt_node_type ( expr. hir_id ) {
740
750
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) ) ;
742
752
}
743
753
}
744
754
}
@@ -945,6 +955,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
945
955
intravisit:: walk_body ( self , body) ;
946
956
}
947
957
958
+ #[ instrument( level = "debug" , skip( self ) ) ]
948
959
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
949
960
let tcx = self . infcx . tcx ;
950
961
match expr. kind {
@@ -959,9 +970,9 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
959
970
_ => intravisit:: walk_expr ( self , expr) ,
960
971
}
961
972
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 ;
965
976
let generics = tcx. generics_of ( generics_def_id) ;
966
977
if let Some ( argument_index) =
967
978
generics. own_substs ( substs) . iter ( ) . position ( |& arg| self . generic_arg_is_target ( arg) )
0 commit comments