Skip to content

Commit

Permalink
Use ItemLocalId as key for TypeckTables::liberated_fn_sigs.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Aug 11, 2017
1 parent 6cd44a9 commit 890f93f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ for ty::TypeckTables<'gcx> {

ich::hash_stable_itemlocalmap(hcx, hasher, closure_tys);
ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
ich::hash_stable_nodemap(hcx, hasher, liberated_fn_sigs);
ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
ich::hash_stable_nodemap(hcx, hasher, fru_field_types);
ich::hash_stable_nodemap(hcx, hasher, cast_kinds);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub struct TypeckTables<'tcx> {
/// (including late-bound regions) are replaced with free
/// equivalents. This table is not used in trans (since regions
/// are erased there) and hence is not serialized to metadata.
pub liberated_fn_sigs: NodeMap<ty::FnSig<'tcx>>,
pub liberated_fn_sigs: ItemLocalMap<ty::FnSig<'tcx>>,

/// For each FRU expression, record the normalized types of the fields
/// of the struct - this is needed because it is non-trivial to
Expand Down Expand Up @@ -285,7 +285,7 @@ impl<'tcx> TypeckTables<'tcx> {
upvar_capture_map: FxHashMap(),
closure_tys: ItemLocalMap(),
closure_kinds: ItemLocalMap(),
liberated_fn_sigs: NodeMap(),
liberated_fn_sigs: ItemLocalMap(),
fru_field_types: NodeMap(),
cast_kinds: NodeMap(),
used_trait_imports: DefIdSet(),
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
} else if let MirSource::Fn(id) = src {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
let fn_sig = cx.tables().liberated_fn_sigs[&id].clone();
let fn_hir_id = tcx.hir.node_to_hir_id(id);
cx.tables().validate_hir_id(fn_hir_id);
let fn_sig = cx.tables().liberated_fn_sigs[&fn_hir_id.local_id].clone();

let ty = tcx.type_of(tcx.hir.local_def_id(id));
let mut abi = fn_sig.abi;
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,12 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
fcx.write_ty(arg.hir_id, arg_ty);
}

inherited.tables.borrow_mut().liberated_fn_sigs.insert(fn_id, fn_sig);
{
let mut inh_tables = inherited.tables.borrow_mut();
let fn_hir_id = fcx.tcx.hir.node_to_hir_id(fn_id);
inh_tables.validate_hir_id(fn_hir_id);
inh_tables.liberated_fn_sigs.insert(fn_hir_id.local_id, fn_sig);
}

fcx.check_return_expr(&body.value);

Expand Down
6 changes: 4 additions & 2 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
let old_call_site_scope = self.set_call_site_scope(Some(call_site));

let fn_sig = {
let fn_sig_map = &self.tables.borrow().liberated_fn_sigs;
match fn_sig_map.get(&id) {
let tables = self.tables.borrow();
let fn_hir_id = self.tcx.hir.node_to_hir_id(id);
tables.validate_hir_id(fn_hir_id);
match tables.liberated_fn_sigs.get(&fn_hir_id.local_id) {
Some(f) => f.clone(),
None => {
bug!("No fn-sig entry for id={}", id);
Expand Down
13 changes: 10 additions & 3 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,16 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}

fn visit_liberated_fn_sigs(&mut self) {
for (&node_id, fn_sig) in self.fcx.tables.borrow().liberated_fn_sigs.iter() {
let fn_sig = self.resolve(fn_sig, &node_id);
self.tables.liberated_fn_sigs.insert(node_id, fn_sig.clone());
let fcx_tables = self.fcx.tables.borrow();
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);

for (&local_id, fn_sig) in fcx_tables.liberated_fn_sigs.iter() {
let hir_id = hir::HirId {
owner: fcx_tables.local_id_root.index,
local_id,
};
let fn_sig = self.resolve(fn_sig, &hir_id);
self.tables.liberated_fn_sigs.insert(local_id, fn_sig.clone());
}
}

Expand Down

0 comments on commit 890f93f

Please sign in to comment.