Skip to content

Commit 801dd07

Browse files
Use ItemLocalId as key for TypeckTables::fru_field_types.
1 parent 890f93f commit 801dd07

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

src/librustc/ich/impls_ty.rs

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

663663
ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub struct TypeckTables<'tcx> {
253253
/// of the struct - this is needed because it is non-trivial to
254254
/// normalize while preserving regions. This table is used only in
255255
/// MIR construction and hence is not serialized to metadata.
256-
pub fru_field_types: NodeMap<Vec<Ty<'tcx>>>,
256+
pub fru_field_types: ItemLocalMap<Vec<Ty<'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.
@@ -286,7 +286,7 @@ impl<'tcx> TypeckTables<'tcx> {
286286
closure_tys: ItemLocalMap(),
287287
closure_kinds: ItemLocalMap(),
288288
liberated_fn_sigs: ItemLocalMap(),
289-
fru_field_types: NodeMap(),
289+
fru_field_types: ItemLocalMap(),
290290
cast_kinds: NodeMap(),
291291
used_trait_imports: DefIdSet(),
292292
tainted_by_errors: false,

src/librustc_mir/hair/cx/expr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,12 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
387387
substs: substs,
388388
fields: field_refs,
389389
base: base.as_ref().map(|base| {
390+
cx.tables().validate_hir_id(expr.hir_id);
390391
FruInfo {
391392
base: base.to_ref(),
392-
field_types: cx.tables().fru_field_types[&expr.id].clone(),
393+
field_types: cx.tables()
394+
.fru_field_types[&expr.hir_id.local_id]
395+
.clone(),
393396
}
394397
}),
395398
}

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
34073407
let fru_field_types = adt.struct_variant().fields.iter().map(|f| {
34083408
self.normalize_associated_types_in(expr.span, &f.ty(self.tcx, substs))
34093409
}).collect();
3410-
self.tables.borrow_mut().fru_field_types.insert(expr.id, fru_field_types);
3410+
3411+
let mut tables = self.tables.borrow_mut();
3412+
tables.validate_hir_id(expr.hir_id);
3413+
tables.fru_field_types.insert(expr.hir_id.local_id, fru_field_types);
34113414
}
34123415
_ => {
34133416
span_err!(self.tcx.sess, base_expr.span, E0436,

src/librustc_typeck/check/writeback.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,16 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
362362
}
363363

364364
fn visit_fru_field_types(&mut self) {
365-
for (&node_id, ftys) in self.fcx.tables.borrow().fru_field_types.iter() {
366-
let ftys = self.resolve(ftys, &node_id);
367-
self.tables.fru_field_types.insert(node_id, ftys);
365+
let fcx_tables = self.fcx.tables.borrow();
366+
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);
367+
368+
for (&local_id, ftys) in fcx_tables.fru_field_types.iter() {
369+
let hir_id = hir::HirId {
370+
owner: fcx_tables.local_id_root.index,
371+
local_id,
372+
};
373+
let ftys = self.resolve(ftys, &hir_id);
374+
self.tables.fru_field_types.insert(local_id, ftys);
368375
}
369376
}
370377

0 commit comments

Comments
 (0)