Skip to content

Commit ed2bb15

Browse files
committed
Querify module_children_local.
1 parent dfe4877 commit ed2bb15

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
@@ -129,6 +129,16 @@ rustc_queries! {
129129
desc { "getting the resolver for lowering" }
130130
}
131131

132+
/// Named module children from all kinds of items, including imports.
133+
/// In addition to regular items this list also includes struct and variant constructors, and
134+
/// items inside `extern {}` blocks because all of them introduce names into parent module.
135+
///
136+
/// Module here is understood in name resolution sense - it can be a `mod` item,
137+
/// or a crate root, or an enum, or a trait.
138+
query module_children_local(key: LocalDefId) -> &'tcx [ModChild] {
139+
desc { |tcx| "module exports for `{}`", tcx.def_path_str(key) }
140+
}
141+
132142
/// Return the span for a definition.
133143
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
134144
/// 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
@@ -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
}
@@ -3195,6 +3181,8 @@ pub struct DeducedParamAttrs {
31953181
}
31963182

31973183
pub fn provide(providers: &mut Providers) {
3184+
providers.module_children_local =
3185+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
31983186
providers.maybe_unused_trait_imports =
31993187
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
32003188
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)