Skip to content

Commit f391bc6

Browse files
committed
Querify module_children_local.
1 parent 706f244 commit f391bc6

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ rustc_queries! {
204204
desc { "getting the resolver for lowering" }
205205
}
206206

207+
/// Named module children from all kinds of items, including imports.
208+
/// In addition to regular items this list also includes struct and variant constructors, and
209+
/// items inside `extern {}` blocks because all of them introduce names into parent module.
210+
///
211+
/// Module here is understood in name resolution sense - it can be a `mod` item,
212+
/// or a crate root, or an enum, or a trait.
213+
query module_children_local(key: LocalDefId) -> &'tcx [ModChild] {
214+
desc { |tcx| "module exports for `{}`", tcx.def_path_str(key) }
215+
}
216+
207217
/// Return the span for a definition.
208218
///
209219
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ use crate::arena::Arena;
6363
use crate::dep_graph::{DepGraph, DepKindStruct};
6464
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind, CanonicalVarKinds};
6565
use crate::lint::lint_level;
66-
use crate::metadata::ModChild;
6766
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
6867
use crate::middle::{resolve_bound_vars, stability};
6968
use crate::mir::interpret::{self, Allocation, ConstAllocation};
@@ -3373,19 +3372,6 @@ impl<'tcx> TyCtxt<'tcx> {
33733372
self.opt_rpitit_info(def_id).is_some()
33743373
}
33753374

3376-
/// Named module children from all kinds of items, including imports.
3377-
/// In addition to regular items this list also includes struct and variant constructors, and
3378-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
3379-
///
3380-
/// Module here is understood in name resolution sense - it can be a `mod` item,
3381-
/// or a crate root, or an enum, or a trait.
3382-
///
3383-
/// This is not a query, making it a query causes perf regressions
3384-
/// (probably due to hashing spans in `ModChild`ren).
3385-
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
3386-
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
3387-
}
3388-
33893375
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Arc<ast::Crate>)> {
33903376
self.resolver_for_lowering_raw(()).0
33913377
}
@@ -3437,6 +3423,8 @@ pub struct DeducedParamAttrs {
34373423
}
34383424

34393425
pub fn provide(providers: &mut Providers) {
3426+
providers.module_children_local =
3427+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
34403428
providers.maybe_unused_trait_imports =
34413429
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
34423430
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)