Move tcx
from Typer
into ClosureTyper
This commit is contained in:
parent
e84a719e37
commit
7134ad4d64
src
librustc/middle
librustc_trans/trans
librustc_typeck/check
@ -281,7 +281,6 @@ pub type McResult<T> = Result<T, ()>;
|
||||
/// know that no errors have occurred, so we simply consult the tcx and we
|
||||
/// can be sure that only `Ok` results will occur.
|
||||
pub trait Typer<'tcx> : ty::ClosureTyper<'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 type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool;
|
||||
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
use middle::infer::{InferCtxt};
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::ty::{self, RegionEscape, Ty};
|
||||
use std::collections::HashSet;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
|
@ -32,7 +32,6 @@ use super::object_safety;
|
||||
use super::{util};
|
||||
|
||||
use middle::fast_reject;
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::subst::{Subst, Substs, TypeSpace, VecPerParamSpace};
|
||||
use middle::ty::{self, RegionEscape, ToPolyTraitRef, Ty};
|
||||
use middle::infer;
|
||||
|
@ -2337,6 +2337,10 @@ impl ClosureKind {
|
||||
}
|
||||
|
||||
pub trait ClosureTyper<'tcx> {
|
||||
fn tcx(&self) -> &ty::ctxt<'tcx> {
|
||||
self.param_env().tcx
|
||||
}
|
||||
|
||||
fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx>;
|
||||
|
||||
/// Is this a `Fn`, `FnMut` or `FnOnce` closure? During typeck,
|
||||
@ -6463,10 +6467,6 @@ impl<'tcx> ctxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'a,'tcx> mc::Typer<'tcx> for ParameterEnvironment<'a,'tcx> {
|
||||
fn tcx(&self) -> &ty::ctxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
|
||||
Ok(ty::node_id_to_type(self.tcx, id))
|
||||
}
|
||||
|
@ -637,10 +637,6 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
|
||||
self.tcx()
|
||||
}
|
||||
|
||||
fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
|
||||
Ok(node_id_type(self, id))
|
||||
}
|
||||
|
@ -309,9 +309,6 @@ pub struct FnCtxt<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> mc::Typer<'tcx> for FnCtxt<'a, 'tcx> {
|
||||
fn tcx(&self) -> &ty::ctxt<'tcx> {
|
||||
self.ccx.tcx
|
||||
}
|
||||
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
|
||||
let ty = self.node_ty(id);
|
||||
self.resolve_type_vars_or_error(&ty)
|
||||
|
Loading…
x
Reference in New Issue
Block a user