Skip to content

Commit 890f93f

Browse files
Use ItemLocalId as key for TypeckTables::liberated_fn_sigs.
1 parent 6cd44a9 commit 890f93f

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ for ty::TypeckTables<'gcx> {
656656

657657
ich::hash_stable_itemlocalmap(hcx, hasher, closure_tys);
658658
ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
659-
ich::hash_stable_nodemap(hcx, hasher, liberated_fn_sigs);
659+
ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
660660
ich::hash_stable_nodemap(hcx, hasher, fru_field_types);
661661
ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
662662

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub struct TypeckTables<'tcx> {
247247
/// (including late-bound regions) are replaced with free
248248
/// equivalents. This table is not used in trans (since regions
249249
/// are erased there) and hence is not serialized to metadata.
250-
pub liberated_fn_sigs: NodeMap<ty::FnSig<'tcx>>,
250+
pub liberated_fn_sigs: ItemLocalMap<ty::FnSig<'tcx>>,
251251

252252
/// For each FRU expression, record the normalized types of the fields
253253
/// of the struct - this is needed because it is non-trivial to
@@ -285,7 +285,7 @@ impl<'tcx> TypeckTables<'tcx> {
285285
upvar_capture_map: FxHashMap(),
286286
closure_tys: ItemLocalMap(),
287287
closure_kinds: ItemLocalMap(),
288-
liberated_fn_sigs: NodeMap(),
288+
liberated_fn_sigs: ItemLocalMap(),
289289
fru_field_types: NodeMap(),
290290
cast_kinds: NodeMap(),
291291
used_trait_imports: DefIdSet(),

src/librustc_mir/build/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
9090
} else if let MirSource::Fn(id) = src {
9191
// fetch the fully liberated fn signature (that is, all bound
9292
// types/lifetimes replaced)
93-
let fn_sig = cx.tables().liberated_fn_sigs[&id].clone();
93+
let fn_hir_id = tcx.hir.node_to_hir_id(id);
94+
cx.tables().validate_hir_id(fn_hir_id);
95+
let fn_sig = cx.tables().liberated_fn_sigs[&fn_hir_id.local_id].clone();
9496

9597
let ty = tcx.type_of(tcx.hir.local_def_id(id));
9698
let mut abi = fn_sig.abi;

src/librustc_typeck/check/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,12 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
10281028
fcx.write_ty(arg.hir_id, arg_ty);
10291029
}
10301030

1031-
inherited.tables.borrow_mut().liberated_fn_sigs.insert(fn_id, fn_sig);
1031+
{
1032+
let mut inh_tables = inherited.tables.borrow_mut();
1033+
let fn_hir_id = fcx.tcx.hir.node_to_hir_id(fn_id);
1034+
inh_tables.validate_hir_id(fn_hir_id);
1035+
inh_tables.liberated_fn_sigs.insert(fn_hir_id.local_id, fn_sig);
1036+
}
10321037

10331038
fcx.check_return_expr(&body.value);
10341039

src/librustc_typeck/check/regionck.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
309309
let old_call_site_scope = self.set_call_site_scope(Some(call_site));
310310

311311
let fn_sig = {
312-
let fn_sig_map = &self.tables.borrow().liberated_fn_sigs;
313-
match fn_sig_map.get(&id) {
312+
let tables = self.tables.borrow();
313+
let fn_hir_id = self.tcx.hir.node_to_hir_id(id);
314+
tables.validate_hir_id(fn_hir_id);
315+
match tables.liberated_fn_sigs.get(&fn_hir_id.local_id) {
314316
Some(f) => f.clone(),
315317
None => {
316318
bug!("No fn-sig entry for id={}", id);

src/librustc_typeck/check/writeback.rs

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

350350
fn visit_liberated_fn_sigs(&mut self) {
351-
for (&node_id, fn_sig) in self.fcx.tables.borrow().liberated_fn_sigs.iter() {
352-
let fn_sig = self.resolve(fn_sig, &node_id);
353-
self.tables.liberated_fn_sigs.insert(node_id, fn_sig.clone());
351+
let fcx_tables = self.fcx.tables.borrow();
352+
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);
353+
354+
for (&local_id, fn_sig) in fcx_tables.liberated_fn_sigs.iter() {
355+
let hir_id = hir::HirId {
356+
owner: fcx_tables.local_id_root.index,
357+
local_id,
358+
};
359+
let fn_sig = self.resolve(fn_sig, &hir_id);
360+
self.tables.liberated_fn_sigs.insert(local_id, fn_sig.clone());
354361
}
355362
}
356363

0 commit comments

Comments
 (0)