Skip to content

Commit e89f50a

Browse files
remove some HIR hashing
1 parent 19112b3 commit e89f50a

7 files changed

Lines changed: 35 additions & 21 deletions

File tree

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ use std::sync::Arc;
4141
use rustc_ast::node_id::NodeMap;
4242
use rustc_ast::visit::Visitor;
4343
use rustc_ast::{self as ast, *};
44-
use rustc_attr_parsing::{AttributeParser, EmitAttribute, Late, OmitDoc};
45-
use rustc_data_structures::fingerprint::Fingerprint;
44+
use rustc_attr_parsing::{AttributeParser, EmitAttribute, Late, OmitDoc};
45+
//use rustc_data_structures::fingerprint::Fingerprint;
4646
use rustc_data_structures::fx::FxIndexSet;
4747
use rustc_data_structures::sorted_map::SortedMap;
48-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
48+
//use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4949
use rustc_data_structures::steal::Steal;
5050
use rustc_data_structures::tagged_ptr::TaggedRef;
5151
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
@@ -57,7 +57,7 @@ use rustc_hir::{
5757
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
5858
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
5959
};
60-
use rustc_index::{Idx, IndexSlice, IndexVec};
60+
use rustc_index::{Idx, IndexVec};
6161
use rustc_macros::extension;
6262
use rustc_middle::hir::{self as mid_hir};
6363
use rustc_middle::span_bug;
@@ -507,7 +507,7 @@ fn index_crate<'a, 'b>(
507507

508508
/// Compute the hash for the HIR of the full crate.
509509
/// This hash will then be part of the crate_hash which is stored in the metadata.
510-
fn compute_hir_hash(
510+
/*fn compute_hir_hash(
511511
tcx: TyCtxt<'_>,
512512
owners: &IndexSlice<LocalDefId, hir::MaybeOwner<'_>>,
513513
) -> Fingerprint {
@@ -526,7 +526,7 @@ fn compute_hir_hash(
526526
hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher);
527527
stable_hasher.finish()
528528
})
529-
}
529+
}*/
530530

531531
pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
532532
// Queries that borrow `resolver_for_lowering`.
@@ -562,11 +562,11 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
562562
}
563563

564564
// Don't hash unless necessary, because it's expensive.
565-
let opt_hir_hash =
566-
if tcx.needs_crate_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None };
565+
// let opt_hir_hash =
566+
// if tcx.needs_crate_hash() { Some(tcx.crate_hash(LOCAL_CRATE)) } else { None };
567567

568568
let delayed_resolver = Steal::new((resolver, krate));
569-
mid_hir::Crate::new(owners, delayed_ids, delayed_resolver, opt_hir_hash)
569+
mid_hir::Crate::new(owners, delayed_ids, delayed_resolver, None)
570570
}
571571

572572
/// Lowers an AST owner corresponding to `def_id`, now only delegations are lowered this way.

compiler/rustc_data_structures/src/svh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::fingerprint::Fingerprint;
2323
HashStable_NoContext
2424
)]
2525
pub struct Svh {
26-
hash: Fingerprint,
26+
pub hash: Fingerprint,
2727
}
2828

2929
impl Svh {

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::marker::PhantomData;
22
use std::num::NonZero;
33

4-
use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
54
use decoder::LazyDecoder;
65
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob, TargetModifiers};
76
use def_path_hash_map::DefPathHashMapRef;
@@ -36,6 +35,7 @@ use rustc_middle::mir::ConstValue;
3635
use rustc_middle::ty::fast_reject::SimplifiedType;
3736
use rustc_middle::ty::{self, Ty, TyCtxt};
3837
use rustc_middle::util::Providers;
38+
use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
3939
use rustc_session::config::{SymbolManglingVersion, TargetModifier};
4040
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
4141
use rustc_span::edition::Edition;

compiler/rustc_middle/src/hir/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use rustc_abi::ExternAbi;
66
use rustc_ast::visit::{VisitorResult, walk_list};
7-
use rustc_data_structures::sync::{DynSend, DynSync, par_for_each_in, try_par_for_each_in, spawn};
7+
use rustc_data_structures::sync::{DynSend, DynSync, par_for_each_in, spawn, try_par_for_each_in};
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
1010
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ pub mod place;
88

99
use std::sync::Arc;
1010

11+
//use rustc_hir::def_id::LOCAL_CRATE;
1112
use rustc_ast::{self as ast};
1213
use rustc_data_structures::fingerprint::Fingerprint;
1314
use rustc_data_structures::fx::FxIndexSet;
1415
use rustc_data_structures::sorted_map::SortedMap;
1516
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1617
use rustc_data_structures::steal::Steal;
18+
use rustc_data_structures::svh::Svh;
1719
use rustc_data_structures::sync::{DynSend, DynSync, try_par_for_each_in};
1820
use rustc_hir::def::{DefKind, Res};
1921
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
2022
use rustc_hir::*;
2123
use rustc_index::IndexVec;
2224
use rustc_macros::{Decodable, Encodable, HashStable};
23-
use rustc_span::{ErrorGuaranteed, ExpnId, HashStableContext, Span};
25+
use rustc_span::{ErrorGuaranteed, ExpnId, Span};
2426

2527
use crate::query::Providers;
2628
use crate::ty::{ResolverAstLowering, TyCtxt};
@@ -31,8 +33,8 @@ use crate::ty::{ResolverAstLowering, TyCtxt};
3133
/// For more details, see the [rustc dev guide].
3234
///
3335
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
34-
#[derive(Debug)]
3536
pub struct Crate<'hir> {
37+
// tcx: TyCtxt<'hir>,
3638
// This field is private by intention, access it through `owner` method.
3739
owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
3840
// Ids of delayed AST owners which are lowered through `lower_delayed_owner` query.
@@ -41,17 +43,27 @@ pub struct Crate<'hir> {
4143
// and then stolen and dropped in `force_delayed_owners_lowering`.
4244
pub delayed_resolver: Steal<(ResolverAstLowering<'hir>, Arc<ast::Crate>)>,
4345
// Only present when incr. comp. is enabled.
44-
pub opt_hir_hash: Option<Fingerprint>,
46+
pub opt_hash: Option<Svh>,
47+
}
48+
49+
impl std::fmt::Debug for Crate<'_> {
50+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51+
f.debug_struct("Crate")
52+
.field("owners", &self.owners)
53+
.field("delayed_ids", &self.delayed_ids)
54+
.field("delayed_resolver", &self.delayed_resolver)
55+
.finish()
56+
}
4557
}
4658

4759
impl<'hir> Crate<'hir> {
4860
pub fn new(
4961
owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
5062
delayed_ids: FxIndexSet<LocalDefId>,
5163
delayed_resolver: Steal<(ResolverAstLowering<'hir>, Arc<ast::Crate>)>,
52-
opt_hir_hash: Option<Fingerprint>,
64+
opt_hash: Option<Svh>,
5365
) -> Crate<'hir> {
54-
Crate { owners, delayed_ids, delayed_resolver, opt_hir_hash }
66+
Crate { owners, delayed_ids, delayed_resolver, opt_hash }
5567
}
5668

5769
/// Serves as an entry point for getting `MaybeOwner`. As owner can either be in
@@ -76,12 +88,11 @@ impl<'hir> Crate<'hir> {
7688
}
7789
}
7890

79-
impl<Hcx: HashStableContext> HashStable<Hcx> for Crate<'_> {
91+
/*impl<Hcx: HashStableContext> HashStable<Hcx> for Crate<'_> {
8092
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
81-
let Crate { opt_hir_hash, .. } = self;
82-
opt_hir_hash.unwrap().hash_stable(hcx, hasher)
93+
self.tcx.crate_hash(LOCAL_CRATE).hash_stable(hcx, hasher)
8394
}
84-
}
95+
}*/
8596

8697
/// Gather the LocalDefId for each item-like within a module, including items contained within
8798
/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.

compiler/rustc_middle/src/queries.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ rustc_queries! {
208208
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
209209
arena_cache
210210
eval_always
211+
no_hash
211212
desc { "getting the crate HIR" }
212213
}
213214

compiler/rustc_query_impl/src/query_impl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//use rustc_data_structures::fingerprint::Fingerprint;
12
use rustc_middle::queries::TaggedQueryKey;
23
use rustc_middle::query::erase::{self, Erased};
34
use rustc_middle::query::{AsLocalQueryKey, QueryMode, QueryVTable};
@@ -189,6 +190,7 @@ macro_rules! define_queries {
189190
hash_value_fn: Some(|hcx, erased_value: &erase::Erased<Value<'tcx>>| {
190191
let value = erase::restore_val(*erased_value);
191192
rustc_middle::dep_graph::hash_result(hcx, &value)
193+
//Fingerprint::new(0, 0)
192194
}),
193195

194196
format_value: |erased_value: &erase::Erased<Value<'tcx>>| {

0 commit comments

Comments
 (0)