Skip to content

Commit 579e526

Browse files
nikomatsakisGuillaumeGomez
authored andcommitted
make probe_for generic over final operation
1 parent 18b3357 commit 579e526

File tree

1 file changed

+19
-11
lines changed
  • src/librustc_typeck/check/method

1 file changed

+19
-11
lines changed

src/librustc_typeck/check/method/probe.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
161161
self_ty,
162162
return_type,
163163
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())
165166
}
166167

167168
pub fn probe_for_name(&self,
@@ -175,17 +176,24 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
175176
self_ty,
176177
item_name,
177178
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())
179185
}
180186

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+
{
189197
// FIXME(#18741) -- right now, creating the steps involves evaluating the
190198
// `*` operator, which registers obligations that then escape into
191199
// the global fulfillment context and thus has global
@@ -241,7 +249,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
241249
steps, opt_simplified_steps);
242250
probe_cx.assemble_inherent_candidates();
243251
probe_cx.assemble_extension_candidates_for_traits_in_scope(scope_expr_id)?;
244-
probe_cx.pick()
252+
op(&mut probe_cx)
245253
})
246254
}
247255

0 commit comments

Comments
 (0)