Skip to content

Commit 66da51a

Browse files
committed
Update Clippy
1 parent ee1be93 commit 66da51a

File tree

194 files changed

+2719
-1364
lines changed

Some content is hidden

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

194 files changed

+2719
-1364
lines changed

CHANGELOG.md

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,101 @@ document.
66

77
## Unreleased / In Rust Beta or Nightly
88

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

11-
## Rust 1.39
11+
## Rust 1.41
1212

1313
Current Beta
1414

15+
## Rust 1.40
16+
17+
Current stable, released 2019-12-19
18+
19+
[4e7e71b...c8e3cfb](https://github.com/rust-lang/rust-clippy/compare/4e7e71b...c8e3cfb)
20+
21+
* New Lints:
22+
* [`unneeded_wildcard_pattern`] [#4537](https://github.com/rust-lang/rust-clippy/pull/4537)
23+
* [`needless_doctest_main`] [#4603](https://github.com/rust-lang/rust-clippy/pull/4603)
24+
* [`suspicious_unary_op_formatting`] [#4615](https://github.com/rust-lang/rust-clippy/pull/4615)
25+
* [`debug_assert_with_mut_call`] [#4680](https://github.com/rust-lang/rust-clippy/pull/4680)
26+
* [`unused_self`] [#4619](https://github.com/rust-lang/rust-clippy/pull/4619)
27+
* [`inefficient_to_string`] [#4683](https://github.com/rust-lang/rust-clippy/pull/4683)
28+
* [`must_use_unit`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
29+
* [`must_use_candidate`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
30+
* [`double_must_use`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
31+
* [`comparison_chain`] [#4569](https://github.com/rust-lang/rust-clippy/pull/4569)
32+
* [`unsound_collection_transmute`] [#4592](https://github.com/rust-lang/rust-clippy/pull/4592)
33+
* [`panic`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
34+
* [`unreachable`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
35+
* [`todo`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
36+
* [`option_expect_used`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
37+
* [`result_expect_used`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
38+
* Move `redundant_clone` to perf group [#4509](https://github.com/rust-lang/rust-clippy/pull/4509)
39+
* Move `manual_mul_add` to nursery group [#4736](https://github.com/rust-lang/rust-clippy/pull/4736)
40+
* Expand `unit_cmp` to also work with `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` [#4613](https://github.com/rust-lang/rust-clippy/pull/4613)
41+
* Expand `integer_arithmetic` to also detect mutating arithmetic like `+=` [#4585](https://github.com/rust-lang/rust-clippy/pull/4585)
42+
* Fix false positive in `nonminimal_bool` [#4568](https://github.com/rust-lang/rust-clippy/pull/4568)
43+
* Fix false positive in `missing_safety_doc` [#4611](https://github.com/rust-lang/rust-clippy/pull/4611)
44+
* Fix false positive in `cast_sign_loss` [#4614](https://github.com/rust-lang/rust-clippy/pull/4614)
45+
* Fix false positive in `redundant_clone` [#4509](https://github.com/rust-lang/rust-clippy/pull/4509)
46+
* Fix false positive in `try_err` [#4721](https://github.com/rust-lang/rust-clippy/pull/4721)
47+
* Fix false positive in `toplevel_ref_arg` [#4570](https://github.com/rust-lang/rust-clippy/pull/4570)
48+
* Fix false positive in `multiple_inherent_impl` [#4593](https://github.com/rust-lang/rust-clippy/pull/4593)
49+
* Improve more suggestions and tests in preparation for the unstable `cargo fix --clippy` [#4575](https://github.com/rust-lang/rust-clippy/pull/4575)
50+
* Improve suggestion for `zero_ptr` [#4599](https://github.com/rust-lang/rust-clippy/pull/4599)
51+
* Improve suggestion for `explicit_counter_loop` [#4691](https://github.com/rust-lang/rust-clippy/pull/4691)
52+
* Improve suggestion for `mul_add` [#4602](https://github.com/rust-lang/rust-clippy/pull/4602)
53+
* Improve suggestion for `assertions_on_constants` [#4635](https://github.com/rust-lang/rust-clippy/pull/4635)
54+
* Fix ICE in `use_self` [#4671](https://github.com/rust-lang/rust-clippy/pull/4671)
55+
* Fix ICE when encountering const casts [#4590](https://github.com/rust-lang/rust-clippy/pull/4590)
56+
57+
## Rust 1.39
58+
59+
Released 2019-11-07
60+
61+
[3aea860...4e7e71b](https://github.com/rust-lang/rust-clippy/compare/3aea860...4e7e71b)
62+
63+
* New Lints:
64+
* [`uninit_assumed_init`] [#4479](https://github.com/rust-lang/rust-clippy/pull/4479)
65+
* [`flat_map_identity`] [#4231](https://github.com/rust-lang/rust-clippy/pull/4231)
66+
* [`missing_safety_doc`] [#4535](https://github.com/rust-lang/rust-clippy/pull/4535)
67+
* [`mem_replace_with_uninit`] [#4511](https://github.com/rust-lang/rust-clippy/pull/4511)
68+
* [`suspicious_map`] [#4394](https://github.com/rust-lang/rust-clippy/pull/4394)
69+
* [`option_and_then_some`] [#4386](https://github.com/rust-lang/rust-clippy/pull/4386)
70+
* [`manual_saturating_arithmetic`] [#4498](https://github.com/rust-lang/rust-clippy/pull/4498)
71+
* Deprecate `unused_collect` lint. This is fully covered by rustc's `#[must_use]` on `collect` [#4348](https://github.com/rust-lang/rust-clippy/pull/4348)
72+
* Move `type_repetition_in_bounds` to pedantic group [#4403](https://github.com/rust-lang/rust-clippy/pull/4403)
73+
* Move `cast_lossless` to pedantic group [#4539](https://github.com/rust-lang/rust-clippy/pull/4539)
74+
* `temporary_cstring_as_ptr` now catches more cases [#4425](https://github.com/rust-lang/rust-clippy/pull/4425)
75+
* `use_self` now works in constructors, too [#4525](https://github.com/rust-lang/rust-clippy/pull/4525)
76+
* `cargo_common_metadata` now checks for license files [#4518](https://github.com/rust-lang/rust-clippy/pull/4518)
77+
* `cognitive_complexity` now includes the measured complexity in the warning message [#4469](https://github.com/rust-lang/rust-clippy/pull/4469)
78+
* Fix false positives in `block_in_if_*` lints [#4458](https://github.com/rust-lang/rust-clippy/pull/4458)
79+
* Fix false positive in `cast_lossless` [#4473](https://github.com/rust-lang/rust-clippy/pull/4473)
80+
* Fix false positive in `clone_on_copy` [#4411](https://github.com/rust-lang/rust-clippy/pull/4411)
81+
* Fix false positive in `deref_addrof` [#4487](https://github.com/rust-lang/rust-clippy/pull/4487)
82+
* Fix false positive in `too_many_lines` [#4490](https://github.com/rust-lang/rust-clippy/pull/4490)
83+
* Fix false positive in `new_ret_no_self` [#4365](https://github.com/rust-lang/rust-clippy/pull/4365)
84+
* Fix false positive in `manual_swap` [#4478](https://github.com/rust-lang/rust-clippy/pull/4478)
85+
* Fix false positive in `missing_const_for_fn` [#4450](https://github.com/rust-lang/rust-clippy/pull/4450)
86+
* Fix false positive in `extra_unused_lifetimes` [#4477](https://github.com/rust-lang/rust-clippy/pull/4477)
87+
* Fix false positive in `inherent_to_string` [#4460](https://github.com/rust-lang/rust-clippy/pull/4460)
88+
* Fix false positive in `map_entry` [#4495](https://github.com/rust-lang/rust-clippy/pull/4495)
89+
* Fix false positive in `unused_unit` [#4445](https://github.com/rust-lang/rust-clippy/pull/4445)
90+
* Fix false positive in `redundant_pattern` [#4489](https://github.com/rust-lang/rust-clippy/pull/4489)
91+
* Fix false positive in `wrong_self_convention` [#4369](https://github.com/rust-lang/rust-clippy/pull/4369)
92+
* Improve various suggestions and tests in preparation for the unstable `cargo fix --clippy` [#4558](https://github.com/rust-lang/rust-clippy/pull/4558)
93+
* Improve suggestions for `redundant_pattern_matching` [#4352](https://github.com/rust-lang/rust-clippy/pull/4352)
94+
* Improve suggestions for `explicit_write` [#4544](https://github.com/rust-lang/rust-clippy/pull/4544)
95+
* Improve suggestion for `or_fun_call` [#4522](https://github.com/rust-lang/rust-clippy/pull/4522)
96+
* Improve suggestion for `match_as_ref` [#4446](https://github.com/rust-lang/rust-clippy/pull/4446)
97+
* Improve suggestion for `unnecessary_fold_span` [#4382](https://github.com/rust-lang/rust-clippy/pull/4382)
98+
* Add suggestions for `unseparated_literal_suffix` [#4401](https://github.com/rust-lang/rust-clippy/pull/4401)
99+
* Add suggestions for `char_lit_as_u8` [#4418](https://github.com/rust-lang/rust-clippy/pull/4418)
100+
15101
## Rust 1.38
16102

17-
Current stable, released 2019-09-26
103+
Released 2019-09-26
18104

19105
[e3cb40e...3aea860](https://github.com/rust-lang/rust-clippy/compare/e3cb40e...3aea860)
20106

@@ -1064,6 +1150,7 @@ Released 2018-09-13
10641150
[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
10651151
[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
10661152
[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
1153+
[`let_underscore_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
10671154
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
10681155
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
10691156
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
@@ -1099,6 +1186,7 @@ Released 2018-09-13
10991186
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
11001187
[`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
11011188
[`module_name_repetitions`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
1189+
[`modulo_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_arithmetic
11021190
[`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one
11031191
[`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
11041192
[`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl
@@ -1107,6 +1195,7 @@ Released 2018-09-13
11071195
[`mut_from_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref
11081196
[`mut_mut`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut
11091197
[`mut_range_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_range_bound
1198+
[`mutable_key_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key_type
11101199
[`mutex_atomic`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_atomic
11111200
[`mutex_integer`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer
11121201
[`naive_bytecount`]: https://rust-lang.github.io/rust-clippy/master/index.html#naive_bytecount

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
3838
regex = "1"
3939
semver = "0.9"
4040
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
41-
git2 = { version = "0.10", optional = true }
41+
git2 = { version = "0.11", optional = true }
4242
tempfile = { version = "3.1.0", optional = true }
4343
lazy_static = "1.0"
4444

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 340 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 342 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_dev/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Lint {
5050
name: name.to_lowercase(),
5151
group: group.to_string(),
5252
desc: NL_ESCAPE_RE.replace(&desc.replace("\\\"", "\""), "").to_string(),
53-
deprecation: deprecation.map(std::string::ToString::to_string),
53+
deprecation: deprecation.map(ToString::to_string),
5454
module: module.to_string(),
5555
}
5656
}

clippy_dev/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
22

3-
extern crate clap;
4-
extern crate clippy_dev;
5-
extern crate regex;
6-
73
use clap::{App, Arg, SubCommand};
84
use clippy_dev::*;
95

clippy_dummy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ keywords = ["clippy", "lint", "plugin"]
1414
categories = ["development-tools", "development-tools::cargo-plugins"]
1515

1616
[build-dependencies]
17-
term = "0.5.1"
17+
term = "0.6"

clippy_dummy/build.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
extern crate term;
1+
use term::color::{GREEN, RED, WHITE};
2+
use term::{Attr, Error, Result};
23

34
fn main() {
4-
if let Err(_) = foo() {
5-
eprintln!("error: Clippy is no longer available via crates.io\n");
6-
eprintln!("help: please run `rustup component add clippy` instead");
5+
if foo().is_err() {
6+
eprintln!(
7+
"error: Clippy is no longer available via crates.io\n\n\
8+
help: please run `rustup component add clippy` instead"
9+
);
710
}
811
std::process::exit(1);
912
}
1013

11-
fn foo() -> Result<(), ()> {
12-
let mut t = term::stderr().ok_or(())?;
14+
fn foo() -> Result<()> {
15+
let mut t = term::stderr().ok_or(Error::NotSupported)?;
1316

14-
t.attr(term::Attr::Bold).map_err(|_| ())?;
15-
t.fg(term::color::RED).map_err(|_| ())?;
16-
write!(t, "\nerror: ").map_err(|_| ())?;
17+
t.attr(Attr::Bold)?;
18+
t.fg(RED)?;
19+
write!(t, "\nerror: ")?;
1720

21+
t.reset()?;
22+
t.fg(WHITE)?;
23+
writeln!(t, "Clippy is no longer available via crates.io\n")?;
1824

19-
t.reset().map_err(|_| ())?;
20-
t.fg(term::color::WHITE).map_err(|_| ())?;
21-
writeln!(t, "Clippy is no longer available via crates.io\n").map_err(|_| ())?;
25+
t.attr(Attr::Bold)?;
26+
t.fg(GREEN)?;
27+
write!(t, "help: ")?;
2228

29+
t.reset()?;
30+
t.fg(WHITE)?;
31+
write!(t, "please run `")?;
2332

24-
t.attr(term::Attr::Bold).map_err(|_| ())?;
25-
t.fg(term::color::GREEN).map_err(|_| ())?;
26-
write!(t, "help: ").map_err(|_| ())?;
33+
t.attr(Attr::Bold)?;
34+
write!(t, "rustup component add clippy")?;
2735

36+
t.reset()?;
37+
t.fg(WHITE)?;
38+
writeln!(t, "` instead")?;
2839

29-
t.reset().map_err(|_| ())?;
30-
t.fg(term::color::WHITE).map_err(|_| ())?;
31-
write!(t, "please run `").map_err(|_| ())?;
32-
33-
t.attr(term::Attr::Bold).map_err(|_| ())?;
34-
write!(t, "rustup component add clippy").map_err(|_| ())?;
35-
36-
t.reset().map_err(|_| ())?;
37-
t.fg(term::color::WHITE).map_err(|_| ())?;
38-
writeln!(t, "` instead").map_err(|_| ())?;
39-
40-
t.reset().map_err(|_| ())?;
40+
t.reset()?;
4141
Ok(())
4242
}

clippy_lints/src/approx_const.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ const KNOWN_CONSTS: [(f64, &str, usize); 16] = [
6060
declare_lint_pass!(ApproxConstant => [APPROX_CONSTANT]);
6161

6262
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ApproxConstant {
63-
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
63+
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
6464
if let ExprKind::Lit(lit) = &e.kind {
6565
check_lit(cx, &lit.node, e);
6666
}
6767
}
6868
}
6969

70-
fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr) {
70+
fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr<'_>) {
7171
match *lit {
7272
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
7373
FloatTy::F32 => check_known_consts(cx, e, s, "f32"),
@@ -78,7 +78,7 @@ fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr) {
7878
}
7979
}
8080

81-
fn check_known_consts(cx: &LateContext<'_, '_>, e: &Expr, s: symbol::Symbol, module: &str) {
81+
fn check_known_consts(cx: &LateContext<'_, '_>, e: &Expr<'_>, s: symbol::Symbol, module: &str) {
8282
let s = s.as_str();
8383
if s.parse::<f64>().is_ok() {
8484
for &(constant, name, min_digits) in &KNOWN_CONSTS {

clippy_lints/src/arithmetic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub struct Arithmetic {
5454
impl_lint_pass!(Arithmetic => [INTEGER_ARITHMETIC, FLOAT_ARITHMETIC]);
5555

5656
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
57-
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
57+
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'_>) {
5858
if self.expr_span.is_some() {
5959
return;
6060
}
@@ -107,13 +107,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
107107
}
108108
}
109109

110-
fn check_expr_post(&mut self, _: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
110+
fn check_expr_post(&mut self, _: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'_>) {
111111
if Some(expr.span) == self.expr_span {
112112
self.expr_span = None;
113113
}
114114
}
115115

116-
fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
116+
fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body<'_>) {
117117
let body_owner = cx.tcx.hir().body_owner(body.id());
118118

119119
match cx.tcx.hir().body_owner_kind(body_owner) {
@@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
131131
}
132132
}
133133

134-
fn check_body_post(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
134+
fn check_body_post(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body<'_>) {
135135
let body_owner = cx.tcx.hir().body_owner(body.id());
136136
let body_span = cx.tcx.hir().span(body_owner);
137137

clippy_lints/src/assertions_on_constants.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare_clippy_lint! {
3333
declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
3434

3535
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
36-
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
36+
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
3737
let lint_true = || {
3838
span_help_and_lint(
3939
cx,
@@ -110,7 +110,7 @@ enum AssertKind {
110110
/// ```
111111
///
112112
/// where `message` is any expression and `c` is a constant bool.
113-
fn match_assert_with_message<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option<AssertKind> {
113+
fn match_assert_with_message<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) -> Option<AssertKind> {
114114
if_chain! {
115115
if let ExprKind::Match(ref expr, ref arms, _) = expr.kind;
116116
// matches { let _t = expr; _t }
@@ -124,7 +124,7 @@ fn match_assert_with_message<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx E
124124
if let LitKind::Bool(true) = lit.node;
125125
// arm 1 block
126126
if let ExprKind::Block(ref block, _) = arms[0].body.kind;
127-
if block.stmts.len() == 0;
127+
if block.stmts.is_empty();
128128
if let Some(block_expr) = &block.expr;
129129
if let ExprKind::Block(ref inner_block, _) = block_expr.kind;
130130
if let Some(begin_panic_call) = &inner_block.expr;

0 commit comments

Comments
 (0)