Skip to content

Commit aab76e7

Browse files
authored
Rollup merge of rust-lang#143374 - cjgillot:bare-extern-crate-map, r=petrochenkov
Unquerify extern_mod_stmt_cnum. Based on rust-lang#143247 r? `@ghost` for perf
2 parents 74f1de6 + 3440bc9 commit aab76e7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,9 +2152,6 @@ rustc_queries! {
21522152
desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) }
21532153
separate_provide_extern
21542154
}
2155-
query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
2156-
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id) }
2157-
}
21582155

21592156
/// Gets the number of definitions in a foreign crate.
21602157
///

compiler/rustc_middle/src/ty/context.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,6 +3373,11 @@ impl<'tcx> TyCtxt<'tcx> {
33733373
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
33743374
}
33753375

3376+
/// Return the crate imported by given use item.
3377+
pub fn extern_mod_stmt_cnum(self, def_id: LocalDefId) -> Option<CrateNum> {
3378+
self.resolutions(()).extern_crate_map.get(&def_id).copied()
3379+
}
3380+
33763381
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Arc<ast::Crate>)> {
33773382
self.resolver_for_lowering_raw(()).0
33783383
}
@@ -3428,8 +3433,6 @@ pub struct DeducedParamAttrs {
34283433
}
34293434

34303435
pub fn provide(providers: &mut Providers) {
3431-
providers.extern_mod_stmt_cnum =
3432-
|tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned();
34333436
providers.is_panic_runtime =
34343437
|tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::panic_runtime);
34353438
providers.is_compiler_builtins =

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12581258
return;
12591259
}
12601260

1261-
if self.tcx.extern_mod_stmt_cnum(hir_id.owner).is_none() {
1261+
if self.tcx.extern_mod_stmt_cnum(hir_id.owner.def_id).is_none() {
12621262
self.tcx.emit_node_span_lint(
12631263
INVALID_DOC_ATTRIBUTES,
12641264
hir_id,

0 commit comments

Comments
 (0)