Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make extern_mod_stmt_cnum into a regular function #83128

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,10 +1277,6 @@ rustc_queries! {
query item_children(def_id: DefId) -> &'tcx [Export<hir::HirId>] {
desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
}
query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
}

query get_lib_features(_: CrateNum) -> LibFeatures {
storage(ArenaCacheSelector<'tcx>)
eval_always
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,12 @@ impl<'tcx> TyCtxt<'tcx> {
def_kind => (def_kind.article(), def_kind.descr(def_id)),
}
}

/// Returns the `CrateNum` of the crate that the given `extern crate` statement
/// resolves to.
pub fn extern_mod_stmt_cnum(self, id: LocalDefId) -> Option<CrateNum> {
self.extern_crate_map.get(&id).cloned()
}
}

/// A trait implemented for all `X<'a>` types that can be safely and
Expand Down Expand Up @@ -2755,7 +2761,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
tcx.stability().local_deprecation_entry(id)
};
providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned();
providers.all_crate_nums = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
Expand Down