From b232992b44901edab3949fa38ba622976cbb42fb Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 3 Jul 2025 13:30:59 +0000 Subject: [PATCH] Unquerify extern_mod_stmt_cnum. --- compiler/rustc_middle/src/query/mod.rs | 3 --- compiler/rustc_middle/src/ty/context.rs | 8 +++++--- compiler/rustc_passes/src/check_attr.rs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index aefae3a3b1466..63d964dbe6cb6 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -2140,9 +2140,6 @@ rustc_queries! { desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) } separate_provide_extern } - query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option { - desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id) } - } /// Gets the number of definitions in a foreign crate. /// diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8aa50d14faa61..d50e28ed88136 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -3360,6 +3360,11 @@ impl<'tcx> TyCtxt<'tcx> { self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]) } + /// Return the crate imported by given use item. + pub fn extern_mod_stmt_cnum(self, def_id: LocalDefId) -> Option { + self.resolutions(()).extern_crate_map.get(&def_id).copied() + } + pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Arc)> { self.resolver_for_lowering_raw(()).0 } @@ -3416,9 +3421,6 @@ pub fn provide(providers: &mut Providers) { providers.names_imported_by_glob_use = |tcx, id| { tcx.arena.alloc(tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default()) }; - - providers.extern_mod_stmt_cnum = - |tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned(); providers.is_panic_runtime = |tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::panic_runtime); providers.is_compiler_builtins = diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 7880e629e911c..c5039e5fa6a43 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1193,7 +1193,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return; } - if self.tcx.extern_mod_stmt_cnum(hir_id.owner).is_none() { + if self.tcx.extern_mod_stmt_cnum(hir_id.owner.def_id).is_none() { self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id,