infer: Use methods for creating an InferCtxt.

This commit is contained in:
Eduard Burtescu 2016-03-11 02:31:38 +02:00
parent b5122d5c4c
commit 0907c198c4
30 changed files with 126 additions and 154 deletions

View File

@ -382,34 +382,36 @@ pub fn fixup_err_to_string(f: FixupError) -> String {
}
}
pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
projection_mode: ProjectionMode)
-> InferCtxt<'a, 'tcx> {
InferCtxt {
tcx: tcx,
tables: tables,
type_variables: RefCell::new(type_variable::TypeVariableTable::new()),
int_unification_table: RefCell::new(UnificationTable::new()),
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(tcx),
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
reported_trait_errors: RefCell::new(FnvHashSet()),
normalize: false,
projection_mode: projection_mode,
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn new(tcx: &'a TyCtxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
projection_mode: ProjectionMode)
-> Self {
InferCtxt {
tcx: tcx,
tables: tables,
type_variables: RefCell::new(type_variable::TypeVariableTable::new()),
int_unification_table: RefCell::new(UnificationTable::new()),
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(tcx),
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
reported_trait_errors: RefCell::new(FnvHashSet()),
normalize: false,
projection_mode: projection_mode,
tainted_by_errors_flag: Cell::new(false),
err_count_on_creation: tcx.sess.err_count()
err_count_on_creation: tcx.sess.err_count()
}
}
}
pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
projection_mode: ProjectionMode)
-> InferCtxt<'a, 'tcx> {
let mut infcx = new_infer_ctxt(tcx, tables, None, projection_mode);
infcx.normalize = true;
infcx
pub fn normalizing(tcx: &'a TyCtxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
projection_mode: ProjectionMode)
-> Self {
let mut infcx = InferCtxt::new(tcx, tables, None, projection_mode);
infcx.normalize = true;
infcx
}
}
pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
@ -532,7 +534,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &TyCtxt<'tcx>, value: &T) -> T
return value;
}
let infcx = new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Any);
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::Any);
let mut selcx = traits::SelectionContext::new(&infcx);
let cause = traits::ObligationCause::dummy();
let traits::Normalized { value: result, obligations } =

View File

@ -11,7 +11,7 @@
use dep_graph::DepNode;
use hir::def::Def;
use hir::def_id::DefId;
use infer::{InferCtxt, new_infer_ctxt};
use infer::InferCtxt;
use traits::ProjectionMode;
use ty::{self, Ty, TyCtxt};
use ty::layout::{LayoutError, Pointer, SizeSkeleton};
@ -36,7 +36,7 @@ struct ItemVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> ItemVisitor<'a, 'tcx> {
fn visit_const(&mut self, item_id: ast::NodeId, expr: &hir::Expr) {
let param_env = ty::ParameterEnvironment::for_item(self.tcx, item_id);
let infcx = new_infer_ctxt(self.tcx, &self.tcx.tables,
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables,
Some(param_env),
ProjectionMode::Any);
let mut visitor = ExprVisitor {
@ -115,7 +115,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
impl<'a, 'tcx, 'v> Visitor<'v> for ItemVisitor<'a, 'tcx> {
// const, static and N in [T; N].
fn visit_expr(&mut self, expr: &hir::Expr) {
let infcx = new_infer_ctxt(self.tcx, &self.tcx.tables,
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables,
None, ProjectionMode::Any);
let mut visitor = ExprVisitor {
infcx: &infcx
@ -144,7 +144,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ItemVisitor<'a, 'tcx> {
match fk {
FnKind::ItemFn(..) | FnKind::Method(..) => {
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
let infcx = new_infer_ctxt(self.tcx, &self.tcx.tables,
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables,
Some(param_env),
ProjectionMode::Any);
let mut visitor = ExprVisitor {

View File

@ -114,7 +114,7 @@ use hir::def::*;
use hir::pat_util;
use ty::{self, TyCtxt, ParameterEnvironment};
use traits::{self, ProjectionMode};
use infer;
use infer::InferCtxt;
use ty::subst::Subst;
use lint;
use util::nodemap::NodeMap;
@ -1488,10 +1488,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let param_env = ParameterEnvironment::for_item(&self.ir.tcx, id);
let t_ret_subst = t_ret.subst(&self.ir.tcx, &param_env.free_substs);
let infcx = infer::new_infer_ctxt(&self.ir.tcx,
&self.ir.tcx.tables,
Some(param_env),
ProjectionMode::Any);
let infcx = InferCtxt::new(&self.ir.tcx,
&self.ir.tcx.tables,
Some(param_env),
ProjectionMode::Any);
let cause = traits::ObligationCause::dummy();
let norm = traits::fully_normalize(&infcx,
cause,

View File

@ -19,7 +19,7 @@ use hir::def_id::DefId;
use middle::free_region::FreeRegionMap;
use ty::subst;
use ty::{self, Ty, TypeFoldable};
use infer::{self, fixup_err_to_string, InferCtxt};
use infer::{fixup_err_to_string, InferCtxt};
use std::rc::Rc;
use syntax::ast;
@ -437,10 +437,8 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(elaborated_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(elaborated_env),
ProjectionMode::AnyFinal);
let predicates = match fully_normalize(&infcx,
cause,
&infcx.parameter_environment.caller_bounds) {

View File

@ -133,7 +133,7 @@ pub fn specializes(tcx: &TyCtxt, impl1_def_id: DefId, impl2_def_id: DefId) -> bo
return false;
}
let mut infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables, ProjectionMode::Topmost);
let mut infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Topmost);
// create a parameter environment corresponding to a (skolemized) instantiation of impl1
let scheme = tcx.lookup_item_type(impl1_def_id);

View File

@ -14,7 +14,7 @@ use std::rc::Rc;
use super::{Overlap, specializes};
use hir::def_id::DefId;
use infer;
use infer::InferCtxt;
use traits::{self, ProjectionMode};
use ty::{self, TyCtxt, ImplOrTraitItem, TraitDef, TypeFoldable};
use ty::fast_reject::{self, SimplifiedType};
@ -113,7 +113,7 @@ impl Children {
} {
let possible_sibling = *slot;
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Topmost);
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::Topmost);
let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id);
if let Some(impl_header) = overlap {

View File

@ -13,7 +13,7 @@
use hir::svh::Svh;
use hir::def_id::DefId;
use ty::subst;
use infer;
use infer::InferCtxt;
use hir::pat_util;
use traits::{self, ProjectionMode};
use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
@ -129,10 +129,8 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
let tcx = self.tcx;
// FIXME: (@jroesch) float this code up
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(self.clone()),
ProjectionMode::Topmost);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(self.clone()),
ProjectionMode::Topmost);
let adt = match self_type.sty {
ty::TyStruct(struct_def, substs) => {
@ -511,10 +509,8 @@ impl<'tcx> ty::TyS<'tcx> {
-> bool
{
let tcx = param_env.tcx;
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(param_env.clone()),
ProjectionMode::Topmost);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(param_env.clone()),
ProjectionMode::Topmost);
let is_impld = traits::type_known_to_meet_builtin_bound(&infcx,
self, bound, span);
@ -600,7 +596,7 @@ impl<'tcx> ty::TyS<'tcx> {
}
#[inline]
pub fn layout<'a>(&'tcx self, infcx: &infer::InferCtxt<'a, 'tcx>)
pub fn layout<'a>(&'tcx self, infcx: &InferCtxt<'a, 'tcx>)
-> Result<&'tcx Layout, LayoutError<'tcx>> {
let can_cache = !self.has_param_types() && !self.has_self_ty();
if can_cache {

View File

@ -22,7 +22,7 @@ use borrowck::*;
use borrowck::InteriorKind::{InteriorElement, InteriorField};
use rustc::middle::expr_use_visitor as euv;
use rustc::middle::expr_use_visitor::MutateMode;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::middle::region;
@ -203,10 +203,8 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
debug!("check_loans(body id={})", body.id);
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
let infcx = infer::new_infer_ctxt(bccx.tcx,
&bccx.tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(bccx.tcx, &bccx.tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
let mut clcx = CheckLoanCtxt {
bccx: bccx,

View File

@ -19,7 +19,7 @@
use borrowck::*;
use borrowck::move_data::MoveData;
use rustc::middle::expr_use_visitor as euv;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::middle::region;
@ -56,10 +56,8 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
};
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
let infcx = infer::new_infer_ctxt(bccx.tcx,
&bccx.tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(bccx.tcx, &bccx.tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
{
let mut euv = euv::ExprUseVisitor::new(&mut glcx, &infcx);
euv.walk_fn(decl, body);
@ -529,10 +527,8 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
fn visit_expr(&mut self, ex: &Expr) {
if let hir::ExprAddrOf(mutbl, ref base) = ex.node {
let infcx = infer::new_infer_ctxt(self.bccx.tcx,
&self.bccx.tcx.tables,
None,
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(self.bccx.tcx, &self.bccx.tcx.tables, None,
ProjectionMode::AnyFinal);
let mc = mc::MemCategorizationContext::new(&infcx);
let base_cmt = mc.cat_expr(&base).unwrap();
let borrow_kind = ty::BorrowKind::from_mutbl(mutbl);

View File

@ -22,7 +22,7 @@ use rustc::hir::def_id::{DefId};
use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor};
use rustc::middle::expr_use_visitor::{LoanCause, MutateMode};
use rustc::middle::expr_use_visitor as euv;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::middle::mem_categorization::{cmt};
use rustc::hir::pat_util::*;
use rustc::traits::ProjectionMode;
@ -1123,10 +1123,9 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
PatKind::Ident(hir::BindByValue(_), _, ref sub) => {
let pat_ty = tcx.node_id_to_type(p.id);
//FIXME: (@jroesch) this code should be floated up as well
let infcx = infer::new_infer_ctxt(cx.tcx,
&cx.tcx.tables,
Some(cx.param_env.clone()),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(cx.tcx, &cx.tcx.tables,
Some(cx.param_env.clone()),
ProjectionMode::AnyFinal);
if infcx.type_moves_by_default(pat_ty, pat.span) {
check_move(p, sub.as_ref().map(|p| &**p));
}
@ -1155,10 +1154,9 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
cx: cx,
};
let infcx = infer::new_infer_ctxt(cx.tcx,
&cx.tcx.tables,
Some(checker.cx.param_env.clone()),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(cx.tcx, &cx.tcx.tables,
Some(checker.cx.param_env.clone()),
ProjectionMode::AnyFinal);
let mut visitor = ExprUseVisitor::new(&mut checker, &infcx);
visitor.walk_expr(guard);

View File

@ -18,7 +18,8 @@ use self::EvalHint::*;
use rustc::hir::map as ast_map;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::middle::cstore::{self, InlinedItem};
use rustc::{infer, traits};
use rustc::traits;
use rustc::infer::InferCtxt;
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::hir::pat_util::def_to_path;
@ -1010,7 +1011,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
trait_ref);
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let mut selcx = traits::SelectionContext::new(&infcx);
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),

View File

@ -149,10 +149,8 @@ fn test_env<F>(source_string: &str,
index,
"test_crate",
|tcx| {
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
None,
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, None,
ProjectionMode::AnyFinal);
body(Env { infcx: &infcx });
let free_regions = FreeRegionMap::new();
infcx.resolve_regions_and_report_errors(&free_regions,

View File

@ -31,7 +31,8 @@
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use middle::stability;
use rustc::{cfg, infer};
use rustc::cfg;
use rustc::infer::InferCtxt;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::adjustment;
@ -869,10 +870,8 @@ impl LateLintPass for UnconditionalRecursion {
let node_id = tcx.map.as_local_node_id(method.def_id).unwrap();
let param_env = ty::ParameterEnvironment::for_item(tcx, node_id);
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
let mut selcx = traits::SelectionContext::new(&infcx);
match selcx.select(&obligation) {
// The method comes from a `T: Trait` bound.

View File

@ -24,7 +24,7 @@ use pretty;
use hair::cx::Cx;
use rustc::mir::mir_map::MirMap;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::traits::ProjectionMode;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::util::nodemap::NodeMap;
@ -75,10 +75,9 @@ impl<'a, 'tcx> BuildMir<'a, 'tcx> {
};
let param_env = ty::ParameterEnvironment::for_item(self.tcx, src.item_id());
let infcx = infer::new_infer_ctxt(self.tcx,
&self.tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
let (mir, scope_auxiliary) = f(Cx::new(&infcx, constness));

View File

@ -19,7 +19,7 @@ use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::hir::intravisit::FnKind;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::traits::{self, ProjectionMode};
use rustc::ty::{self, TyCtxt, Ty};
use rustc::ty::cast::CastTy;
@ -1017,10 +1017,8 @@ impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
// Statics must be Sync.
if mode == Mode::Static {
let ty = mir.return_ty.unwrap();
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
None,
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, None,
ProjectionMode::AnyFinal);
let cause = traits::ObligationCause::new(mir.span, id, traits::SharedStatic);
let mut fulfillment_cx = traits::FulfillmentContext::new();
fulfillment_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);

View File

@ -585,10 +585,8 @@ impl<'tcx> MirPass<'tcx> for TypeckMir {
return;
}
let param_env = ty::ParameterEnvironment::for_item(tcx, src.item_id());
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
let mut checker = TypeChecker::new(&infcx);
{
let mut verifier = TypeVerifier::new(&mut checker, mir);

View File

@ -36,7 +36,7 @@ use rustc_const_math::{ConstMathErr, Op};
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::middle::expr_use_visitor as euv;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::ty::{self, Ty, TyCtxt};
@ -95,10 +95,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
None => self.tcx.empty_parameter_environment()
};
let infcx = infer::new_infer_ctxt(self.tcx,
&self.tcx.tables,
Some(param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables, Some(param_env),
ProjectionMode::AnyFinal);
f(&mut euv::ExprUseVisitor::new(self, &infcx))
}

View File

@ -13,7 +13,7 @@
use rustc::dep_graph::DepNode;
use rustc::middle::expr_use_visitor as euv;
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::middle::mem_categorization as mc;
use rustc::ty::{self, TyCtxt, ParameterEnvironment};
use rustc::traits::ProjectionMode;
@ -42,10 +42,9 @@ impl<'a, 'tcx, 'v> intravisit::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.clone()),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables,
Some(param_env.clone()),
ProjectionMode::AnyFinal);
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: &param_env };
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
euv.walk_fn(fd, b);

View File

@ -194,7 +194,7 @@ use rustc_const_eval::{compare_lit_exprs, eval_const_expr};
use rustc::hir::def::{Def, DefMap};
use rustc::hir::def_id::DefId;
use middle::expr_use_visitor as euv;
use rustc::infer;
use rustc::infer::InferCtxt;
use middle::lang_items::StrEqFnLangItem;
use middle::mem_categorization as mc;
use middle::mem_categorization::Categorization;
@ -1467,9 +1467,8 @@ fn is_discr_reassigned(bcx: Block, discr: &hir::Expr, body: &hir::Expr) -> bool
reassigned: false
};
{
let infcx = infer::normalizing_infer_ctxt(bcx.tcx(),
&bcx.tcx().tables,
ProjectionMode::Any);
let infcx = InferCtxt::normalizing(bcx.tcx(), &bcx.tcx().tables,
ProjectionMode::Any);
let mut visitor = euv::ExprUseVisitor::new(&mut rc, &infcx);
visitor.walk_expr(body);
}

View File

@ -12,7 +12,7 @@ use arena::TypedArena;
use back::symbol_names;
use llvm::{ValueRef, get_param, get_params};
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::infer::{self, InferCtxt};
use rustc::traits::ProjectionMode;
use abi::{Abi, FnType};
use adt;
@ -155,7 +155,7 @@ fn get_or_create_closure_declaration<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let symbol = symbol_names::exported_name(ccx, &instance);
// Compute the rust-call form of the closure call method.
let infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any);
let sig = &infcx.closure_type(closure_id, &substs).sig;
let sig = tcx.erase_late_bound_regions(sig);
let sig = infer::normalize_associated_type(tcx, &sig);
@ -220,7 +220,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
// this function (`trans_closure`) is invoked at the point
// of the closure expression.
let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(ccx.tcx(), &ccx.tcx().tables, ProjectionMode::Any);
let function_type = infcx.closure_type(closure_def_id, closure_substs);
let sig = tcx.erase_late_bound_regions(&function_type.sig);
@ -344,7 +344,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
closure_def_id, substs, Value(llreffn));
let tcx = ccx.tcx();
let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(ccx.tcx(), &ccx.tcx().tables, ProjectionMode::Any);
// Find a version of the closure type. Substitute static for the
// region since it doesn't really matter.

View File

@ -19,7 +19,7 @@ use llvm::{True, False, Bool, OperandBundleDef};
use rustc::cfg;
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::infer::{self, InferCtxt};
use rustc::util::common::MemoizationMap;
use middle::lang_items::LangItem;
use rustc::ty::subst::Substs;
@ -1066,9 +1066,7 @@ pub fn fulfill_obligation<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
// Do the initial selection for the obligation. This yields the
// shallow result we are looking for -- that is, what specific impl.
let infcx = infer::normalizing_infer_ctxt(tcx,
&tcx.tables,
ProjectionMode::Any);
let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any);
let mut selcx = SelectionContext::new(&infcx);
let obligation_cause = traits::ObligationCause::misc(span,
@ -1130,7 +1128,7 @@ pub fn normalize_and_test_predicates<'tcx>(tcx: &TyCtxt<'tcx>,
debug!("normalize_and_test_predicates(predicates={:?})",
predicates);
let infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any);
let mut selcx = SelectionContext::new(&infcx);
let mut fulfill_cx = traits::FulfillmentContext::new();
let cause = traits::ObligationCause::dummy();

View File

@ -18,8 +18,9 @@ use back::symbol_names;
use llvm;
use llvm::{ValueRef, get_param};
use middle::lang_items::ExchangeFreeFnLangItem;
use rustc::infer::InferCtxt;
use rustc::ty::subst::{Substs};
use rustc::{infer, traits};
use rustc::traits;
use rustc::ty::{self, Ty, TyCtxt};
use abi::{Abi, FnType};
use adt;
@ -115,9 +116,9 @@ pub fn get_drop_glue_type<'tcx>(tcx: &TyCtxt<'tcx>,
match t.sty {
ty::TyBox(typ) if !type_needs_drop(&tcx, typ)
&& type_is_sized(tcx, typ) => {
let infcx = infer::normalizing_infer_ctxt(tcx,
&tcx.tables,
traits::ProjectionMode::Any);
let infcx = InferCtxt::normalizing(tcx,
&tcx.tables,
traits::ProjectionMode::Any);
let layout = t.layout(&infcx).unwrap();
if layout.size(&tcx.data_layout).bytes() == 0 {
// `Box<ZeroSizeType>` does not allocate.

View File

@ -14,7 +14,7 @@ use arena::TypedArena;
use back::symbol_names;
use llvm::{ValueRef, get_params};
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::infer::{self, InferCtxt};
use rustc::ty::subst::{FnSpace, Subst, Substs};
use rustc::ty::subst;
use rustc::traits::{self, ProjectionMode};
@ -314,7 +314,7 @@ pub fn get_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
let trait_def = tcx.lookup_trait_def(trait_def_id);
let infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(tcx, &tcx.tables, ProjectionMode::Any);
match trait_def.ancestors(impl_def_id).fn_defs(tcx, name).next() {
Some(node_item) => {

View File

@ -11,7 +11,7 @@
#![allow(non_camel_case_types)]
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::infer::{self, InferCtxt};
use rustc::ty::subst;
use abi::FnType;
use adt;
@ -124,7 +124,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
// FIXME(eddyb) Temporary sanity check for ty::layout.
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables, ProjectionMode::Any);
let infcx = InferCtxt::normalizing(cx.tcx(), &cx.tcx().tables, ProjectionMode::Any);
match t.layout(&infcx) {
Ok(layout) => {
if !type_is_sized(cx.tcx(), t) {

View File

@ -9,7 +9,7 @@
// except according to those terms.
use middle::free_region::FreeRegionMap;
use rustc::infer::{self, InferOk, TypeOrigin};
use rustc::infer::{self, InferCtxt, InferOk, TypeOrigin};
use rustc::ty::{self, TyCtxt};
use rustc::traits::{self, ProjectionMode};
use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace};
@ -42,7 +42,7 @@ pub fn compare_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
debug!("compare_impl_method: impl_trait_ref (liberated) = {:?}",
impl_trait_ref);
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let mut infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let mut fulfillment_cx = traits::FulfillmentContext::new();
let trait_to_impl_substs = &impl_trait_ref.substs;
@ -416,7 +416,7 @@ pub fn compare_const_impl<'tcx>(tcx: &TyCtxt<'tcx>,
debug!("compare_const_impl(impl_trait_ref={:?})",
impl_trait_ref);
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let mut fulfillment_cx = traits::FulfillmentContext::new();
// The below is for the most part highly similar to the procedure

View File

@ -12,7 +12,7 @@ use check::regionck::{self, Rcx};
use hir::def_id::DefId;
use middle::free_region::FreeRegionMap;
use rustc::infer;
use rustc::infer::{self, InferCtxt};
use middle::region;
use rustc::ty::subst::{self, Subst};
use rustc::ty::{self, Ty, TyCtxt};
@ -82,10 +82,8 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
// check that the impl type can be made to match the trait type.
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, self_type_node_id);
let infcx = infer::new_infer_ctxt(tcx,
&tcx.tables,
Some(impl_param_env),
ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(impl_param_env),
ProjectionMode::AnyFinal);
let mut fulfillment_cx = traits::FulfillmentContext::new();
let named_type = tcx.lookup_item_type(self_type_did).ty;

View File

@ -88,7 +88,7 @@ use middle::astconv_util::prohibit_type_params;
use middle::cstore::LOCAL_CRATE;
use hir::def::{self, Def};
use hir::def_id::DefId;
use rustc::infer::{self, InferOk, TypeOrigin, TypeTrace, type_variable};
use rustc::infer::{self, InferCtxt, InferOk, TypeOrigin, TypeTrace, type_variable};
use hir::pat_util::{self, pat_id_map};
use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace};
use rustc::traits::{self, report_fulfillment_errors, ProjectionMode};
@ -156,7 +156,7 @@ mod op;
/// `bar()` will each have their own `FnCtxt`, but they will
/// share the inherited fields.
pub struct Inherited<'a, 'tcx: 'a> {
infcx: infer::InferCtxt<'a, 'tcx>,
infcx: InferCtxt<'a, 'tcx>,
locals: RefCell<NodeMap<Ty<'tcx>>>,
fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
@ -305,7 +305,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
-> Inherited<'a, 'tcx> {
Inherited {
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env), ProjectionMode::AnyFinal),
infcx: InferCtxt::new(tcx, tables, Some(param_env), ProjectionMode::AnyFinal),
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
locals: RefCell::new(NodeMap()),
tables: tables,
@ -1190,7 +1190,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn tcx(&self) -> &TyCtxt<'tcx> { self.ccx.tcx }
pub fn infcx(&self) -> &infer::InferCtxt<'a,'tcx> {
pub fn infcx(&self) -> &InferCtxt<'a,'tcx> {
&self.inh.infcx
}

View File

@ -31,7 +31,7 @@ use rustc::ty::TyProjection;
use rustc::ty::util::CopyImplementationError;
use middle::free_region::FreeRegionMap;
use CrateCtxt;
use rustc::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt};
use rustc::infer::{self, InferCtxt, TypeOrigin};
use std::cell::RefCell;
use std::rc::Rc;
use syntax::codemap::Span;
@ -379,7 +379,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (free)",
source, target);
let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env), ProjectionMode::Topmost);
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(param_env), ProjectionMode::Topmost);
let origin = TypeOrigin::Misc(span);
let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>,
@ -516,7 +516,7 @@ fn enforce_trait_manually_implementable(tcx: &TyCtxt, sp: Span, trait_def_id: De
pub fn check_coherence(crate_context: &CrateCtxt) {
let _task = crate_context.tcx.dep_graph.in_task(DepNode::Coherence);
let infcx = new_infer_ctxt(crate_context.tcx,
let infcx = InferCtxt::new(crate_context.tcx,
&crate_context.tcx.tables,
None,
ProjectionMode::Topmost);

View File

@ -14,7 +14,7 @@
use hir::def_id::DefId;
use rustc::traits::{self, ProjectionMode};
use rustc::infer;
use rustc::infer::InferCtxt;
use rustc::ty::{self, TyCtxt};
use syntax::ast;
use rustc::dep_graph::DepNode;
@ -84,10 +84,8 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
for (i, &impl1_def_id) in impls.iter().enumerate() {
for &impl2_def_id in &impls[(i+1)..] {
let infcx = infer::new_infer_ctxt(self.tcx,
&self.tcx.tables,
None,
ProjectionMode::Topmost);
let infcx = InferCtxt::new(self.tcx, &self.tcx.tables, None,
ProjectionMode::Topmost);
if traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id).is_some() {
self.check_for_common_items_in_impls(impl1_def_id, impl2_def_id)
}

View File

@ -104,7 +104,7 @@ pub use rustc::util;
use dep_graph::DepNode;
use hir::map as hir_map;
use hir::def::Def;
use rustc::infer::{self, TypeOrigin};
use rustc::infer::{self, InferCtxt, TypeOrigin};
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::traits::ProjectionMode;
@ -197,7 +197,7 @@ fn require_same_types<'a, 'tcx>(tcx: &TyCtxt<'tcx>,
{
let result = match maybe_infcx {
None => {
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
let infcx = InferCtxt::new(tcx, &tcx.tables, None, ProjectionMode::AnyFinal);
infer::mk_eqty(&infcx, t1_is_expected, TypeOrigin::Misc(span), t1, t2)
}
Some(infcx) => {