diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index a55ef23ddad0..6ec9171057b2 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -647,7 +647,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) { - let callee_ty = ty::expr_ty_adjusted(self.tcx(), callee); + let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee)); debug!("walk_callee: callee={} callee_ty={}", callee.repr(self.tcx()), callee_ty.repr(self.tcx())); let call_scope = region::CodeExtent::from_node_id(call.id); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 932a124ed339..7dadd832ca2c 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -285,6 +285,7 @@ pub type McResult = Result; pub trait Typer<'tcx> { fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; fn node_ty(&self, id: ast::NodeId) -> McResult>; + fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult>; fn node_method_ty(&self, method_call: ty::MethodCall) -> Option>; fn adjustments<'a>(&'a self) -> &'a RefCell>>; fn is_method_call(&self, id: ast::NodeId) -> bool; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 9c1259f41202..659cf85937ec 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -6169,7 +6169,11 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> { Ok(ty::node_id_to_type(self, id)) } - fn node_method_ty(&self, method_call: MethodCall) -> Option> { + fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult> { + Ok(ty::expr_ty_adjusted(self, expr)) + } + + fn node_method_ty(&self, method_call: ty::MethodCall) -> Option> { self.method_map.borrow().get(&method_call).map(|method| method.ty) } diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 9a3e39ff10b3..883205765f25 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -467,6 +467,10 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> { Ok(node_id_type(self, id)) } + fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult> { + Ok(expr_ty_adjusted(self, expr)) + } + fn node_method_ty(&self, method_call: ty::MethodCall) -> Option> { self.tcx() .method_map @@ -752,11 +756,11 @@ pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty monomorphize_type(bcx, t) } -pub fn expr_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> { +pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> { node_id_type(bcx, ex.id) } -pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> { +pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> { monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex)) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 835e48601981..ca8c901b6fd2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -290,6 +290,9 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> { let ty = self.node_ty(id); Ok(self.infcx().resolve_type_vars_if_possible(ty)) } + fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult> { + let ty = self.expr_ty_adjusted(expr); + Ok(self.infcx().resolve_type_vars_if_possible(ty)) } fn node_method_ty(&self, method_call: ty::MethodCall) -> Option> {