Skip to content

Commit 2a1c0f9

Browse files
flip1995tesuji
authored andcommitted
Update Clippy
1 parent 1153b93 commit 2a1c0f9

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

ci/integration-tests.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
#!/usr/bin/env bash
12
set -x
3+
4+
if [[ -z "$INTEGRATION" ]]; then
5+
exit 0
6+
fi
7+
28
rm ~/.cargo/bin/cargo-clippy
3-
cargo install --force --path .
9+
cargo install --force --debug --path .
410

511
echo "Running integration test for crate ${INTEGRATION}"
612

7-
git clone --depth=1 https://github.com/${INTEGRATION}.git checkout
8-
cd checkout
13+
git clone --depth=1 "https://github.com/${INTEGRATION}.git" checkout
14+
cd checkout || exit 1
915

10-
function check() {
1116
# run clippy on a project, try to be verbose and trigger as many warnings as possible for greater coverage
12-
RUST_BACKTRACE=full cargo clippy --all-targets --all-features -- --cap-lints warn -W clippy::pedantic -W clippy::nursery &> clippy_output
13-
cat clippy_output
14-
! cat clippy_output | grep -q "internal compiler error\|query stack during panic\|E0463"
15-
if [[ $? != 0 ]]; then
16-
return 1
17-
fi
18-
}
17+
RUST_BACKTRACE=full \
18+
cargo clippy \
19+
--all-targets \
20+
--all-features \
21+
-- --cap-lints warn -W clippy::pedantic -W clippy::nursery \
22+
2>& 1 \
23+
| tee clippy_output
1924

20-
case ${INTEGRATION} in
21-
*)
22-
check
23-
;;
24-
esac
25+
if grep -q "internal compiler error\|query stack during panic\|E0463" clippy_output; then
26+
exit 1
27+
fi

clippy_lints/src/utils/hir_utils.rs

Lines changed: 12 additions & 9 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,19 +349,19 @@ 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

363-
pub fn finish(&self) -> u64 {
364+
pub fn finish(self) -> u64 {
364365
self.s.finish()
365366
}
366367

@@ -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.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
},
@@ -460,7 +463,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
460463
},
461464
ExprKind::InlineAsm(..) | ExprKind::Err => {},
462465
ExprKind::Lit(ref l) => {
463-
l.hash(&mut self.s);
466+
l.node.hash(&mut self.s);
464467
},
465468
ExprKind::Loop(ref b, ref i, _) => {
466469
self.hash_block(b);
@@ -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)