Skip to content

Commit ba92291

Browse files
committed
Querify module_children_local.
1 parent a48e472 commit ba92291

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
@@ -8,7 +8,6 @@ use crate::arena::Arena;
88
use crate::dep_graph::{DepGraph, DepKindStruct};
99
use crate::infer::canonical::CanonicalVarInfo;
1010
use crate::lint::struct_lint_level;
11-
use crate::metadata::ModChild;
1211
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
1312
use crate::middle::resolve_bound_vars;
1413
use crate::middle::stability;
@@ -2137,19 +2136,6 @@ impl<'tcx> TyCtxt<'tcx> {
21372136
self.opt_rpitit_info(def_id).is_some()
21382137
}
21392138

2140-
/// Named module children from all kinds of items, including imports.
2141-
/// In addition to regular items this list also includes struct and variant constructors, and
2142-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
2143-
///
2144-
/// Module here is understood in name resolution sense - it can be a `mod` item,
2145-
/// or a crate root, or an enum, or a trait.
2146-
///
2147-
/// This is not a query, making it a query causes perf regressions
2148-
/// (probably due to hashing spans in `ModChild`ren).
2149-
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
2150-
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
2151-
}
2152-
21532139
pub fn metadata_dep_node(self) -> crate::dep_graph::DepNode {
21542140
crate::dep_graph::make_metadata(self)
21552141
}
@@ -2171,6 +2157,8 @@ pub struct DeducedParamAttrs {
21712157
}
21722158

21732159
pub fn provide(providers: &mut Providers) {
2160+
providers.module_children_local =
2161+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
21742162
providers.maybe_unused_trait_imports =
21752163
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
21762164
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)