Skip to content

Commit ff2e6c2

Browse files
committed
Querify module_children_local.
1 parent 25b794f commit ff2e6c2

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

137+
/// Named module children from all kinds of items, including imports.
138+
/// In addition to regular items this list also includes struct and variant constructors, and
139+
/// items inside `extern {}` blocks because all of them introduce names into parent module.
140+
///
141+
/// Module here is understood in name resolution sense - it can be a `mod` item,
142+
/// or a crate root, or an enum, or a trait.
143+
query module_children_local(key: LocalDefId) -> &'tcx [ModChild] {
144+
desc { |tcx| "module exports for `{}`", tcx.def_path_str(key) }
145+
}
146+
137147
/// Return the span for a definition.
138148
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
139149
/// 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;
@@ -2114,19 +2113,6 @@ impl<'tcx> TyCtxt<'tcx> {
21142113
self.opt_rpitit_info(def_id).is_some()
21152114
}
21162115

2117-
/// Named module children from all kinds of items, including imports.
2118-
/// In addition to regular items this list also includes struct and variant constructors, and
2119-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
2120-
///
2121-
/// Module here is understood in name resolution sense - it can be a `mod` item,
2122-
/// or a crate root, or an enum, or a trait.
2123-
///
2124-
/// This is not a query, making it a query causes perf regressions
2125-
/// (probably due to hashing spans in `ModChild`ren).
2126-
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
2127-
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
2128-
}
2129-
21302116
pub fn metadata_dep_node(self) -> crate::dep_graph::DepNode {
21312117
crate::dep_graph::make_metadata(self)
21322118
}
@@ -2148,6 +2134,8 @@ pub struct DeducedParamAttrs {
21482134
}
21492135

21502136
pub fn provide(providers: &mut Providers) {
2137+
providers.module_children_local =
2138+
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
21512139
providers.maybe_unused_trait_imports =
21522140
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
21532141
providers.names_imported_by_glob_use = |tcx, id| {

0 commit comments

Comments
 (0)