Skip to content

Commit 882b371

Browse files
committed
Use StableHasher in SpanlessHasher
1 parent ef18ece commit 882b371

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

clippy_lints/src/utils/hir_utils.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ use crate::consts::{constant_context, constant_simple};
22
use crate::utils::differing_macro_contexts;
33
use rustc::hir::ptr::P;
44
use rustc::hir::*;
5+
use rustc::ich::StableHashingContextProvider;
56
use rustc::lint::LateContext;
67
use rustc::ty::TypeckTables;
7-
use std::collections::hash_map::DefaultHasher;
8-
use std::hash::{Hash, Hasher};
8+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9+
use std::hash::Hash;
910
use syntax::ast::Name;
1011

1112
/// Type used to check whether two ast are the same. This is different from the
@@ -348,15 +349,15 @@ pub struct SpanlessHash<'a, 'tcx> {
348349
/// Context used to evaluate constant expressions.
349350
cx: &'a LateContext<'a, 'tcx>,
350351
tables: &'a TypeckTables<'tcx>,
351-
s: DefaultHasher,
352+
s: StableHasher,
352353
}
353354

354355
impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
355356
pub fn new(cx: &'a LateContext<'a, 'tcx>, tables: &'a TypeckTables<'tcx>) -> Self {
356357
Self {
357358
cx,
358359
tables,
359-
s: DefaultHasher::new(),
360+
s: StableHasher::new(),
360361
}
361362
}
362363

@@ -411,15 +412,15 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
411412
self.hash_expr(r);
412413
},
413414
ExprKind::AssignOp(ref o, ref l, ref r) => {
414-
o.node.hash(&mut self.s);
415+
o.node.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
415416
self.hash_expr(l);
416417
self.hash_expr(r);
417418
},
418419
ExprKind::Block(ref b, _) => {
419420
self.hash_block(b);
420421
},
421422
ExprKind::Binary(op, ref l, ref r) => {
422-
op.node.hash(&mut self.s);
423+
op.node.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
423424
self.hash_expr(l);
424425
self.hash_expr(r);
425426
},
@@ -519,7 +520,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
519520
self.hash_exprs(v);
520521
},
521522
ExprKind::Unary(lop, ref le) => {
522-
lop.hash(&mut self.s);
523+
lop.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
523524
self.hash_expr(le);
524525
},
525526
}

0 commit comments

Comments
 (0)