diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-05-30 18:49:17 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-14 22:45:51 +0200 |
| commit | 34e4d72929c33bb126e0b1b199faab9031e0f3de (patch) | |
| tree | 69b51523d44c6b69ba565ede45279fca81027797 /compiler/rustc_middle/src/hir | |
| parent | b676edd641dbd1049702e63dc027f92daa849d23 (diff) | |
| download | rust-34e4d72929c33bb126e0b1b199faab9031e0f3de.tar.gz rust-34e4d72929c33bb126e0b1b199faab9031e0f3de.zip | |
Separate `source_span` and `expn_that_defined` from `Definitions`.
Diffstat (limited to 'compiler/rustc_middle/src/hir')
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 73aa23ce2b2..9d77d640a15 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1078,6 +1078,8 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { let upstream_crates = upstream_crates(tcx); + let resolutions = tcx.resolutions(()); + // We hash the final, remapped names of all local source files so we // don't have to include the path prefix remapping commandline args. // If we included the full mapping in the SVH, we could only have @@ -1107,7 +1109,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { .filter_map(|(def_id, info)| { let _ = info.as_owner()?; let def_path_hash = definitions.def_path_hash(def_id); - let span = definitions.def_span(def_id); + let span = resolutions.source_span[def_id]; debug_assert_eq!(span.parent(), None); Some((def_path_hash, span)) }) @@ -1118,7 +1120,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher); tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher); // Hash visibility information since it does not appear in HIR. - let resolutions = tcx.resolutions(()); resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher); resolutions.has_pub_restricted.hash_stable(&mut hcx, &mut stable_hasher); diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 8068e6dff95..09b142e0c41 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -13,7 +13,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::*; use rustc_query_system::ich::StableHashingContext; -use rustc_span::DUMMY_SP; +use rustc_span::{ExpnId, DUMMY_SP}; /// Top-level HIR node for current owner. This only contains the node for which /// `HirId::local_id == 0`, and excludes bodies. @@ -117,7 +117,8 @@ pub fn provide(providers: &mut Providers) { }; providers.hir_attrs = |tcx, id| tcx.hir_crate(()).owners[id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs); - providers.source_span = |tcx, def_id| tcx.definitions_untracked().def_span(def_id); + providers.source_span = + |tcx, def_id| tcx.resolutions(()).source_span.get(def_id).copied().unwrap_or(DUMMY_SP); providers.def_span = |tcx, def_id| { let def_id = def_id.expect_local(); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); @@ -147,7 +148,7 @@ pub fn provide(providers: &mut Providers) { providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls; providers.expn_that_defined = |tcx, id| { let id = id.expect_local(); - tcx.definitions_untracked().expansion_that_defined(id) + tcx.resolutions(()).expn_that_defined.get(&id).copied().unwrap_or(ExpnId::root()) }; providers.in_scope_traits_map = |tcx, id| tcx.hir_crate(()).owners[id].as_owner().map(|owner_info| &owner_info.trait_map); |
