Use ItemLocalId as key for TypeckTables::liberated_fn_sigs.
This commit is contained in:
parent
6cd44a9d5e
commit
890f93f8d4
@ -656,7 +656,7 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
@ -285,7 +285,7 @@ pub fn empty(local_id_root: DefId) -> 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(),
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -309,8 +309,10 @@ fn visit_fn_body(&mut self,
|
||||
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);
|
||||
|
@ -348,9 +348,16 @@ fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user