提交 8f770f10 编写于 作者: N Niko Matsakis

Extend Typer interface to include `expr_ty_adjusted` so that we can

remove another direct dependency on tcx from euv.
上级 f3ff084d
......@@ -647,7 +647,7 @@ pub fn walk_expr(&mut self, expr: &ast::Expr) {
}
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);
......
......@@ -285,6 +285,7 @@ impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {}
pub trait Typer<'tcx> {
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>;
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>>;
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>>;
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>;
fn is_method_call(&self, id: ast::NodeId) -> bool;
......
......@@ -6169,7 +6169,11 @@ fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
Ok(ty::node_id_to_type(self, id))
}
fn node_method_ty(&self, method_call: MethodCall) -> Option<Ty<'tcx>> {
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
Ok(ty::expr_ty_adjusted(self, expr))
}
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
self.method_map.borrow().get(&method_call).map(|method| method.ty)
}
......
......@@ -467,6 +467,10 @@ fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
Ok(node_id_type(self, id))
}
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
Ok(expr_ty_adjusted(self, expr))
}
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
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))
}
......
......@@ -290,6 +290,9 @@ fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'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<Ty<'tcx>> {
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<Ty<'tcx>> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册