diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index eec73937e2c..740b4c428dc 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -656,7 +656,7 @@ fn hash_stable(&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); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 492ec0f3e40..5ec39b78e30 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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>, + pub liberated_fn_sigs: ItemLocalMap>, /// 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(), diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 66817fda5b7..ae951d50a8c 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -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; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 5308ffe6f8d..0d484d2ce36 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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); diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 3113f4a569f..c9c8f3363ce 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -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); diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index ed7b75ddb05..499afe62b4f 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -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()); } }