Skip to content

Commit 2b8c59f

Browse files
committed
Update clippy
1 parent 7830b0e commit 2b8c59f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+526
-199
lines changed

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ matrix:
5151
# We don't want to run these always because they go towards
5252
# the build limit within the Travis rust-lang account.
5353
# The jobs are approximately sorted by execution time
54-
# disabled cargo and rls integration test due to https://github.com/rust-lang/rust-clippy/issues/4121
55-
#- env: INTEGRATION=rust-lang/cargo
56-
# if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
54+
- env: INTEGRATION=rust-lang/cargo
55+
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
5756
- env: INTEGRATION=rust-lang-nursery/chalk
5857
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
59-
#- env: INTEGRATION=rust-lang/rls
60-
# if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
58+
- env: INTEGRATION=rust-lang/rls
59+
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
6160
- env: INTEGRATION=Geal/nom
6261
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
6362
- env: INTEGRATION=rust-lang/rustfmt

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ Released 2018-09-13
11341134
[`transmuting_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmuting_null
11351135
[`trivial_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
11361136
[`trivially_copy_pass_by_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
1137+
[`try_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#try_err
11371138
[`type_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
11381139
[`unicode_not_nfc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unicode_not_nfc
11391140
[`unimplemented`]: https://rust-lang.github.io/rust-clippy/master/index.html#unimplemented

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are 305 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 306 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1212

@@ -171,7 +171,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
171171
Copyright 2014-2019 The Rust Project Developers
172172

173173
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
174-
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
175-
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
174+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
175+
<LICENSE-MIT or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)>, at your
176176
option. All files in the project carrying such notice may not be
177177
copied, modified, or distributed except according to those terms.

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
118118
span: Span,
119119
hir_id: HirId,
120120
) {
121-
let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
121+
let def_id = cx.tcx.hir().local_def_id(hir_id);
122122
if !cx.tcx.has_attr(def_id, sym!(test)) {
123123
self.check(cx, body, span);
124124
}

clippy_lints/src/copies.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::utils::{get_parent_expr, higher, in_macro_or_desugar, snippet, span_lint_and_then, span_note_and_lint};
1+
use crate::utils::{
2+
get_parent_expr, higher, in_macro_or_desugar, same_tys, snippet, span_lint_and_then, span_note_and_lint,
3+
};
24
use crate::utils::{SpanlessEq, SpanlessHash};
35
use rustc::hir::*;
46
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -165,7 +167,18 @@ fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr]) {
165167
}
166168

167169
/// Implementation of `MATCH_SAME_ARMS`.
168-
fn lint_match_arms(cx: &LateContext<'_, '_>, expr: &Expr) {
170+
fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) {
171+
fn same_bindings<'tcx>(
172+
cx: &LateContext<'_, 'tcx>,
173+
lhs: &FxHashMap<LocalInternedString, Ty<'tcx>>,
174+
rhs: &FxHashMap<LocalInternedString, Ty<'tcx>>,
175+
) -> bool {
176+
lhs.len() == rhs.len()
177+
&& lhs
178+
.iter()
179+
.all(|(name, l_ty)| rhs.get(name).map_or(false, |r_ty| same_tys(cx, l_ty, r_ty)))
180+
}
181+
169182
if let ExprKind::Match(_, ref arms, MatchSource::Normal) = expr.node {
170183
let hash = |&(_, arm): &(usize, &Arm)| -> u64 {
171184
let mut h = SpanlessHash::new(cx, cx.tables);
@@ -176,12 +189,13 @@ fn lint_match_arms(cx: &LateContext<'_, '_>, expr: &Expr) {
176189
let eq = |&(lindex, lhs): &(usize, &Arm), &(rindex, rhs): &(usize, &Arm)| -> bool {
177190
let min_index = usize::min(lindex, rindex);
178191
let max_index = usize::max(lindex, rindex);
192+
179193
// Arms with a guard are ignored, those can’t always be merged together
180194
// This is also the case for arms in-between each there is an arm with a guard
181195
(min_index..=max_index).all(|index| arms[index].guard.is_none()) &&
182196
SpanlessEq::new(cx).eq_expr(&lhs.body, &rhs.body) &&
183197
// all patterns should have the same bindings
184-
bindings(cx, &lhs.pats[0]) == bindings(cx, &rhs.pats[0])
198+
same_bindings(cx, &bindings(cx, &lhs.pats[0]), &bindings(cx, &rhs.pats[0]))
185199
};
186200

187201
let indexed_arms: Vec<(usize, &Arm)> = arms.iter().enumerate().collect();

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
3535
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
3636
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
37-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
37+
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
3838

3939
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
4040
span_note_and_lint(

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]);
6767
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
6868
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
6969
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
70-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
70+
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
7171
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7272

7373
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
2727

2828
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
2929
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
30-
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
30+
let did = cx.tcx.hir().local_def_id(item.hir_id);
3131
if let ItemKind::Enum(..) = item.node {
3232
let ty = cx.tcx.type_of(did);
3333
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
7777
too_large_for_stack: self.too_large_for_stack,
7878
};
7979

80-
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
80+
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
8181
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
8282
ExprUseVisitor::new(
8383
&mut v,

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare_lint_pass!(FallibleImplFrom => [FALLIBLE_IMPL_FROM]);
3333
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
3434
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
3535
// check for `impl From<???> for ..`
36-
let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
36+
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
3737
if_chain! {
3838
if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
3939
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
@@ -95,7 +95,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
9595
then {
9696
// check the body for `begin_panic` or `unwrap`
9797
let body = cx.tcx.hir().body(body_id);
98-
let impl_item_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.id.hir_id);
98+
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id);
9999
let mut fpu = FindPanicUnwrap {
100100
lcx: cx,
101101
tables: cx.tcx.typeck_tables_of(impl_item_def_id),

0 commit comments

Comments
 (0)