Skip to content

Commit 171b6e3

Browse files
committed
Update clippy
1 parent 378fc6e commit 171b6e3

39 files changed

+527
-205
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ matrix:
8585
allow_failures:
8686
- os: windows
8787
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true
88+
- os: osx # run base tests on both platforms
89+
env: BASE_TESTS=true
8890
# prevent these jobs with default env vars
8991
exclude:
9092
- os: linux

CHANGELOG.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,45 @@ document.
66

77
## Unreleased / In Rust Beta or Nightly
88

9-
[72da101...master](https://github.com/rust-lang/rust-clippy/compare/72da101...master)
9+
[3aea860...master](https://github.com/rust-lang/rust-clippy/compare/3aea860...master)
1010

11-
## Rust 1.38
11+
## Rust 1.39
1212

1313
Current Beta
1414

15-
[e3cb40e...72da101](https://github.com/rust-lang/rust-clippy/compare/e3cb40e...72da101)
15+
## Rust 1.38
16+
17+
Current stable, released 2019-09-26
18+
19+
[e3cb40e...3aea860](https://github.com/rust-lang/rust-clippy/compare/e3cb40e...3aea860)
20+
21+
* New Lints:
22+
* [`main_recursion`] [#4203](https://github.com/rust-lang/rust-clippy/pull/4203)
23+
* [`inherent_to_string`] [#4259](https://github.com/rust-lang/rust-clippy/pull/4259)
24+
* [`inherent_to_string_shadow_display`] [#4259](https://github.com/rust-lang/rust-clippy/pull/4259)
25+
* [`type_repetition_in_bounds`] [#3766](https://github.com/rust-lang/rust-clippy/pull/3766)
26+
* [`try_err`] [#4222](https://github.com/rust-lang/rust-clippy/pull/4222)
27+
* Move `{unnnecessary,panicking}_unwrap` out of nursery [#4307](https://github.com/rust-lang/rust-clippy/pull/4307)
28+
* Extend the `use_self` lint to suggest uses of `Self::Variant` [#4308](https://github.com/rust-lang/rust-clippy/pull/4308)
29+
* Improve suggestion for needless return [#4262](https://github.com/rust-lang/rust-clippy/pull/4262)
30+
* Add auto-fixable suggestion for `let_unit` [#4337](https://github.com/rust-lang/rust-clippy/pull/4337)
31+
* Fix false positive in `pub_enum_variant_names` and `enum_variant_names` [#4345](https://github.com/rust-lang/rust-clippy/pull/4345)
32+
* Fix false positive in `cast_ptr_alignment` [#4257](https://github.com/rust-lang/rust-clippy/pull/4257)
33+
* Fix false positive in `string_lit_as_bytes` [#4233](https://github.com/rust-lang/rust-clippy/pull/4233)
34+
* Fix false positive in `needless_lifetimes` [#4266](https://github.com/rust-lang/rust-clippy/pull/4266)
35+
* Fix false positive in `float_cmp` [#4275](https://github.com/rust-lang/rust-clippy/pull/4275)
36+
* Fix false positives in `needless_return` [#4274](https://github.com/rust-lang/rust-clippy/pull/4274)
37+
* Fix false negative in `match_same_arms` [#4246](https://github.com/rust-lang/rust-clippy/pull/4246)
38+
* Fix incorrect suggestion for `needless_bool` [#4335](https://github.com/rust-lang/rust-clippy/pull/4335)
39+
* Improve suggestion for `cast_ptr_alignment` [#4257](https://github.com/rust-lang/rust-clippy/pull/4257)
40+
* Improve suggestion for `single_char_literal` [#4361](https://github.com/rust-lang/rust-clippy/pull/4361)
41+
* Improve suggestion for `len_zero` [#4314](https://github.com/rust-lang/rust-clippy/pull/4314)
42+
* Fix ICE in `implicit_hasher` [#4268](https://github.com/rust-lang/rust-clippy/pull/4268)
43+
* Fix allow bug in `trivially_copy_pass_by_ref` [#4250](https://github.com/rust-lang/rust-clippy/pull/4250)
1644

1745
## Rust 1.37
1846

19-
Current stable, released 2019-08-15
47+
Released 2019-08-15
2048

2149
[082cfa7...e3cb40e](https://github.com/rust-lang/rust-clippy/compare/082cfa7...e3cb40e)
2250

@@ -1190,6 +1218,7 @@ Released 2018-09-13
11901218
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
11911219
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
11921220
[`unneeded_field_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
1221+
[`unneeded_wildcard_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_wildcard_pattern
11931222
[`unreadable_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal
11941223
[`unsafe_removed_from_name`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_removed_from_name
11951224
[`unsafe_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_vector_initialization

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
4646

4747
[dev-dependencies]
4848
cargo_metadata = "0.8.0"
49-
compiletest_rs = { version = "0.3.22", features = ["tmp"] }
49+
compiletest_rs = { version = "0.3.23", features = ["tmp"] }
5050
lazy_static = "1.0"
5151
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
5252
serde = { version = "1.0", features = ["derive"] }

README.md

Lines changed: 1 addition & 1 deletion
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 315 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 316 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

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ impl<'tcx> Visitor<'tcx> for CCHelper {
112112
walk_expr(self, e);
113113
match e.node {
114114
ExprKind::Match(_, ref arms, _) => {
115-
let arms_n: u64 = arms.iter().map(|arm| arm.pats.len() as u64).sum();
116-
if arms_n > 1 {
115+
if arms.len() > 1 {
117116
self.cc += 1;
118117
}
119118
self.cc += arms.iter().filter(|arm| arm.guard.is_some()).count() as u64;

clippy_lints/src/copies.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) {
193193
(min_index..=max_index).all(|index| arms[index].guard.is_none()) &&
194194
SpanlessEq::new(cx).eq_expr(&lhs.body, &rhs.body) &&
195195
// all patterns should have the same bindings
196-
same_bindings(cx, &bindings(cx, &lhs.pats[0]), &bindings(cx, &rhs.pats[0]))
196+
same_bindings(cx, &bindings(cx, &lhs.pat), &bindings(cx, &rhs.pat))
197197
};
198198

199199
let indexed_arms: Vec<(usize, &Arm)> = arms.iter().enumerate().collect();
@@ -213,27 +213,22 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) {
213213
// span for the whole pattern, the suggestion is only shown when there is only
214214
// one pattern. The user should know about `|` if they are already using it…
215215

216-
if i.pats.len() == 1 && j.pats.len() == 1 {
217-
let lhs = snippet(cx, i.pats[0].span, "<pat1>");
218-
let rhs = snippet(cx, j.pats[0].span, "<pat2>");
219-
220-
if let PatKind::Wild = j.pats[0].node {
221-
// if the last arm is _, then i could be integrated into _
222-
// note that i.pats[0] cannot be _, because that would mean that we're
223-
// hiding all the subsequent arms, and rust won't compile
224-
db.span_note(
225-
i.body.span,
226-
&format!(
227-
"`{}` has the same arm body as the `_` wildcard, consider removing it`",
228-
lhs
229-
),
230-
);
231-
} else {
232-
db.span_help(
233-
i.pats[0].span,
234-
&format!("consider refactoring into `{} | {}`", lhs, rhs),
235-
);
236-
}
216+
let lhs = snippet(cx, i.pat.span, "<pat1>");
217+
let rhs = snippet(cx, j.pat.span, "<pat2>");
218+
219+
if let PatKind::Wild = j.pat.node {
220+
// if the last arm is _, then i could be integrated into _
221+
// note that i.pat cannot be _, because that would mean that we're
222+
// hiding all the subsequent arms, and rust won't compile
223+
db.span_note(
224+
i.body.span,
225+
&format!(
226+
"`{}` has the same arm body as the `_` wildcard, consider removing it`",
227+
lhs
228+
),
229+
);
230+
} else {
231+
db.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs));
237232
}
238233
},
239234
);

clippy_lints/src/eval_order_dependence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct DivergenceVisitor<'a, 'tcx> {
101101
impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
102102
fn maybe_walk_expr(&mut self, e: &'tcx Expr) {
103103
match e.node {
104-
ExprKind::Closure(.., _) => {},
104+
ExprKind::Closure(..) => {},
105105
ExprKind::Match(ref e, ref arms, _) => {
106106
self.visit_expr(e);
107107
for arm in arms {

clippy_lints/src/format.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ fn on_argumentv1_new<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, arm
8484
if let ExprKind::Path(ref qpath) = args[1].node;
8585
if let Some(did) = resolve_node(cx, qpath, args[1].hir_id).opt_def_id();
8686
if match_def_path(cx, did, &paths::DISPLAY_FMT_METHOD);
87-
if arms[0].pats.len() == 1;
8887
// check `(arg0,)` in match block
89-
if let PatKind::Tuple(ref pats, None) = arms[0].pats[0].node;
88+
if let PatKind::Tuple(ref pats, None) = arms[0].pat.node;
9089
if pats.len() == 1;
9190
then {
9291
let ty = walk_ptrs_ty(cx.tables.pat_ty(&pats[0]));

clippy_lints/src/infallible_destructuring_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InfallibleDestructingMatch {
4747
if_chain! {
4848
if let Some(ref expr) = local.init;
4949
if let ExprKind::Match(ref target, ref arms, MatchSource::Normal) = expr.node;
50-
if arms.len() == 1 && arms[0].pats.len() == 1 && arms[0].guard.is_none();
51-
if let PatKind::TupleStruct(QPath::Resolved(None, ref variant_name), ref args, _) = arms[0].pats[0].node;
50+
if arms.len() == 1 && arms[0].guard.is_none();
51+
if let PatKind::TupleStruct(QPath::Resolved(None, ref variant_name), ref args, _) = arms[0].pat.node;
5252
if args.len() == 1;
5353
if let Some(arg) = get_arg_name(&args[0]);
5454
let body = remove_blocks(&arms[0].body);

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
828828
misc_early::REDUNDANT_CLOSURE_CALL,
829829
misc_early::REDUNDANT_PATTERN,
830830
misc_early::UNNEEDED_FIELD_PATTERN,
831+
misc_early::UNNEEDED_WILDCARD_PATTERN,
831832
misc_early::ZERO_PREFIXED_LITERAL,
832833
mut_reference::UNNECESSARY_MUT_PASSED,
833834
mutex_atomic::MUTEX_ATOMIC,
@@ -1047,6 +1048,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
10471048
methods::USELESS_ASREF,
10481049
misc::SHORT_CIRCUIT_STATEMENT,
10491050
misc_early::REDUNDANT_CLOSURE_CALL,
1051+
misc_early::UNNEEDED_WILDCARD_PATTERN,
10501052
misc_early::ZERO_PREFIXED_LITERAL,
10511053
needless_bool::BOOL_COMPARISON,
10521054
needless_bool::NEEDLESS_BOOL,

0 commit comments

Comments
 (0)