diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-04-27 18:34:43 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-05-02 17:21:08 +0300 |
| commit | ef77dd232d7eed9d82b0719d7fc683924a3dc2de (patch) | |
| tree | 354d62df9952adc6d14207510c14c13d234224ca /compiler/rustc_middle/src/ty | |
| parent | 98c33e47a495fbd7b22bce9ce32f2815991bc414 (diff) | |
| download | rust-ef77dd232d7eed9d82b0719d7fc683924a3dc2de.tar.gz rust-ef77dd232d7eed9d82b0719d7fc683924a3dc2de.zip | |
resolve: One more attempt to simplify `module_children`
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 3 |
2 files changed, 7 insertions, 17 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a309eaf048d..bf78b379986 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -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[..]) } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index db6b35026a8..8986defacc7 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -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>>, |
