Skip to content

Commit

Permalink
Use ItemLocalId as key for TypeckTables::fru_field_types.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Aug 11, 2017
1 parent 890f93f commit 801dd07
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_ty.rs
Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_mir/hair/cx/expr.rs
Expand Up @@ -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(),
}
}),
}
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_typeck/check/mod.rs
Expand Up @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions src/librustc_typeck/check/writeback.rs
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 801dd07

Please sign in to comment.