@@ -161,7 +161,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
161
161
self_ty,
162
162
return_type,
163
163
scope_expr_id) ;
164
- self . probe_for ( span, mode, LookingFor :: ReturnType ( return_type) , self_ty, scope_expr_id)
164
+ self . probe_op ( span, mode, LookingFor :: ReturnType ( return_type) , self_ty, scope_expr_id,
165
+ |probe_cx| probe_cx. pick ( ) )
165
166
}
166
167
167
168
pub fn probe_for_name ( & self ,
@@ -175,17 +176,24 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
175
176
self_ty,
176
177
item_name,
177
178
scope_expr_id) ;
178
- self . probe_for ( span, mode, LookingFor :: MethodName ( item_name) , self_ty, scope_expr_id)
179
+ self . probe_op ( span,
180
+ mode,
181
+ LookingFor :: MethodName ( item_name) ,
182
+ self_ty,
183
+ scope_expr_id,
184
+ |probe_cx| probe_cx. pick ( ) )
179
185
}
180
186
181
- fn probe_for ( & self ,
182
- span : Span ,
183
- mode : Mode ,
184
- looking_for : LookingFor < ' tcx > ,
185
- self_ty : Ty < ' tcx > ,
186
- scope_expr_id : ast:: NodeId )
187
- -> PickResult < ' tcx > {
188
-
187
+ fn probe_op < ' a , OP , R > ( & ' a self ,
188
+ span : Span ,
189
+ mode : Mode ,
190
+ looking_for : LookingFor < ' tcx > ,
191
+ self_ty : Ty < ' tcx > ,
192
+ scope_expr_id : ast:: NodeId ,
193
+ op : OP )
194
+ -> R
195
+ where OP : FnOnce ( & mut ProbeContext < ' a , ' gcx , ' tcx > ) -> R
196
+ {
189
197
// FIXME(#18741) -- right now, creating the steps involves evaluating the
190
198
// `*` operator, which registers obligations that then escape into
191
199
// the global fulfillment context and thus has global
@@ -241,7 +249,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
241
249
steps, opt_simplified_steps) ;
242
250
probe_cx. assemble_inherent_candidates ( ) ;
243
251
probe_cx. assemble_extension_candidates_for_traits_in_scope ( scope_expr_id) ?;
244
- probe_cx . pick ( )
252
+ op ( & mut probe_cx )
245
253
} )
246
254
}
247
255
0 commit comments