Rollup merge of #110908 - petrochenkov:notagain4, r=compiler-errors
resolve: One more attempt to simplify `module_children` If the next step is performed and `fn module_children_local` is merged with the `module_children` query, then it causes perf regressions, regardless of whether query result feeding is [used](https://perf.rust-lang.org/compare.html?start=43a78029b4f4d92978b8fde0a677ea300b113c41&end=2eb5bcc5068b9d92f74bcb1797da664865d6981d&stat=instructions:u) or [not](https://perf.rust-lang.org/compare.html?start=2fce2290865f012391b8f3e581c3852a248031fa&end=2a33d6cd99481d1712037a79e7d66a8aefadbf72&stat=instructions:u).
This commit is contained in:
commit
0228994cdf
10 changed files with 45 additions and 53 deletions
|
@ -2414,26 +2414,17 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Named module children from all items except `use` and `extern crate` imports.
|
||||
///
|
||||
/// In addition to regular items this list also includes struct or variant constructors, and
|
||||
/// Named module children from all kinds of items, including imports.
|
||||
/// In addition to regular items this list also includes struct and variant constructors, and
|
||||
/// items inside `extern {}` blocks because all of them introduce names into parent module.
|
||||
/// For non-reexported children every such name is associated with a separate `DefId`.
|
||||
///
|
||||
/// Module here is understood in name resolution sense - it can be a `mod` item,
|
||||
/// or a crate root, or an enum, or a trait.
|
||||
pub fn module_children_non_reexports(self, def_id: LocalDefId) -> &'tcx [LocalDefId] {
|
||||
self.resolutions(()).module_children_non_reexports.get(&def_id).map_or(&[], |v| &v[..])
|
||||
}
|
||||
|
||||
/// Named module children from `use` and `extern crate` imports.
|
||||
///
|
||||
/// Reexported names are not associated with individual `DefId`s,
|
||||
/// e.g. a glob import can introduce a lot of names, all with the same `DefId`.
|
||||
/// That's why the list needs to contain `ModChild` structures describing all the names
|
||||
/// individually instead of `DefId`s.
|
||||
pub fn module_children_reexports(self, def_id: LocalDefId) -> &'tcx [ModChild] {
|
||||
self.resolutions(()).module_children_reexports.get(&def_id).map_or(&[], |v| &v[..])
|
||||
/// This is not a query, making it a query causes perf regressions
|
||||
/// (probably due to hashing spans in `ModChild`ren).
|
||||
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
|
||||
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,8 +165,7 @@ pub struct ResolverGlobalCtxt {
|
|||
pub effective_visibilities: EffectiveVisibilities,
|
||||
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
|
||||
pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
|
||||
pub module_children_non_reexports: LocalDefIdMap<Vec<LocalDefId>>,
|
||||
pub module_children_reexports: LocalDefIdMap<Vec<ModChild>>,
|
||||
pub module_children: LocalDefIdMap<Vec<ModChild>>,
|
||||
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
|
||||
pub main_def: Option<MainDefinition>,
|
||||
pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue