Remove Typer + ClosureTyper impls for BlockS
This commit is contained in:
parent
e2d7e904ca
commit
05c57e0e6a
9 changed files with 32 additions and 123 deletions
|
@ -110,8 +110,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn with_euv<'b, F, R>(&'b mut self, item_id: Option<ast::NodeId>, f: F) -> R where
|
||||
F: for<'t> FnOnce(&mut euv::ExprUseVisitor<'b, 't, 'tcx,
|
||||
infer::InferCtxt<'a, 'tcx>>) -> R,
|
||||
F: for<'t> FnOnce(&mut euv::ExprUseVisitor<'b, 't, 'b, 'tcx>) -> R,
|
||||
{
|
||||
let param_env = match item_id {
|
||||
Some(item_id) => ty::ParameterEnvironment::for_item(self.tcx, item_id),
|
||||
|
|
|
@ -41,8 +41,8 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
|||
{
|
||||
// FIXME (@jroesch) change this to be an inference context
|
||||
let param_env = ParameterEnvironment::for_item(self.tcx, fn_id);
|
||||
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), false);
|
||||
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: &infcx.parameter_environment };
|
||||
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env.clone()), false);
|
||||
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: ¶m_env };
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
|
||||
euv.walk_fn(fd, b);
|
||||
}
|
||||
|
|
|
@ -21,9 +21,10 @@ use self::TrackMatchMode::*;
|
|||
use self::OverloadedCallType::*;
|
||||
|
||||
use middle::{def, region, pat_util};
|
||||
use middle::infer;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::ty::{self};
|
||||
use middle::ty::{self, ClosureTyper};
|
||||
use middle::ty::{MethodCall, MethodObject, MethodTraitObject};
|
||||
use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam};
|
||||
use middle::ty::{MethodStatic, MethodStaticClosure};
|
||||
|
@ -291,9 +292,9 @@ impl OverloadedCallType {
|
|||
// supplies types from the tree. After type checking is complete, you
|
||||
// can just use the tcx as the typer.
|
||||
|
||||
pub struct ExprUseVisitor<'d,'t,'tcx:'t,TYPER:'t> {
|
||||
typer: &'t TYPER,
|
||||
mc: mc::MemCategorizationContext<'t,TYPER>,
|
||||
pub struct ExprUseVisitor<'d,'t,'a: 't, 'tcx:'a> {
|
||||
typer: &'t infer::InferCtxt<'a, 'tcx>,
|
||||
mc: mc::MemCategorizationContext<'t, 'a, 'tcx>,
|
||||
delegate: &'d mut (Delegate<'tcx>+'d),
|
||||
}
|
||||
|
||||
|
@ -319,10 +320,10 @@ enum PassArgs {
|
|||
ByRef,
|
||||
}
|
||||
|
||||
impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||
pub fn new(delegate: &'d mut Delegate<'tcx>,
|
||||
typer: &'t TYPER)
|
||||
-> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
typer: &'t infer::InferCtxt<'a, 'tcx>)
|
||||
-> ExprUseVisitor<'d,'t,'a, 'tcx> {
|
||||
ExprUseVisitor {
|
||||
typer: typer,
|
||||
mc: mc::MemCategorizationContext::new(typer),
|
||||
|
|
|
@ -30,7 +30,7 @@ use middle::region::CodeExtent;
|
|||
use middle::subst;
|
||||
use middle::subst::Substs;
|
||||
use middle::subst::Subst;
|
||||
use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation,
|
||||
use middle::traits::{self, FulfillmentContext, Normalized,
|
||||
SelectionContext, ObligationCause};
|
||||
use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, UnconstrainedNumeric};
|
||||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
|
@ -477,7 +477,7 @@ pub struct CombinedSnapshot {
|
|||
|
||||
impl<'a, 'tcx> mc::Typer<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
|
||||
let ty = self.node_ty(id);
|
||||
let ty = self.node_type(id);
|
||||
self.resolve_type_vars_or_error(&ty)
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1183,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
.map(|method| resolve_ty(method.ty)))
|
||||
}
|
||||
|
||||
pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
|
||||
pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
|
||||
match self.tables.borrow().node_types.get(&id) {
|
||||
Some(&t) => t,
|
||||
// FIXME
|
||||
|
|
|
@ -73,10 +73,11 @@ pub use self::categorization::*;
|
|||
use self::Aliasability::*;
|
||||
|
||||
use ast_map;
|
||||
use middle::infer;
|
||||
use middle::check_const;
|
||||
use middle::def;
|
||||
use middle::region;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty::{self, Ty, ClosureTyper};
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
use syntax::ast::{MutImmutable, MutMutable};
|
||||
|
@ -255,13 +256,10 @@ impl ast_node for ast::Pat {
|
|||
fn span(&self) -> Span { self.span }
|
||||
}
|
||||
|
||||
pub struct MemCategorizationContext<'t,TYPER:'t> {
|
||||
typer: &'t TYPER
|
||||
}
|
||||
|
||||
impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {}
|
||||
impl<'t,TYPER:'t> Clone for MemCategorizationContext<'t,TYPER> {
|
||||
fn clone(&self) -> MemCategorizationContext<'t,TYPER> { *self }
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct MemCategorizationContext<'t, 'a: 't, 'tcx : 'a> {
|
||||
pub typer: &'t infer::InferCtxt<'a, 'tcx>,
|
||||
// pub monomorphize: bool,
|
||||
}
|
||||
|
||||
pub type McResult<T> = Result<T, ()>;
|
||||
|
@ -391,13 +389,13 @@ impl MutabilityCategory {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
||||
pub fn new(typer: &'t TYPER) -> MemCategorizationContext<'t,TYPER> {
|
||||
impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||
pub fn new(typer: &'t infer::InferCtxt<'a, 'tcx>) -> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||
MemCategorizationContext { typer: typer }
|
||||
}
|
||||
|
||||
fn tcx(&self) -> &'t ty::ctxt<'tcx> {
|
||||
self.typer.tcx()
|
||||
fn tcx(&self) -> &'a ty::ctxt<'tcx> {
|
||||
self.typer.tcx
|
||||
}
|
||||
|
||||
fn expr_ty(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
|
||||
|
@ -1175,7 +1173,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
}
|
||||
|
||||
pub fn cat_pattern<F>(&self, cmt: cmt<'tcx>, pat: &ast::Pat, mut op: F) -> McResult<()>
|
||||
where F: FnMut(&MemCategorizationContext<'t, TYPER>, cmt<'tcx>, &ast::Pat),
|
||||
where F: FnMut(&MemCategorizationContext<'t, 'a, 'tcx>, cmt<'tcx>, &ast::Pat),
|
||||
{
|
||||
self.cat_pattern_(cmt, pat, &mut op)
|
||||
}
|
||||
|
@ -1183,7 +1181,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
// FIXME(#19596) This is a workaround, but there should be a better way to do this
|
||||
fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &ast::Pat, op: &mut F)
|
||||
-> McResult<()>
|
||||
where F : FnMut(&MemCategorizationContext<'t, TYPER>, cmt<'tcx>, &ast::Pat),
|
||||
where F : FnMut(&MemCategorizationContext<'t, 'a, 'tcx>, cmt<'tcx>, &ast::Pat),
|
||||
{
|
||||
// Here, `cmt` is the categorization for the value being
|
||||
// matched and pat is the pattern it is being matched against.
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#![feature(unicode)]
|
||||
#![feature(unicode)]
|
||||
#![feature(vec_push_all)]
|
||||
#![feature(cell_extras)]
|
||||
|
||||
#![allow(trivial_casts)]
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ use middle::check_match;
|
|||
use middle::const_eval;
|
||||
use middle::def::{self, DefMap};
|
||||
use middle::expr_use_visitor as euv;
|
||||
use middle::infer;
|
||||
use middle::lang_items::StrEqFnLangItem;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::pat_util::*;
|
||||
|
@ -1350,7 +1351,8 @@ fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool
|
|||
reassigned: false
|
||||
};
|
||||
{
|
||||
let mut visitor = euv::ExprUseVisitor::new(&mut rc, bcx);
|
||||
let infcx = infer::new_infer_ctxt(bcx.tcx(), &bcx.tcx().tables, None, false);
|
||||
let mut visitor = euv::ExprUseVisitor::new(&mut rc, &infcx);
|
||||
visitor.walk_expr(body);
|
||||
}
|
||||
rc.reassigned
|
||||
|
|
|
@ -22,7 +22,6 @@ use middle::cfg;
|
|||
use middle::def;
|
||||
use middle::infer;
|
||||
use middle::lang_items::LangItem;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::ty::ClosureTyper;
|
||||
use middle::region;
|
||||
|
@ -48,7 +47,7 @@ use util::nodemap::{FnvHashMap, NodeMap};
|
|||
use arena::TypedArena;
|
||||
use libc::{c_uint, c_char};
|
||||
use std::ffi::CString;
|
||||
use std::cell::{Cell, RefCell, Ref};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::result::Result as StdResult;
|
||||
use std::vec::Vec;
|
||||
use syntax::ast;
|
||||
|
@ -577,95 +576,6 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
|
||||
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()
|
||||
.tables
|
||||
.borrow()
|
||||
.method_map
|
||||
.get(&method_call)
|
||||
.map(|method| monomorphize_type(self, method.ty))
|
||||
}
|
||||
|
||||
fn node_method_origin(&self, method_call: ty::MethodCall)
|
||||
-> Option<ty::MethodOrigin<'tcx>>
|
||||
{
|
||||
self.tcx()
|
||||
.tables
|
||||
.borrow()
|
||||
.method_map
|
||||
.get(&method_call)
|
||||
.map(|method| method.origin.clone())
|
||||
}
|
||||
|
||||
fn adjustments<'a>(&'a self) -> Ref<NodeMap<ty::AutoAdjustment<'tcx>>> {
|
||||
// FIXME (@jroesch): this is becuase we currently have a HR inference problem
|
||||
// in the snapshot that causes this code not to work.
|
||||
fn project_adjustments<'a, 'tcx>(tables: &'a ty::Tables<'tcx>) ->
|
||||
&'a NodeMap<ty::AutoAdjustment<'tcx>> {
|
||||
&tables.adjustments
|
||||
}
|
||||
|
||||
Ref::map(self.tcx().tables.borrow(), project_adjustments)
|
||||
}
|
||||
|
||||
fn is_method_call(&self, id: ast::NodeId) -> bool {
|
||||
self.tcx().tables.borrow().method_map.contains_key(&ty::MethodCall::expr(id))
|
||||
}
|
||||
|
||||
fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<region::CodeExtent> {
|
||||
self.tcx().region_maps.temporary_scope(rvalue_id)
|
||||
}
|
||||
|
||||
fn upvar_capture(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarCapture> {
|
||||
Some(self.tcx().tables.borrow().upvar_capture_map.get(&upvar_id).unwrap().clone())
|
||||
}
|
||||
|
||||
fn type_moves_by_default(&self, ty: Ty<'tcx>, span: Span) -> bool {
|
||||
ty.moves_by_default(&self.fcx.param_env, span)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'blk, 'tcx> ty::ClosureTyper<'tcx> for BlockS<'blk, 'tcx> {
|
||||
fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx> {
|
||||
&self.fcx.param_env
|
||||
}
|
||||
|
||||
fn closure_kind(&self,
|
||||
def_id: ast::DefId)
|
||||
-> Option<ty::ClosureKind>
|
||||
{
|
||||
let infcx = infer::normalizing_infer_ctxt(self.tcx(), &self.tcx().tables);
|
||||
infcx.closure_kind(def_id)
|
||||
}
|
||||
|
||||
fn closure_type(&self,
|
||||
def_id: ast::DefId,
|
||||
substs: &subst::Substs<'tcx>)
|
||||
-> ty::ClosureTy<'tcx>
|
||||
{
|
||||
let infcx = infer::normalizing_infer_ctxt(self.tcx(), &self.tcx().tables);
|
||||
infcx.closure_type(def_id, substs)
|
||||
}
|
||||
|
||||
fn closure_upvars(&self,
|
||||
def_id: ast::DefId,
|
||||
substs: &Substs<'tcx>)
|
||||
-> Option<Vec<ty::ClosureUpvar<'tcx>>>
|
||||
{
|
||||
let infcx = infer::new_infer_ctxt(self.tcx(), &self.tcx().tables, None, true);
|
||||
infcx.closure_upvars(def_id, substs)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Result<'blk, 'tcx: 'blk> {
|
||||
pub bcx: Block<'blk, 'tcx>,
|
||||
pub val: ValueRef
|
||||
|
|
|
@ -1101,8 +1101,8 @@ fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[ast::Arg]) {
|
|||
|
||||
/// Link lifetimes of any ref bindings in `root_pat` to the pointers found in the discriminant, if
|
||||
/// needed.
|
||||
fn link_pattern<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
|
||||
mc: mc::MemCategorizationContext<InferCtxt<'a, 'tcx>>,
|
||||
fn link_pattern<'t, 'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
|
||||
mc: mc::MemCategorizationContext<'t, 'a, 'tcx>,
|
||||
discr_cmt: mc::cmt<'tcx>,
|
||||
root_pat: &ast::Pat) {
|
||||
debug!("link_pattern(discr_cmt={:?}, root_pat={:?})",
|
||||
|
|
Loading…
Add table
Reference in a new issue