Skip to content

Commit 73f1879

Browse files
committed
Querify module_children_local.
1 parent 69c2ea4 commit 73f1879

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

compiler/rustc_middle/src/query/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ rustc_queries! {
130130
desc { "getting the resolver for lowering" }
131131
}
132132

133+
/// Named module children from all kinds of items, including imports.
134+
/// In addition to regular items this list also includes struct and variant constructors, and
135+
/// items inside `extern {}` blocks because all of them introduce names into parent module.
136+
///
137+
/// Module here is understood in name resolution sense - it can be a `mod` item,
138+
/// or a crate root, or an enum, or a trait.
139+
query module_children_local(key: LocalDefId) -> &'tcx [ModChild] {
140+
desc { |tcx| "module exports for `{}`", tcx.def_path_str(key) }
141+
}
142+
133143
/// Return the span for a definition.
134144
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
135145
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside

compiler/rustc_middle/src/ty/context.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ use crate::arena::Arena;
6262
use crate::dep_graph::{DepGraph, DepKindStruct};
6363
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
6464
use crate::lint::lint_level;
65-
use crate::metadata::ModChild;
6665
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
6766
use crate::middle::{resolve_bound_vars, stability};
6867
use crate::mir::interpret::{self, Allocation, ConstAllocation};
@@ -3138,19 +3137,6 @@ impl<'tcx> TyCtxt<'tcx> {
31383137
self.opt_rpitit_info(def_id).is_some()
31393138
}
31403139

3141-
/// Named module children from all kinds of items, including imports.
3142-
/// In addition to regular items this list also includes struct and variant constructors, and
3143-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
3144-
///
3145-
/// Module here is understood in name resolution sense - it can be a `mod` item,
3146-
/// or a crate root, or an enum, or a trait.
3147-
///
3148-
/// This is not a query, making it a query causes perf regressions
3149-
/// (probably due to hashing spans in `ModChild`ren).
3150-
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
3151-
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
3152-
}
3153-
31543140
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
31553141
self.resolver_for_lowering_raw(()).0
31563142
}
@@ -3206,6 +3192,8 @@ pub struct DeducedParamAttrs {
32063192
}
32073193

32083194
pub fn provide(providers: &mut Providers) {
3195+
providers.module_children_local =
3196+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
32093197
providers.maybe_unused_trait_imports =
32103198
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
32113199
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)