Skip to content

Commit 795a1d3

Browse files
committed
Remove HashStable impl for [hir::Attribute].
This impl skips over a handful of attributes as if they aren't there. This skipping originated all the way back in #36025, and was extended a couple of times, e.g. in #36370. Those PRs don't have any explanation of why the skipping exists. Removing the impl (and falling back to the default impl for `[T]`) doesn't seem to have any effects.
1 parent a92a99e commit 795a1d3

1 file changed

Lines changed: 0 additions & 41 deletions

File tree

compiler/rustc_middle/src/ich/impls_syntax.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
44
use rustc_ast as ast;
55
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6-
use rustc_hir as hir;
7-
use rustc_span::{Symbol, sym};
8-
use smallvec::SmallVec;
96

107
use super::StableHashingContext;
118

@@ -16,44 +13,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
1613
}
1714
}
1815

19-
impl<'a> HashStable<StableHashingContext<'a>> for [hir::Attribute] {
20-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
21-
if self.is_empty() {
22-
self.len().hash_stable(hcx, hasher);
23-
return;
24-
}
25-
26-
// Some attributes are always ignored during hashing.
27-
let filtered: SmallVec<[&hir::Attribute; 8]> = self
28-
.iter()
29-
.filter(|attr| {
30-
attr.is_doc_comment().is_none()
31-
// FIXME(jdonszelmann) have a better way to handle ignored attrs
32-
&& !attr.name().is_some_and(|ident| is_ignored_attr(ident))
33-
})
34-
.collect();
35-
36-
filtered.len().hash_stable(hcx, hasher);
37-
for attr in filtered {
38-
attr.hash_stable(hcx, hasher);
39-
}
40-
}
41-
}
42-
43-
#[inline]
44-
fn is_ignored_attr(name: Symbol) -> bool {
45-
const IGNORED_ATTRIBUTES: &[Symbol] = &[
46-
sym::cfg_trace, // FIXME(#138844) should this really be ignored?
47-
sym::rustc_if_this_changed,
48-
sym::rustc_then_this_would_need,
49-
sym::rustc_clean,
50-
sym::rustc_partition_reused,
51-
sym::rustc_partition_codegened,
52-
sym::rustc_expected_cgu_reuse,
53-
];
54-
IGNORED_ATTRIBUTES.contains(&name)
55-
}
56-
5716
impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::Features {
5817
fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
5918
// Unfortunately we cannot exhaustively list fields here, since the

0 commit comments

Comments
 (0)