about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-08-08 12:25:22 +0200
committerMichael Woerister <michaelwoerister@posteo>2017-08-11 12:11:38 +0200
commitfbc7398badef55d58476b5410e7e911bb872f537 (patch)
tree4401b521d32fb9b315fd996b20807f49652120ac
parent801dd07a950b047150aa291e461ba53a7d29489e (diff)
downloadrust-fbc7398badef55d58476b5410e7e911bb872f537.tar.gz
rust-fbc7398badef55d58476b5410e7e911bb872f537.zip
Use ItemLocalId as key for TypeckTables::cast_kinds.
-rw-r--r--src/librustc/ich/impls_ty.rs2
-rw-r--r--src/librustc/ty/context.rs5
-rw-r--r--src/librustc_mir/hair/cx/expr.rs5
-rw-r--r--src/librustc_passes/consts.rs3
-rw-r--r--src/librustc_typeck/check/cast.rs8
5 files changed, 16 insertions, 7 deletions
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs
index 84058119b45..7b98eb0fb71 100644
--- a/src/librustc/ich/impls_ty.rs
+++ b/src/librustc/ich/impls_ty.rs
@@ -658,7 +658,7 @@ for ty::TypeckTables<'gcx> {
             ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
             ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
             ich::hash_stable_itemlocalmap(hcx, hasher, fru_field_types);
-            ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
+            ich::hash_stable_itemlocalmap(hcx, hasher, cast_kinds);
 
             ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {
                 hcx.def_path_hash(*def_id)
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index f09488ebcfa..bf412b57007 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -257,7 +257,7 @@ pub struct TypeckTables<'tcx> {
 
     /// Maps a cast expression to its kind. This is keyed on the
     /// *from* expression of the cast, not the cast itself.
-    pub cast_kinds: NodeMap<ty::cast::CastKind>,
+    pub cast_kinds: ItemLocalMap<ty::cast::CastKind>,
 
     /// Set of trait imports actually used in the method resolution.
     /// This is used for warning unused imports.
@@ -287,7 +287,8 @@ impl<'tcx> TypeckTables<'tcx> {
             closure_kinds: ItemLocalMap(),
             liberated_fn_sigs: ItemLocalMap(),
             fru_field_types: ItemLocalMap(),
-            cast_kinds: NodeMap(),
+            cast_kinds: ItemLocalMap(),
+            lints: lint::LintTable::new(),
             used_trait_imports: DefIdSet(),
             tainted_by_errors: false,
             free_region_map: FreeRegionMap::new(),
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs
index 30f7378e83b..05709fed0af 100644
--- a/src/librustc_mir/hair/cx/expr.rs
+++ b/src/librustc_mir/hair/cx/expr.rs
@@ -551,7 +551,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         hir::ExprCast(ref source, _) => {
             // Check to see if this cast is a "coercion cast", where the cast is actually done
             // using a coercion (or is a no-op).
-            if let Some(&TyCastKind::CoercionCast) = cx.tables().cast_kinds.get(&source.id) {
+            cx.tables().validate_hir_id(source.hir_id);
+            if let Some(&TyCastKind::CoercionCast) = cx.tables()
+                                                       .cast_kinds
+                                                       .get(&source.hir_id.local_id) {
                 // Convert the lexpr to a vexpr.
                 ExprKind::Use { source: source.to_ref() }
             } else {
diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs
index c06ae721f36..4a2925175c2 100644
--- a/src/librustc_passes/consts.rs
+++ b/src/librustc_passes/consts.rs
@@ -320,7 +320,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
         }
         hir::ExprCast(ref from, _) => {
             debug!("Checking const cast(id={})", from.id);
-            match v.tables.cast_kinds.get(&from.id) {
+            v.tables.validate_hir_id(from.hir_id);
+            match v.tables.cast_kinds.get(&from.hir_id.local_id) {
                 None => span_bug!(e.span, "no kind for cast"),
                 Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
                     v.promotable = false;
diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs
index 5f256eab9a9..2be427eee1b 100644
--- a/src/librustc_typeck/check/cast.rs
+++ b/src/librustc_typeck/check/cast.rs
@@ -330,12 +330,16 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
         } else if self.try_coercion_cast(fcx) {
             self.trivial_cast_lint(fcx);
             debug!(" -> CoercionCast");
-            fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, CastKind::CoercionCast);
+            let mut tables = fcx.tables.borrow_mut();
+            tables.validate_hir_id(self.expr.hir_id);
+            tables.cast_kinds.insert(self.expr.hir_id.local_id, CastKind::CoercionCast);
         } else {
             match self.do_check(fcx) {
                 Ok(k) => {
                     debug!(" -> {:?}", k);
-                    fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, k);
+                    let mut tables = fcx.tables.borrow_mut();
+                    tables.validate_hir_id(self.expr.hir_id);
+                    tables.cast_kinds.insert(self.expr.hir_id.local_id, k);
                 }
                 Err(e) => self.report_cast_error(fcx, e),
             };