Skip to content

Commit fbc7398

Browse files
Use ItemLocalId as key for TypeckTables::cast_kinds.
1 parent 801dd07 commit fbc7398

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ for ty::TypeckTables<'gcx> {
658658
ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
659659
ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
660660
ich::hash_stable_itemlocalmap(hcx, hasher, fru_field_types);
661-
ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
661+
ich::hash_stable_itemlocalmap(hcx, hasher, cast_kinds);
662662

663663
ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {
664664
hcx.def_path_hash(*def_id)

src/librustc/ty/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ pub struct TypeckTables<'tcx> {
257257

258258
/// Maps a cast expression to its kind. This is keyed on the
259259
/// *from* expression of the cast, not the cast itself.
260-
pub cast_kinds: NodeMap<ty::cast::CastKind>,
260+
pub cast_kinds: ItemLocalMap<ty::cast::CastKind>,
261261

262262
/// Set of trait imports actually used in the method resolution.
263263
/// This is used for warning unused imports.
@@ -287,7 +287,8 @@ impl<'tcx> TypeckTables<'tcx> {
287287
closure_kinds: ItemLocalMap(),
288288
liberated_fn_sigs: ItemLocalMap(),
289289
fru_field_types: ItemLocalMap(),
290-
cast_kinds: NodeMap(),
290+
cast_kinds: ItemLocalMap(),
291+
lints: lint::LintTable::new(),
291292
used_trait_imports: DefIdSet(),
292293
tainted_by_errors: false,
293294
free_region_map: FreeRegionMap::new(),

src/librustc_mir/hair/cx/expr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
551551
hir::ExprCast(ref source, _) => {
552552
// Check to see if this cast is a "coercion cast", where the cast is actually done
553553
// using a coercion (or is a no-op).
554-
if let Some(&TyCastKind::CoercionCast) = cx.tables().cast_kinds.get(&source.id) {
554+
cx.tables().validate_hir_id(source.hir_id);
555+
if let Some(&TyCastKind::CoercionCast) = cx.tables()
556+
.cast_kinds
557+
.get(&source.hir_id.local_id) {
555558
// Convert the lexpr to a vexpr.
556559
ExprKind::Use { source: source.to_ref() }
557560
} else {

src/librustc_passes/consts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
320320
}
321321
hir::ExprCast(ref from, _) => {
322322
debug!("Checking const cast(id={})", from.id);
323-
match v.tables.cast_kinds.get(&from.id) {
323+
v.tables.validate_hir_id(from.hir_id);
324+
match v.tables.cast_kinds.get(&from.hir_id.local_id) {
324325
None => span_bug!(e.span, "no kind for cast"),
325326
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
326327
v.promotable = false;

src/librustc_typeck/check/cast.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,16 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
330330
} else if self.try_coercion_cast(fcx) {
331331
self.trivial_cast_lint(fcx);
332332
debug!(" -> CoercionCast");
333-
fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, CastKind::CoercionCast);
333+
let mut tables = fcx.tables.borrow_mut();
334+
tables.validate_hir_id(self.expr.hir_id);
335+
tables.cast_kinds.insert(self.expr.hir_id.local_id, CastKind::CoercionCast);
334336
} else {
335337
match self.do_check(fcx) {
336338
Ok(k) => {
337339
debug!(" -> {:?}", k);
338-
fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, k);
340+
let mut tables = fcx.tables.borrow_mut();
341+
tables.validate_hir_id(self.expr.hir_id);
342+
tables.cast_kinds.insert(self.expr.hir_id.local_id, k);
339343
}
340344
Err(e) => self.report_cast_error(fcx, e),
341345
};

0 commit comments

Comments
 (0)