Skip to content

Commit cdbeccc

Browse files
committed
Querify module_children_local.
1 parent b8d9359 commit cdbeccc

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
@@ -132,6 +132,16 @@ rustc_queries! {
132132
desc { "getting the resolver for lowering" }
133133
}
134134

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

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ use crate::arena::Arena;
6161
use crate::dep_graph::{DepGraph, DepKindStruct};
6262
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
6363
use crate::lint::lint_level;
64-
use crate::metadata::ModChild;
6564
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
6665
use crate::middle::{resolve_bound_vars, stability};
6766
use crate::mir::interpret::{self, Allocation, ConstAllocation};
@@ -3154,19 +3153,6 @@ impl<'tcx> TyCtxt<'tcx> {
31543153
self.opt_rpitit_info(def_id).is_some()
31553154
}
31563155

3157-
/// Named module children from all kinds of items, including imports.
3158-
/// In addition to regular items this list also includes struct and variant constructors, and
3159-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
3160-
///
3161-
/// Module here is understood in name resolution sense - it can be a `mod` item,
3162-
/// or a crate root, or an enum, or a trait.
3163-
///
3164-
/// This is not a query, making it a query causes perf regressions
3165-
/// (probably due to hashing spans in `ModChild`ren).
3166-
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
3167-
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
3168-
}
3169-
31703156
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
31713157
self.resolver_for_lowering_raw(()).0
31723158
}
@@ -3222,6 +3208,8 @@ pub struct DeducedParamAttrs {
32223208
}
32233209

32243210
pub fn provide(providers: &mut Providers) {
3211+
providers.module_children_local =
3212+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
32253213
providers.maybe_unused_trait_imports =
32263214
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
32273215
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)