diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index e3f4d7056bd..c7dd4dd2646 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -654,22 +654,19 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } _ => { let overloaded_call_type = - match self.tcx() - .method_map - .borrow() - .get(&MethodCall::expr(call.id)) { - Some(ref method_callee) => { - OverloadedCallType::from_method_origin( - self.tcx(), - &method_callee.origin) - } - None => { - self.tcx().sess.span_bug( - callee.span, - format!("unexpected callee type {}", - callee_ty.repr(self.tcx()))[]) - } - }; + match self.typer.node_method_origin(MethodCall::expr(call.id)) { + Some(method_origin) => { + OverloadedCallType::from_method_origin( + self.tcx(), + &method_origin) + } + None => { + self.tcx().sess.span_bug( + callee.span, + format!("unexpected callee type {}", + callee_ty.repr(self.tcx())).as_slice()) + } + }; match overloaded_call_type { FnMutOverloadedCall => { self.borrow_expr(callee, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index eff5433c3e5..9f7472c2c73 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -285,6 +285,8 @@ pub trait Typer<'tcx> { fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx>; fn expr_ty_adjusted(&self, expr: &ast::Expr) -> Ty<'tcx>; fn node_method_ty(&self, method_call: ty::MethodCall) -> Option>; + fn node_method_origin(&self, method_call: ty::MethodCall) + -> Option>; fn adjustments<'a>(&'a self) -> &'a RefCell>>; fn is_method_call(&self, id: ast::NodeId) -> bool; fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 7add505e0eb..9cd07286735 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3003,9 +3003,9 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents { // FIXME(#14449): `borrowed_contents` below assumes `&mut` // unboxed closure. let upvars = unboxed_closure_upvars(cx, did, substs); - TypeContents::union(upvars[], - |f| tc_ty(cx, f.ty, cache)) | - borrowed_contents(r, MutMutable) + TypeContents::union(upvars.as_slice(), + |f| tc_ty(cx, f.ty, cache)) + | borrowed_contents(r, MutMutable) } ty_tup(ref tys) => { @@ -6177,6 +6177,12 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> { self.method_map.borrow().get(&method_call).map(|method| method.ty) } + fn node_method_origin(&self, method_call: ty::MethodCall) + -> Option> + { + self.method_map.borrow().get(&method_call).map(|method| method.origin.clone()) + } + fn adjustments<'a>(&'a self) -> &'a RefCell>> { &self.adjustments } diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 64ab9448795..ea2a4ef6b28 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -479,6 +479,16 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> { .map(|method| monomorphize_type(self, method.ty)) } + fn node_method_origin(&self, method_call: ty::MethodCall) + -> Option> + { + self.tcx() + .method_map + .borrow() + .get(&method_call) + .map(|method| method.origin.clone()) + } + fn adjustments<'a>(&'a self) -> &'a RefCell>> { &self.tcx().adjustments } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b046b39b283..535a4700854 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -301,6 +301,13 @@ impl<'a, 'tcx> mc::Typer<'tcx> for FnCtxt<'a, 'tcx> { .map(|method| method.ty) .map(|ty| self.infcx().resolve_type_vars_if_possible(&ty)) } + fn node_method_origin(&self, method_call: ty::MethodCall) + -> Option> + { + self.inh.method_map.borrow() + .get(&method_call) + .map(|method| method.origin.clone()) + } fn adjustments(&self) -> &RefCell>> { &self.inh.adjustments }