Use ItemLocalId as key for TypeckTables::fru_field_types.

This commit is contained in:
Michael Woerister 2017-08-08 12:13:16 +02:00
parent 890f93f8d4
commit 801dd07a95
5 changed files with 21 additions and 8 deletions

View file

@ -657,7 +657,7 @@ for ty::TypeckTables<'gcx> {
ich::hash_stable_itemlocalmap(hcx, hasher, closure_tys);
ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
ich::hash_stable_nodemap(hcx, hasher, fru_field_types);
ich::hash_stable_itemlocalmap(hcx, hasher, fru_field_types);
ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {

View file

@ -253,7 +253,7 @@ pub struct TypeckTables<'tcx> {
/// of the struct - this is needed because it is non-trivial to
/// normalize while preserving regions. This table is used only in
/// MIR construction and hence is not serialized to metadata.
pub fru_field_types: NodeMap<Vec<Ty<'tcx>>>,
pub fru_field_types: ItemLocalMap<Vec<Ty<'tcx>>>,
/// Maps a cast expression to its kind. This is keyed on the
/// *from* expression of the cast, not the cast itself.
@ -286,7 +286,7 @@ impl<'tcx> TypeckTables<'tcx> {
closure_tys: ItemLocalMap(),
closure_kinds: ItemLocalMap(),
liberated_fn_sigs: ItemLocalMap(),
fru_field_types: NodeMap(),
fru_field_types: ItemLocalMap(),
cast_kinds: NodeMap(),
used_trait_imports: DefIdSet(),
tainted_by_errors: false,

View file

@ -387,9 +387,12 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
substs: substs,
fields: field_refs,
base: base.as_ref().map(|base| {
cx.tables().validate_hir_id(expr.hir_id);
FruInfo {
base: base.to_ref(),
field_types: cx.tables().fru_field_types[&expr.id].clone(),
field_types: cx.tables()
.fru_field_types[&expr.hir_id.local_id]
.clone(),
}
}),
}

View file

@ -3407,7 +3407,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let fru_field_types = adt.struct_variant().fields.iter().map(|f| {
self.normalize_associated_types_in(expr.span, &f.ty(self.tcx, substs))
}).collect();
self.tables.borrow_mut().fru_field_types.insert(expr.id, fru_field_types);
let mut tables = self.tables.borrow_mut();
tables.validate_hir_id(expr.hir_id);
tables.fru_field_types.insert(expr.hir_id.local_id, fru_field_types);
}
_ => {
span_err!(self.tcx.sess, base_expr.span, E0436,

View file

@ -362,9 +362,16 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}
fn visit_fru_field_types(&mut self) {
for (&node_id, ftys) in self.fcx.tables.borrow().fru_field_types.iter() {
let ftys = self.resolve(ftys, &node_id);
self.tables.fru_field_types.insert(node_id, ftys);
let fcx_tables = self.fcx.tables.borrow();
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);
for (&local_id, ftys) in fcx_tables.fru_field_types.iter() {
let hir_id = hir::HirId {
owner: fcx_tables.local_id_root.index,
local_id,
};
let ftys = self.resolve(ftys, &hir_id);
self.tables.fru_field_types.insert(local_id, ftys);
}
}