@@ -94,71 +94,82 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
94
94
self . find_ambiguous_parameter_in ( def_id, error. root_obligation . predicate ) ;
95
95
}
96
96
97
- let ( expr , qpath ) = match self . tcx . hir_node ( hir_id) {
98
- hir:: Node :: Expr ( expr ) => {
99
- if self . closure_span_overlaps_error ( error, expr . span ) {
97
+ match self . tcx . hir_node ( hir_id) {
98
+ hir:: Node :: Expr ( & hir :: Expr { kind : hir :: ExprKind :: Path ( qpath ) , span , .. } ) => {
99
+ if self . closure_span_overlaps_error ( error, span) {
100
100
return false ;
101
101
}
102
- let qpath =
103
- if let hir:: ExprKind :: Path ( qpath) = expr. kind { Some ( qpath) } else { None } ;
104
102
105
- ( Some ( & expr . kind ) , qpath )
106
- }
107
- hir :: Node :: Ty ( hir :: Ty { kind : hir :: TyKind :: Path ( qpath ) , .. } ) => ( None , Some ( * qpath ) ) ,
108
- _ => return false ,
109
- } ;
103
+ if let Some ( param ) = predicate_self_type_to_point_at
104
+ && self . point_at_path_if_possible ( error , def_id , param , & qpath )
105
+ {
106
+ return true ;
107
+ }
110
108
111
- if let Some ( qpath) = qpath {
112
- // Prefer pointing at the turbofished arg that corresponds to the
113
- // self type of the failing predicate over anything else.
114
- if let Some ( param) = predicate_self_type_to_point_at
115
- && self . point_at_path_if_possible ( error, def_id, param, & qpath)
116
- {
117
- return true ;
118
- }
109
+ if let hir:: Node :: Expr ( hir:: Expr {
110
+ kind : hir:: ExprKind :: Call ( callee, args) ,
111
+ hir_id : call_hir_id,
112
+ span : call_span,
113
+ ..
114
+ } ) = self . tcx . parent_hir_node ( hir_id)
115
+ && callee. hir_id == hir_id
116
+ {
117
+ if self . closure_span_overlaps_error ( error, * call_span) {
118
+ return false ;
119
+ }
119
120
120
- if let hir:: Node :: Expr ( hir:: Expr {
121
- kind : hir:: ExprKind :: Call ( callee, args) ,
122
- hir_id : call_hir_id,
123
- span : call_span,
124
- ..
125
- } ) = self . tcx . parent_hir_node ( hir_id)
126
- && callee. hir_id == hir_id
127
- {
128
- if self . closure_span_overlaps_error ( error, * call_span) {
129
- return false ;
121
+ for param in
122
+ [ param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
123
+ . into_iter ( )
124
+ . flatten ( )
125
+ {
126
+ if self . blame_specific_arg_if_possible (
127
+ error,
128
+ def_id,
129
+ param,
130
+ * call_hir_id,
131
+ callee. span ,
132
+ None ,
133
+ args,
134
+ ) {
135
+ return true ;
136
+ }
137
+ }
130
138
}
131
139
132
140
for param in [ param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
133
141
. into_iter ( )
134
142
. flatten ( )
135
143
{
136
- if self . blame_specific_arg_if_possible (
137
- error,
138
- def_id,
139
- param,
140
- * call_hir_id,
141
- callee. span ,
142
- None ,
143
- args,
144
- ) {
144
+ if self . point_at_path_if_possible ( error, def_id, param, & qpath) {
145
145
return true ;
146
146
}
147
147
}
148
148
}
149
-
150
- for param in [ param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
149
+ hir:: Node :: Ty ( hir:: Ty { kind : hir:: TyKind :: Path ( qpath) , .. } ) => {
150
+ for param in [
151
+ predicate_self_type_to_point_at,
152
+ param_to_point_at,
153
+ fallback_param_to_point_at,
154
+ self_param_to_point_at,
155
+ ]
151
156
. into_iter ( )
152
157
. flatten ( )
153
- {
154
- if self . point_at_path_if_possible ( error, def_id, param, & qpath) {
155
- return true ;
158
+ {
159
+ if self . point_at_path_if_possible ( error, def_id, param, & qpath) {
160
+ return true ;
161
+ }
156
162
}
157
163
}
158
- }
164
+ hir:: Node :: Expr ( & hir:: Expr {
165
+ kind : hir:: ExprKind :: MethodCall ( segment, receiver, args, ..) ,
166
+ span,
167
+ ..
168
+ } ) => {
169
+ if self . closure_span_overlaps_error ( error, span) {
170
+ return false ;
171
+ }
159
172
160
- match expr {
161
- Some ( hir:: ExprKind :: MethodCall ( segment, receiver, args, ..) ) => {
162
173
if let Some ( param) = predicate_self_type_to_point_at
163
174
&& self . point_at_generic_if_possible ( error, def_id, param, segment)
164
175
{
@@ -208,7 +219,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
208
219
return true ;
209
220
}
210
221
}
211
- Some ( hir:: ExprKind :: Struct ( qpath, fields, ..) ) => {
222
+ hir:: Node :: Expr ( & hir:: Expr {
223
+ kind : hir:: ExprKind :: Struct ( qpath, fields, ..) ,
224
+ span,
225
+ ..
226
+ } ) => {
227
+ if self . closure_span_overlaps_error ( error, span) {
228
+ return false ;
229
+ }
230
+
212
231
if let Res :: Def ( DefKind :: Struct | DefKind :: Variant , variant_def_id) =
213
232
self . typeck_results . borrow ( ) . qpath_res ( qpath, hir_id)
214
233
{
0 commit comments