Skip to content

Commit 172ee0e

Browse files
committed
Auto merge of #155248 - JonathanBrouwer:no_hash_delayed_lints, r=<try>
Don't hash `DelayedLints`
2 parents 14196db + f45125b commit 172ee0e

7 files changed

Lines changed: 10 additions & 37 deletions

File tree

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,13 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
863863
let bodies = SortedMap::from_presorted_elements(bodies);
864864

865865
// Don't hash unless necessary, because it's expensive.
866-
let rustc_middle::hir::Hashes { opt_hash_including_bodies, attrs_hash, delayed_lints_hash } =
867-
self.tcx.hash_owner_nodes(node, &bodies, &attrs, &delayed_lints, define_opaque);
866+
let rustc_middle::hir::Hashes { opt_hash_including_bodies, attrs_hash } =
867+
self.tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
868868
let num_nodes = self.item_local_id_counter.as_usize();
869869
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
870870
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };
871871
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash, define_opaque };
872-
let delayed_lints =
873-
hir::lints::DelayedLints { lints: delayed_lints, opt_hash: delayed_lints_hash };
872+
let delayed_lints = hir::lints::DelayedLints { lints: delayed_lints };
874873

875874
self.arena.alloc(hir::OwnerInfo { nodes, parenting, attrs, trait_map, delayed_lints })
876875
}

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,7 @@ pub struct OwnerInfo<'hir> {
16311631

16321632
/// Lints delayed during ast lowering to be emitted
16331633
/// after hir has completely built
1634+
#[stable_hasher(ignore)]
16341635
pub delayed_lints: DelayedLints,
16351636
}
16361637

compiler/rustc_hir/src/lints.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
use rustc_data_structures::fingerprint::Fingerprint;
21
use rustc_error_messages::MultiSpan;
32
use rustc_lint_defs::LintId;
43
pub use rustc_lint_defs::{AttributeLintKind, FormatWarning};
5-
use rustc_macros::HashStable_Generic;
64

75
use crate::HirId;
86

97
#[derive(Debug)]
108
pub struct DelayedLints {
119
pub lints: Box<[DelayedLint]>,
12-
// Only present when the crate hash is needed.
13-
pub opt_hash: Option<Fingerprint>,
1410
}
1511

1612
/// During ast lowering, no lints can be emitted.
@@ -19,12 +15,12 @@ pub struct DelayedLints {
1915
/// and then there's a gap where no lints can be emitted until HIR is done.
2016
/// The variants in this enum represent lints that are temporarily stashed during
2117
/// AST lowering to be emitted once HIR is built.
22-
#[derive(Debug, HashStable_Generic)]
18+
#[derive(Debug)]
2319
pub enum DelayedLint {
2420
AttributeParsing(AttributeLint<HirId>),
2521
}
2622

27-
#[derive(Debug, HashStable_Generic)]
23+
#[derive(Debug)]
2824
pub struct AttributeLint<Id> {
2925
pub lint_id: LintId,
3026
pub id: Id,

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::hir::{
77
AttributeMap, BodyId, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
88
};
99
use crate::hir_id::ItemLocalId;
10-
use crate::lints::DelayedLints;
1110

1211
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for BodyId {
1312
type KeyType = (DefPathHash, ItemLocalId);
@@ -74,13 +73,6 @@ impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for OwnerNodes<'tcx> {
7473
}
7574
}
7675

77-
impl<Hcx: HashStableContext> HashStable<Hcx> for DelayedLints {
78-
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
79-
let DelayedLints { opt_hash, .. } = *self;
80-
opt_hash.unwrap().hash_stable(hcx, hasher);
81-
}
82-
}
83-
8476
impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for AttributeMap<'tcx> {
8577
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
8678
// We ignore the `map` since it refers to information included in `opt_hash` which is

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_data_structures::steal::Steal;
1717
use rustc_data_structures::sync::{DynSend, DynSync, spawn, try_par_for_each_in};
1818
use rustc_hir::def::{DefKind, Res};
1919
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
20-
use rustc_hir::lints::DelayedLint;
2120
use rustc_hir::*;
2221
use rustc_index::IndexVec;
2322
use rustc_macros::{Decodable, Encodable, HashStable};
@@ -255,15 +254,10 @@ impl<'tcx> TyCtxt<'tcx> {
255254
node: OwnerNode<'_>,
256255
bodies: &SortedMap<ItemLocalId, &Body<'_>>,
257256
attrs: &SortedMap<ItemLocalId, &[Attribute]>,
258-
delayed_lints: &[DelayedLint],
259257
define_opaque: Option<&[(Span, LocalDefId)]>,
260258
) -> Hashes {
261259
if !self.needs_crate_hash() {
262-
return Hashes {
263-
opt_hash_including_bodies: None,
264-
attrs_hash: None,
265-
delayed_lints_hash: None,
266-
};
260+
return Hashes { opt_hash_including_bodies: None, attrs_hash: None };
267261
}
268262

269263
self.with_stable_hashing_context(|mut hcx| {
@@ -281,16 +275,7 @@ impl<'tcx> TyCtxt<'tcx> {
281275

282276
let h2 = stable_hasher.finish();
283277

284-
// hash lints emitted during ast lowering
285-
let mut stable_hasher = StableHasher::new();
286-
delayed_lints.hash_stable(&mut hcx, &mut stable_hasher);
287-
let h3 = stable_hasher.finish();
288-
289-
Hashes {
290-
opt_hash_including_bodies: Some(h1),
291-
attrs_hash: Some(h2),
292-
delayed_lints_hash: Some(h3),
293-
}
278+
Hashes { opt_hash_including_bodies: Some(h1), attrs_hash: Some(h2) }
294279
})
295280
}
296281

@@ -484,7 +469,6 @@ impl<'tcx> TyCtxt<'tcx> {
484469
pub struct Hashes {
485470
pub opt_hash_including_bodies: Option<Fingerprint>,
486471
pub attrs_hash: Option<Fingerprint>,
487-
pub delayed_lints_hash: Option<Fingerprint>,
488472
}
489473

490474
pub fn provide(providers: &mut Providers) {

compiler/rustc_middle/src/queries.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ rustc_queries! {
276276
/// Avoid calling this query directly.
277277
query opt_ast_lowering_delayed_lints(key: hir::OwnerId) -> Option<&'tcx hir::lints::DelayedLints> {
278278
desc { "getting AST lowering delayed lints in `{}`", tcx.def_path_str(key) }
279+
no_hash
279280
}
280281

281282
/// Returns the *default* of the const pararameter given by `DefId`.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
708708
let attrs = hir::AttributeMap::EMPTY;
709709

710710
let rustc_middle::hir::Hashes { opt_hash_including_bodies, .. } =
711-
self.tcx.hash_owner_nodes(node, &bodies, &attrs.map, &[], attrs.define_opaque);
711+
self.tcx.hash_owner_nodes(node, &bodies, &attrs.map, attrs.define_opaque);
712712
let node = node.into();
713713
self.opt_hir_owner_nodes(Some(self.tcx.arena.alloc(hir::OwnerNodes {
714714
opt_hash_including_bodies,

0 commit comments

Comments
 (0)