Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5abb60b

Browse files
committedOct 22, 2019
Use StableHasher in SpanlessHasher
1 parent ef18ece commit 5abb60b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎clippy_lints/src/utils/hir_utils.rs

+10-7
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,17 @@ 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
416+
.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
415417
self.hash_expr(l);
416418
self.hash_expr(r);
417419
},
418420
ExprKind::Block(ref b, _) => {
419421
self.hash_block(b);
420422
},
421423
ExprKind::Binary(op, ref l, ref r) => {
422-
op.node.hash(&mut self.s);
424+
op.node
425+
.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
423426
self.hash_expr(l);
424427
self.hash_expr(r);
425428
},
@@ -519,7 +522,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
519522
self.hash_exprs(v);
520523
},
521524
ExprKind::Unary(lop, ref le) => {
522-
lop.hash(&mut self.s);
525+
lop.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
523526
self.hash_expr(le);
524527
},
525528
}

0 commit comments

Comments
 (0)
Please sign in to comment.