Skip to content

Commit c9a4e5d

Browse files
authored
Unrolled build for #156265
Rollup merge of #156265 - nnethercote:rm-unused-ToStableHashKey-impls, r=mejrs Remove unused `ToStableHashKey` impls. There are quite a few. r? @mejrs
2 parents 32bd660 + 769f2f1 commit c9a4e5d

11 files changed

Lines changed: 9 additions & 217 deletions

File tree

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,22 +459,6 @@ impl StableOrd for String {
459459
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
460460
}
461461

462-
impl ToStableHashKey for String {
463-
type KeyType = String;
464-
#[inline]
465-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
466-
self.clone()
467-
}
468-
}
469-
470-
impl<T1: ToStableHashKey, T2: ToStableHashKey> ToStableHashKey for (T1, T2) {
471-
type KeyType = (T1::KeyType, T2::KeyType);
472-
#[inline]
473-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> Self::KeyType {
474-
(self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx))
475-
}
476-
}
477-
478462
impl StableHash for bool {
479463
#[inline]
480464
fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {

compiler/rustc_hir/src/def.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::fmt::Debug;
44

55
use rustc_ast as ast;
66
use rustc_ast::NodeId;
7-
use rustc_data_structures::stable_hasher::ToStableHashKey;
87
use rustc_data_structures::unord::UnordMap;
98
use rustc_error_messages::{DiagArgValue, IntoDiagArg};
109
use rustc_macros::{Decodable, Encodable, StableHash};
@@ -712,15 +711,6 @@ impl IntoDiagArg for Namespace {
712711
}
713712
}
714713

715-
impl ToStableHashKey for Namespace {
716-
type KeyType = Namespace;
717-
718-
#[inline]
719-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Namespace {
720-
*self
721-
}
722-
}
723-
724714
/// Just a helper ‒ separate structure for each namespace.
725715
#[derive(Copy, Clone, Default, Debug, StableHash)]
726716
pub struct PerNS<T> {

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,7 @@
1-
use rustc_data_structures::stable_hasher::{
2-
StableHash, StableHashCtxt, StableHasher, ToStableHashKey,
3-
};
4-
use rustc_span::def_id::DefPathHash;
1+
use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher};
52

63
use crate::HashIgnoredAttrId;
7-
use crate::hir::{
8-
AttributeMap, BodyId, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
9-
};
10-
use crate::hir_id::ItemLocalId;
11-
12-
impl ToStableHashKey for BodyId {
13-
type KeyType = (DefPathHash, ItemLocalId);
14-
15-
#[inline]
16-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
17-
let BodyId { hir_id } = *self;
18-
hir_id.to_stable_hash_key(hcx)
19-
}
20-
}
21-
22-
impl ToStableHashKey for ItemId {
23-
type KeyType = DefPathHash;
24-
25-
#[inline]
26-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> DefPathHash {
27-
self.owner_id.def_id.to_stable_hash_key(hcx)
28-
}
29-
}
30-
31-
impl ToStableHashKey for TraitItemId {
32-
type KeyType = DefPathHash;
33-
34-
#[inline]
35-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> DefPathHash {
36-
self.owner_id.def_id.to_stable_hash_key(hcx)
37-
}
38-
}
39-
40-
impl ToStableHashKey for ImplItemId {
41-
type KeyType = DefPathHash;
42-
43-
#[inline]
44-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> DefPathHash {
45-
self.owner_id.def_id.to_stable_hash_key(hcx)
46-
}
47-
}
48-
49-
impl ToStableHashKey for ForeignItemId {
50-
type KeyType = DefPathHash;
51-
52-
#[inline]
53-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> DefPathHash {
54-
self.owner_id.def_id.to_stable_hash_key(hcx)
55-
}
56-
}
4+
use crate::hir::{AttributeMap, OwnerNodes};
575

586
// The following implementations of StableHash for `ItemId`, `TraitItemId`, and
597
// `ImplItemId` deserve special attention. Normally we do not hash `NodeId`s within

compiler/rustc_hir_id/src/lib.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,3 @@ pub const CRATE_HIR_ID: HirId =
176176
HirId { owner: OwnerId { def_id: CRATE_DEF_ID }, local_id: ItemLocalId::ZERO };
177177

178178
pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };
179-
180-
impl ToStableHashKey for HirId {
181-
type KeyType = (DefPathHash, ItemLocalId);
182-
183-
#[inline]
184-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
185-
let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx);
186-
(def_path_hash, self.local_id)
187-
}
188-
}
189-
190-
impl ToStableHashKey for ItemLocalId {
191-
type KeyType = ItemLocalId;
192-
193-
#[inline]
194-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> ItemLocalId {
195-
*self
196-
}
197-
}

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use std::fmt::Display;
33

44
use rustc_data_structures::fx::FxIndexSet;
55
use rustc_data_structures::stable_hasher::{
6-
StableCompare, StableHash, StableHashCtxt, StableHasher, ToStableHashKey,
6+
StableCompare, StableHash, StableHashCtxt, StableHasher,
77
};
88
use rustc_error_messages::{DiagArgValue, IntoDiagArg};
9-
use rustc_hir_id::{HirId, ItemLocalId};
9+
use rustc_hir_id::HirId;
1010
use rustc_macros::{Decodable, Encodable, StableHash};
11-
use rustc_span::def_id::DefPathHash;
1211
pub use rustc_span::edition::Edition;
1312
use rustc_span::{AttrId, Ident, Symbol, sym};
1413
use serde::{Deserialize, Serialize};
@@ -154,23 +153,6 @@ impl StableHash for LintExpectationId {
154153
}
155154
}
156155

157-
impl ToStableHashKey for LintExpectationId {
158-
type KeyType = (DefPathHash, ItemLocalId, u16, u16);
159-
160-
#[inline]
161-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> Self::KeyType {
162-
match self {
163-
LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
164-
let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx);
165-
(def_path_hash, lint_idx, *attr_index, *lint_index)
166-
}
167-
_ => {
168-
unreachable!("StableHash should only be called for a filled `LintExpectationId`")
169-
}
170-
}
171-
}
172-
}
173-
174156
/// Setting for how to handle a lint.
175157
///
176158
/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
@@ -623,15 +605,6 @@ impl StableHash for LintId {
623605
}
624606
}
625607

626-
impl ToStableHashKey for LintId {
627-
type KeyType = &'static str;
628-
629-
#[inline]
630-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> &'static str {
631-
self.lint_name_raw()
632-
}
633-
}
634-
635608
impl StableCompare for LintId {
636609
const CAN_USE_UNSTABLE_SORT: bool = true;
637610

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use std::fmt;
5151
use std::hash::Hash;
5252

5353
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
54-
use rustc_data_structures::stable_hasher::{StableHasher, StableOrd, ToStableHashKey};
54+
use rustc_data_structures::stable_hasher::{StableHasher, StableOrd};
5555
use rustc_hir::def_id::DefId;
5656
use rustc_hir::definitions::DefPathHash;
5757
use rustc_macros::{Decodable, Encodable, StableHash};
@@ -231,13 +231,7 @@ impl WorkProductId {
231231
WorkProductId { hash: hasher.finish() }
232232
}
233233
}
234-
impl ToStableHashKey for WorkProductId {
235-
type KeyType = Fingerprint;
236-
#[inline]
237-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
238-
self.hash
239-
}
240-
}
234+
241235
impl StableOrd for WorkProductId {
242236
// Fingerprint can use unstable (just a tuple of `u64`s), so WorkProductId can as well
243237
const CAN_USE_UNSTABLE_SORT: bool = true;

compiler/rustc_middle/src/ty/impls_ty.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ use std::ptr;
77
use rustc_data_structures::fingerprint::Fingerprint;
88
use rustc_data_structures::fx::FxHashMap;
99
use rustc_data_structures::stable_hasher::{
10-
HashingControls, StableHash, StableHashCtxt, StableHasher, ToStableHashKey,
10+
HashingControls, StableHash, StableHashCtxt, StableHasher,
1111
};
1212
use tracing::trace;
1313

14-
use crate::middle::region;
1514
use crate::{mir, ty};
1615

1716
impl<'tcx, H, T> StableHash for &'tcx ty::list::RawList<H, T>
@@ -45,20 +44,6 @@ where
4544
}
4645
}
4746

48-
impl<'tcx, H, T> ToStableHashKey for &'tcx ty::list::RawList<H, T>
49-
where
50-
T: StableHash,
51-
{
52-
type KeyType = Fingerprint;
53-
54-
#[inline]
55-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> Fingerprint {
56-
let mut hasher = StableHasher::new();
57-
self.stable_hash(hcx, &mut hasher);
58-
hasher.finish()
59-
}
60-
}
61-
6247
impl<'tcx> StableHash for ty::GenericArg<'tcx> {
6348
fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
6449
self.kind().stable_hash(hcx, hasher);
@@ -81,12 +66,3 @@ impl StableHash for mir::interpret::CtfeProvenance {
8166
self.into_parts().stable_hash(hcx, hasher);
8267
}
8368
}
84-
85-
impl ToStableHashKey for region::Scope {
86-
type KeyType = region::Scope;
87-
88-
#[inline]
89-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> region::Scope {
90-
*self
91-
}
92-
}

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{cmp, fs, iter};
1414

1515
use externs::{ExternOpt, split_extern_opt};
1616
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
17-
use rustc_data_structures::stable_hasher::{StableHasher, StableOrd, ToStableHashKey};
17+
use rustc_data_structures::stable_hasher::{StableHasher, StableOrd};
1818
use rustc_errors::emitter::HumanReadableErrorType;
1919
use rustc_errors::{ColorConfig, DiagCtxtFlags};
2020
use rustc_feature::UnstableFeatures;
@@ -628,23 +628,13 @@ macro_rules! define_output_types {
628628
)*
629629
}
630630

631-
632631
impl StableOrd for OutputType {
633632
const CAN_USE_UNSTABLE_SORT: bool = true;
634633

635634
// Trivial C-Style enums have a stable sort order across compilation sessions.
636635
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
637636
}
638637

639-
impl ToStableHashKey for OutputType {
640-
type KeyType = Self;
641-
642-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
643-
*self
644-
}
645-
}
646-
647-
648638
impl OutputType {
649639
pub fn iter_all() -> impl Iterator<Item = OutputType> {
650640
static ALL_VARIANTS: &[OutputType] = &[

compiler/rustc_span/src/def_id.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -465,24 +465,6 @@ impl ToStableHashKey for LocalDefId {
465465
}
466466
}
467467

468-
impl ToStableHashKey for CrateNum {
469-
type KeyType = DefPathHash;
470-
471-
#[inline]
472-
fn to_stable_hash_key<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx) -> DefPathHash {
473-
self.as_def_id().to_stable_hash_key(hcx)
474-
}
475-
}
476-
477-
impl ToStableHashKey for DefPathHash {
478-
type KeyType = DefPathHash;
479-
480-
#[inline]
481-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> DefPathHash {
482-
*self
483-
}
484-
}
485-
486468
macro_rules! typed_def_id {
487469
($Name:ident, $LocalName:ident) => {
488470
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)]

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{fmt, str};
88
use rustc_arena::DroplessArena;
99
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1010
use rustc_data_structures::stable_hasher::{
11-
StableCompare, StableHash, StableHashCtxt, StableHasher, ToStableHashKey,
11+
StableCompare, StableHash, StableHashCtxt, StableHasher,
1212
};
1313
use rustc_data_structures::sync::Lock;
1414
use rustc_macros::{Decodable, Encodable, StableHash, symbols};
@@ -2642,14 +2642,6 @@ impl StableHash for Symbol {
26422642
}
26432643
}
26442644

2645-
impl ToStableHashKey for Symbol {
2646-
type KeyType = String;
2647-
#[inline]
2648-
fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> String {
2649-
self.as_str().to_string()
2650-
}
2651-
}
2652-
26532645
impl StableCompare for Symbol {
26542646
const CAN_USE_UNSTABLE_SORT: bool = true;
26552647

0 commit comments

Comments
 (0)