Skip to content

Commit 8f770f1

Browse files
committed
Extend Typer interface to include expr_ty_adjusted so that we can
remove another direct dependency on tcx from euv.
1 parent f3ff084 commit 8f770f1

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
647647
}
648648

649649
fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
650-
let callee_ty = ty::expr_ty_adjusted(self.tcx(), callee);
650+
let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee));
651651
debug!("walk_callee: callee={} callee_ty={}",
652652
callee.repr(self.tcx()), callee_ty.repr(self.tcx()));
653653
let call_scope = region::CodeExtent::from_node_id(call.id);

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ pub type McResult<T> = Result<T, ()>;
285285
pub trait Typer<'tcx> {
286286
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
287287
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>;
288+
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>>;
288289
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>>;
289290
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>;
290291
fn is_method_call(&self, id: ast::NodeId) -> bool;

src/librustc/middle/ty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6169,7 +6169,11 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> {
61696169
Ok(ty::node_id_to_type(self, id))
61706170
}
61716171

6172-
fn node_method_ty(&self, method_call: MethodCall) -> Option<Ty<'tcx>> {
6172+
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
6173+
Ok(ty::expr_ty_adjusted(self, expr))
6174+
}
6175+
6176+
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
61736177
self.method_map.borrow().get(&method_call).map(|method| method.ty)
61746178
}
61756179

src/librustc_trans/trans/common.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
467467
Ok(node_id_type(self, id))
468468
}
469469

470+
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
471+
Ok(expr_ty_adjusted(self, expr))
472+
}
473+
470474
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
471475
self.tcx()
472476
.method_map
@@ -752,11 +756,11 @@ pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty
752756
monomorphize_type(bcx, t)
753757
}
754758

755-
pub fn expr_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
759+
pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
756760
node_id_type(bcx, ex.id)
757761
}
758762

759-
pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
763+
pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
760764
monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex))
761765
}
762766

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> {
290290
let ty = self.node_ty(id);
291291
Ok(self.infcx().resolve_type_vars_if_possible(ty))
292292
}
293+
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
294+
let ty = self.expr_ty_adjusted(expr);
295+
Ok(self.infcx().resolve_type_vars_if_possible(ty))
293296
}
294297
fn node_method_ty(&self, method_call: ty::MethodCall)
295298
-> Option<Ty<'tcx>> {

0 commit comments

Comments
 (0)