Skip to content

Commit

Permalink
make probe_for generic over final operation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis authored and GuillaumeGomez committed Dec 20, 2016
1 parent 18b3357 commit 579e526
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/librustc_typeck/check/method/probe.rs
Expand Up @@ -161,7 +161,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self_ty,
return_type,
scope_expr_id);
self.probe_for(span, mode, LookingFor::ReturnType(return_type), self_ty, scope_expr_id)
self.probe_op(span, mode, LookingFor::ReturnType(return_type), self_ty, scope_expr_id,
|probe_cx| probe_cx.pick())
}

pub fn probe_for_name(&self,
Expand All @@ -175,17 +176,24 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self_ty,
item_name,
scope_expr_id);
self.probe_for(span, mode, LookingFor::MethodName(item_name), self_ty, scope_expr_id)
self.probe_op(span,
mode,
LookingFor::MethodName(item_name),
self_ty,
scope_expr_id,
|probe_cx| probe_cx.pick())
}

fn probe_for(&self,
span: Span,
mode: Mode,
looking_for: LookingFor<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: ast::NodeId)
-> PickResult<'tcx> {

fn probe_op<'a,OP,R>(&'a self,
span: Span,
mode: Mode,
looking_for: LookingFor<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: ast::NodeId,
op: OP)
-> R
where OP: FnOnce(&mut ProbeContext<'a, 'gcx, 'tcx>) -> R
{
// FIXME(#18741) -- right now, creating the steps involves evaluating the
// `*` operator, which registers obligations that then escape into
// the global fulfillment context and thus has global
Expand Down Expand Up @@ -241,7 +249,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
steps, opt_simplified_steps);
probe_cx.assemble_inherent_candidates();
probe_cx.assemble_extension_candidates_for_traits_in_scope(scope_expr_id)?;
probe_cx.pick()
op(&mut probe_cx)
})
}

Expand Down

0 comments on commit 579e526

Please sign in to comment.