rustc: Split local type contexts interners from the global one.

This commit is contained in:
Eduard Burtescu 2016-05-11 04:14:41 +03:00
parent 31a07b0ce6
commit a1c170fc35
65 changed files with 1144 additions and 702 deletions

View file

@ -22,7 +22,6 @@ 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::InferCtxt;
use rustc::middle::mem_categorization::{cmt};
use rustc::hir::pat_util::*;
use rustc::traits::ProjectionMode;
@ -1123,8 +1122,8 @@ 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
InferCtxt::enter(cx.tcx, None, Some(cx.param_env.clone()),
ProjectionMode::AnyFinal, |infcx| {
cx.tcx.infer_ctxt(None, Some(cx.param_env.clone()),
ProjectionMode::AnyFinal).enter(|infcx| {
if infcx.type_moves_by_default(pat_ty, pat.span) {
check_move(p, sub.as_ref().map(|p| &**p));
}
@ -1150,8 +1149,8 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
/// assign.
fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
guard: &hir::Expr) {
InferCtxt::enter(cx.tcx, None, Some(cx.param_env.clone()),
ProjectionMode::AnyFinal, |infcx| {
cx.tcx.infer_ctxt(None, Some(cx.param_env.clone()),
ProjectionMode::AnyFinal).enter(|infcx| {
let mut checker = MutationChecker {
cx: cx,
};
@ -1160,11 +1159,11 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
});
}
struct MutationChecker<'a, 'tcx: 'a> {
cx: &'a MatchCheckCtxt<'a, 'tcx>,
struct MutationChecker<'a, 'gcx: 'a> {
cx: &'a MatchCheckCtxt<'a, 'gcx>,
}
impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> {
fn matched_pat(&mut self, _: &Pat, _: cmt, _: euv::MatchMode) {}
fn consume(&mut self, _: NodeId, _: Span, _: cmt, _: ConsumeMode) {}
fn consume_pat(&mut self, _: &Pat, _: cmt, _: ConsumeMode) {}

View file

@ -19,7 +19,6 @@ use rustc::hir::map as ast_map;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::middle::cstore::{self, InlinedItem};
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;
@ -1014,7 +1013,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
trait_ref);
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
InferCtxt::enter(tcx, None, None, ProjectionMode::AnyFinal, |infcx| {
tcx.infer_ctxt(None, None, ProjectionMode::AnyFinal).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
trait_ref.to_poly_trait_predicate());