Skip to content

Commit 27ac647

Browse files
committed
Use discriminant instead of stable_hash
1 parent e027b6b commit 27ac647

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

clippy_utils/src/hir_utils.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::consts::{constant_context, constant_simple};
22
use crate::differing_macro_contexts;
33
use crate::source::snippet_opt;
44
use rustc_ast::ast::InlineAsmTemplatePiece;
5-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5+
use rustc_data_structures::stable_hasher::StableHasher;
66
use rustc_hir::def::Res;
77
use rustc_hir::HirIdMap;
88
use rustc_hir::{
@@ -12,7 +12,6 @@ use rustc_hir::{
1212
};
1313
use rustc_lexer::{tokenize, TokenKind};
1414
use rustc_lint::LateContext;
15-
use rustc_middle::ich::StableHashingContextProvider;
1615
use rustc_middle::ty::TypeckResults;
1716
use rustc_span::Symbol;
1817
use std::hash::Hash;
@@ -571,17 +570,15 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
571570
self.hash_expr(r);
572571
},
573572
ExprKind::AssignOp(ref o, l, r) => {
574-
o.node
575-
.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
573+
std::mem::discriminant(&o.node).hash(&mut self.s);
576574
self.hash_expr(l);
577575
self.hash_expr(r);
578576
},
579577
ExprKind::Block(b, _) => {
580578
self.hash_block(b);
581579
},
582580
ExprKind::Binary(op, l, r) => {
583-
op.node
584-
.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
581+
std::mem::discriminant(&op.node).hash(&mut self.s);
585582
self.hash_expr(l);
586583
self.hash_expr(r);
587584
},
@@ -736,7 +733,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
736733
self.hash_exprs(v);
737734
},
738735
ExprKind::Unary(lop, le) => {
739-
lop.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
736+
std::mem::discriminant(&lop).hash(&mut self.s);
740737
self.hash_expr(le);
741738
},
742739
}
@@ -761,7 +758,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
761758
self.hash_name(path.ident.name);
762759
},
763760
QPath::LangItem(lang_item, ..) => {
764-
lang_item.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
761+
std::mem::discriminant(&lang_item).hash(&mut self.s);
765762
},
766763
}
767764
// self.maybe_typeck_results.unwrap().qpath_res(p, id).hash(&mut self.s);
@@ -771,7 +768,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
771768
std::mem::discriminant(&pat.kind).hash(&mut self.s);
772769
match pat.kind {
773770
PatKind::Binding(ann, _, _, pat) => {
774-
ann.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
771+
std::mem::discriminant(&ann).hash(&mut self.s);
775772
if let Some(pat) = pat {
776773
self.hash_pat(pat);
777774
}
@@ -791,11 +788,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
791788
if let Some(e) = e {
792789
self.hash_expr(e);
793790
}
794-
i.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
791+
std::mem::discriminant(&i).hash(&mut self.s);
795792
},
796-
PatKind::Ref(pat, m) => {
793+
PatKind::Ref(pat, mu) => {
797794
self.hash_pat(pat);
798-
m.hash(&mut self.s);
795+
std::mem::discriminant(&mu).hash(&mut self.s);
799796
},
800797
PatKind::Slice(l, m, r) => {
801798
for pat in l {

0 commit comments

Comments
 (0)