Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f12e837

Browse files
committed
Hash resolutions.
1 parent 1584b0e commit f12e837

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

‎compiler/rustc_interface/src/passes.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
850850
providers.analysis = analysis;
851851
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
852852
providers.resolver_for_lowering_raw = resolver_for_lowering_raw;
853-
providers.stripped_cfg_items =
854-
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
853+
providers.stripped_cfg_items = |tcx, _| &tcx.resolutions(()).stripped_cfg_items[..];
855854
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
856855
providers.early_lint_checks = early_lint_checks;
857856
providers.env_var_os = env_var_os;

‎compiler/rustc_middle/src/query/mod.rs‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ rustc_queries! {
194194
}
195195

196196
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
197-
no_hash
198197
desc { "getting the resolver outputs" }
199198
}
200199

@@ -204,16 +203,6 @@ rustc_queries! {
204203
desc { "getting the resolver for lowering" }
205204
}
206205

207-
/// Named module children from all kinds of items, including imports.
208-
/// In addition to regular items this list also includes struct and variant constructors, and
209-
/// items inside `extern {}` blocks because all of them introduce names into parent module.
210-
///
211-
/// Module here is understood in name resolution sense - it can be a `mod` item,
212-
/// or a crate root, or an enum, or a trait.
213-
query module_children_local(key: LocalDefId) -> &'tcx [ModChild] {
214-
desc { |tcx| "module exports for `{}`", tcx.def_path_str(key) }
215-
}
216-
217206
/// Return the span for a definition.
218207
///
219208
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.

‎compiler/rustc_middle/src/ty/context.rs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ use crate::arena::Arena;
6363
use crate::dep_graph::{DepGraph, DepKindStruct};
6464
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind, CanonicalVarKinds};
6565
use crate::lint::lint_level;
66+
use crate::metadata::ModChild;
6667
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
6768
use crate::middle::{resolve_bound_vars, stability};
6869
use crate::mir::interpret::{self, Allocation, ConstAllocation};
@@ -3370,6 +3371,19 @@ impl<'tcx> TyCtxt<'tcx> {
33703371
self.opt_rpitit_info(def_id).is_some()
33713372
}
33723373

3374+
/// Named module children from all kinds of items, including imports.
3375+
/// In addition to regular items this list also includes struct and variant constructors, and
3376+
/// items inside `extern {}` blocks because all of them introduce names into parent module.
3377+
///
3378+
/// Module here is understood in name resolution sense - it can be a `mod` item,
3379+
/// or a crate root, or an enum, or a trait.
3380+
///
3381+
/// This is not a query, making it a query causes perf regressions
3382+
/// (probably due to hashing spans in `ModChild`ren).
3383+
pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
3384+
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
3385+
}
3386+
33733387
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Arc<ast::Crate>)> {
33743388
self.resolver_for_lowering_raw(()).0
33753389
}
@@ -3421,8 +3435,6 @@ pub struct DeducedParamAttrs {
34213435
}
34223436

34233437
pub fn provide(providers: &mut Providers) {
3424-
providers.module_children_local =
3425-
|tcx, def_id| tcx.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]);
34263438
providers.maybe_unused_trait_imports =
34273439
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
34283440
providers.names_imported_by_glob_use = |tcx, id| {

‎compiler/rustc_middle/src/ty/mod.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
3333
use rustc_data_structures::intern::Interned;
3434
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3535
use rustc_data_structures::steal::Steal;
36-
use rustc_data_structures::unord::UnordMap;
36+
use rustc_data_structures::unord::{UnordMap,UnordSet};
3737
use rustc_errors::{Diag, ErrorGuaranteed};
3838
use rustc_hir::LangItem;
3939
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
@@ -176,11 +176,11 @@ pub struct ResolverOutputs {
176176
pub ast_lowering: ResolverAstLowering,
177177
}
178178

179-
#[derive(Debug)]
179+
#[derive(Debug,HashStable)]
180180
pub struct ResolverGlobalCtxt {
181181
pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
182182
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
183-
pub expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
183+
pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,
184184
pub effective_visibilities: EffectiveVisibilities,
185185
pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,
186186
pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
@@ -196,8 +196,8 @@ pub struct ResolverGlobalCtxt {
196196
pub confused_type_with_std_module: FxIndexMap<Span, Span>,
197197
pub doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
198198
pub doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
199-
pub all_macro_rules: FxHashSet<Symbol>,
200-
pub stripped_cfg_items: Steal<Vec<StrippedCfgItem>>,
199+
pub all_macro_rules: UnordSet<Symbol>,
200+
pub stripped_cfg_items: Vec<StrippedCfgItem>,
201201
}
202202

203203
/// Resolutions that should only be used for lowering.
@@ -243,7 +243,7 @@ pub struct DelegationFnSig {
243243
pub target_feature: bool,
244244
}
245245

246-
#[derive(Clone, Copy, Debug)]
246+
#[derive(Clone, Copy, Debug,HashStable)]
247247
pub struct MainDefinition {
248248
pub res: Res<ast::NodeId>,
249249
pub is_import: bool,

‎compiler/rustc_resolve/src/lib.rs‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
4646
use rustc_data_structures::intern::Interned;
4747
use rustc_data_structures::steal::Steal;
4848
use rustc_data_structures::sync::FreezeReadGuard;
49-
use rustc_data_structures::unord::UnordMap;
49+
use rustc_data_structures::unord::{UnordMap,UnordSet};
5050
use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed};
5151
use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind};
5252
use rustc_feature::BUILTIN_ATTRIBUTES;
@@ -1031,7 +1031,7 @@ pub struct Resolver<'ra, 'tcx> {
10311031
tcx: TyCtxt<'tcx>,
10321032

10331033
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
1034-
expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
1034+
expn_that_defined: UnordMap<LocalDefId, ExpnId>,
10351035

10361036
graph_root: Module<'ra>,
10371037

@@ -1208,7 +1208,7 @@ pub struct Resolver<'ra, 'tcx> {
12081208
effective_visibilities: EffectiveVisibilities,
12091209
doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
12101210
doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
1211-
all_macro_rules: FxHashSet<Symbol>,
1211+
all_macro_rules: UnordSet<Symbol>,
12121212

12131213
/// Invocation ids of all glob delegations.
12141214
glob_delegation_invoc_ids: FxHashSet<LocalExpnId>,
@@ -1647,16 +1647,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16471647
let confused_type_with_std_module = self.confused_type_with_std_module;
16481648
let effective_visibilities = self.effective_visibilities;
16491649

1650-
let stripped_cfg_items = Steal::new(
1651-
self.stripped_cfg_items
1652-
.into_iter()
1653-
.filter_map(|item| {
1654-
let parent_module =
1655-
self.node_id_to_def_id.get(&item.parent_module)?.key().to_def_id();
1656-
Some(StrippedCfgItem { parent_module, ident: item.ident, cfg: item.cfg })
1657-
})
1658-
.collect(),
1659-
);
1650+
let stripped_cfg_items = self
1651+
.stripped_cfg_items
1652+
.into_iter()
1653+
.filter_map(|item| {
1654+
let parent_module =
1655+
self.node_id_to_def_id.get(&item.parent_module)?.key().to_def_id();
1656+
Some(StrippedCfgItem { parent_module, ident: item.ident, cfg: item.cfg })
1657+
})
1658+
.collect();
16601659

16611660
let global_ctxt = ResolverGlobalCtxt {
16621661
expn_that_defined,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /