Skip to content

Commit 2d5a21f

Browse files
committed
Auto merge of #95772 - flip1995:clippyup, r=Manishearth,flip1995
Update Clippy r? `@Manishearth`
2 parents e4f5b15 + b590d5c commit 2d5a21f

File tree

178 files changed

+3117
-1493
lines changed

Some content is hidden

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

178 files changed

+3117
-1493
lines changed

Cargo.lock

+4-7
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,8 @@ dependencies = [
613613

614614
[[package]]
615615
name = "clippy"
616-
version = "0.1.61"
616+
version = "0.1.62"
617617
dependencies = [
618-
"cargo_metadata",
619618
"clippy_lints",
620619
"clippy_utils",
621620
"compiletest_rs",
@@ -642,20 +641,18 @@ dependencies = [
642641
name = "clippy_dev"
643642
version = "0.0.1"
644643
dependencies = [
645-
"bytecount",
646-
"cargo_metadata",
647644
"clap 2.34.0",
648645
"indoc",
649646
"itertools",
650647
"opener",
651-
"regex",
652648
"shell-escape",
649+
"tempfile",
653650
"walkdir",
654651
]
655652

656653
[[package]]
657654
name = "clippy_lints"
658-
version = "0.1.61"
655+
version = "0.1.62"
659656
dependencies = [
660657
"cargo_metadata",
661658
"clippy_utils",
@@ -676,7 +673,7 @@ dependencies = [
676673

677674
[[package]]
678675
name = "clippy_utils"
679-
version = "0.1.61"
676+
version = "0.1.62"
680677
dependencies = [
681678
"arrayvec",
682679
"if_chain",

src/tools/clippy/CHANGELOG.md

+142-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,143 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[0eff589...master](https://github.com/rust-lang/rust-clippy/compare/0eff589...master)
9+
[57b3c4b...master](https://github.com/rust-lang/rust-clippy/compare/57b3c4b...master)
1010

11-
## Rust 1.59 (beta)
11+
## Rust 1.60
1212

13-
Current beta, release 2022-02-24
13+
Current stable, released 2022-04-07
14+
15+
[0eff589...57b3c4b](https://github.com/rust-lang/rust-clippy/compare/0eff589...57b3c4b)
16+
17+
### New Lints
18+
19+
* [`single_char_lifetime_names`]
20+
[#8236](https://github.com/rust-lang/rust-clippy/pull/8236)
21+
* [`iter_overeager_cloned`]
22+
[#8203](https://github.com/rust-lang/rust-clippy/pull/8203)
23+
* [`transmute_undefined_repr`]
24+
[#8398](https://github.com/rust-lang/rust-clippy/pull/8398)
25+
* [`default_union_representation`]
26+
[#8289](https://github.com/rust-lang/rust-clippy/pull/8289)
27+
* [`manual_bits`]
28+
[#8213](https://github.com/rust-lang/rust-clippy/pull/8213)
29+
* [`borrow_as_ptr`]
30+
[#8210](https://github.com/rust-lang/rust-clippy/pull/8210)
31+
32+
### Moves and Deprecations
33+
34+
* Moved [`disallowed_methods`] and [`disallowed_types`] to `style` (now warn-by-default)
35+
[#8261](https://github.com/rust-lang/rust-clippy/pull/8261)
36+
* Rename `ref_in_deref` to [`needless_borrow`]
37+
[#8217](https://github.com/rust-lang/rust-clippy/pull/8217)
38+
* Moved [`mutex_atomic`] to `nursery` (now allow-by-default)
39+
[#8260](https://github.com/rust-lang/rust-clippy/pull/8260)
40+
41+
### Enhancements
42+
43+
* [`ptr_arg`]: Now takes the argument usage into account and lints for mutable references
44+
[#8271](https://github.com/rust-lang/rust-clippy/pull/8271)
45+
* [`unused_io_amount`]: Now supports async read and write traits
46+
[#8179](https://github.com/rust-lang/rust-clippy/pull/8179)
47+
* [`while_let_on_iterator`]: Improved detection to catch more cases
48+
[#8221](https://github.com/rust-lang/rust-clippy/pull/8221)
49+
* [`trait_duplication_in_bounds`]: Now covers trait functions with `Self` bounds
50+
[#8252](https://github.com/rust-lang/rust-clippy/pull/8252)
51+
* [`unwrap_used`]: Now works for `.get(i).unwrap()` and `.get_mut(i).unwrap()`
52+
[#8372](https://github.com/rust-lang/rust-clippy/pull/8372)
53+
* [`map_clone`]: The suggestion takes `msrv` into account
54+
[#8280](https://github.com/rust-lang/rust-clippy/pull/8280)
55+
* [`manual_bits`] and [`borrow_as_ptr`]: Now track the `clippy::msrv` attribute
56+
[#8280](https://github.com/rust-lang/rust-clippy/pull/8280)
57+
* [`disallowed_methods`]: Now works for methods on primitive types
58+
[#8112](https://github.com/rust-lang/rust-clippy/pull/8112)
59+
* [`not_unsafe_ptr_arg_deref`]: Now works for type aliases
60+
[#8273](https://github.com/rust-lang/rust-clippy/pull/8273)
61+
* [`needless_question_mark`]: Now works for async functions
62+
[#8311](https://github.com/rust-lang/rust-clippy/pull/8311)
63+
* [`iter_not_returning_iterator`]: Now handles type projections
64+
[#8228](https://github.com/rust-lang/rust-clippy/pull/8228)
65+
* [`wrong_self_convention`]: Now detects wrong `self` references in more cases
66+
[#8208](https://github.com/rust-lang/rust-clippy/pull/8208)
67+
* [`single_match`]: Now works for `match` statements with tuples
68+
[#8322](https://github.com/rust-lang/rust-clippy/pull/8322)
69+
70+
### False Positive Fixes
71+
72+
* [`erasing_op`]: No longer triggers if the output type changes
73+
[#8204](https://github.com/rust-lang/rust-clippy/pull/8204)
74+
* [`if_same_then_else`]: No longer triggers for `if let` statements
75+
[#8297](https://github.com/rust-lang/rust-clippy/pull/8297)
76+
* [`manual_memcpy`]: No longer lints on `VecDeque`
77+
[#8226](https://github.com/rust-lang/rust-clippy/pull/8226)
78+
* [`trait_duplication_in_bounds`]: Now takes path segments into account
79+
[#8315](https://github.com/rust-lang/rust-clippy/pull/8315)
80+
* [`deref_addrof`]: No longer lints when the dereference or borrow occurs in different a context
81+
[#8268](https://github.com/rust-lang/rust-clippy/pull/8268)
82+
* [`type_repetition_in_bounds`]: Now checks for full equality to prevent false positives
83+
[#8224](https://github.com/rust-lang/rust-clippy/pull/8224)
84+
* [`ptr_arg`]: No longer lint for mutable references in traits
85+
[#8369](https://github.com/rust-lang/rust-clippy/pull/8369)
86+
* [`implicit_clone`]: No longer lints for double references
87+
[#8231](https://github.com/rust-lang/rust-clippy/pull/8231)
88+
* [`needless_lifetimes`]: No longer lints lifetimes for explicit `self` types
89+
[#8278](https://github.com/rust-lang/rust-clippy/pull/8278)
90+
* [`op_ref`]: No longer lints in `BinOp` impl if that can cause recursion
91+
[#8298](https://github.com/rust-lang/rust-clippy/pull/8298)
92+
* [`enum_variant_names`]: No longer triggers for empty variant names
93+
[#8329](https://github.com/rust-lang/rust-clippy/pull/8329)
94+
* [`redundant_closure`]: No longer lints for `Arc<T>` or `Rc<T>`
95+
[#8193](https://github.com/rust-lang/rust-clippy/pull/8193)
96+
* [`iter_not_returning_iterator`]: No longer lints on trait implementations but therefore on trait definitions
97+
[#8228](https://github.com/rust-lang/rust-clippy/pull/8228)
98+
* [`single_match`]: No longer lints on exhaustive enum patterns without a wildcard
99+
[#8322](https://github.com/rust-lang/rust-clippy/pull/8322)
100+
* [`manual_swap`]: No longer lints on cases that involve automatic dereferences
101+
[#8220](https://github.com/rust-lang/rust-clippy/pull/8220)
102+
* [`useless_format`]: Now works for implicit named arguments
103+
[#8295](https://github.com/rust-lang/rust-clippy/pull/8295)
104+
105+
### Suggestion Fixes/Improvements
106+
107+
* [`needless_borrow`]: Prevent mutable borrows being moved and suggest removing the borrow on method calls
108+
[#8217](https://github.com/rust-lang/rust-clippy/pull/8217)
109+
* [`chars_next_cmp`]: Correctly excapes the suggestion
110+
[#8376](https://github.com/rust-lang/rust-clippy/pull/8376)
111+
* [`explicit_write`]: Add suggestions for `write!`s with format arguments
112+
[#8365](https://github.com/rust-lang/rust-clippy/pull/8365)
113+
* [`manual_memcpy`]: Suggests `copy_from_slice` when applicable
114+
[#8226](https://github.com/rust-lang/rust-clippy/pull/8226)
115+
* [`or_fun_call`]: Improved suggestion display for long arguments
116+
[#8292](https://github.com/rust-lang/rust-clippy/pull/8292)
117+
* [`unnecessary_cast`]: Now correctly includes the sign
118+
[#8350](https://github.com/rust-lang/rust-clippy/pull/8350)
119+
* [`cmp_owned`]: No longer flips the comparison order
120+
[#8299](https://github.com/rust-lang/rust-clippy/pull/8299)
121+
* [`explicit_counter_loop`]: Now correctly suggests `iter()` on references
122+
[#8382](https://github.com/rust-lang/rust-clippy/pull/8382)
123+
124+
### ICE Fixes
125+
126+
* [`manual_split_once`]
127+
[#8250](https://github.com/rust-lang/rust-clippy/pull/8250)
128+
129+
### Documentation Improvements
130+
131+
* [`map_flatten`]: Add documentation for the `Option` type
132+
[#8354](https://github.com/rust-lang/rust-clippy/pull/8354)
133+
* Document that Clippy's driver might use a different code generation than rustc
134+
[#8037](https://github.com/rust-lang/rust-clippy/pull/8037)
135+
* Clippy's lint list will now automatically focus the search box
136+
[#8343](https://github.com/rust-lang/rust-clippy/pull/8343)
137+
138+
### Others
139+
140+
* Clippy now warns if we find multiple Clippy config files exist
141+
[#8326](https://github.com/rust-lang/rust-clippy/pull/8326)
142+
143+
## Rust 1.59
144+
145+
Released 2022-02-24
14146

15147
[e181011...0eff589](https://github.com/rust-lang/rust-clippy/compare/e181011...0eff589)
16148

@@ -174,7 +306,7 @@ Current beta, release 2022-02-24
174306

175307
## Rust 1.58
176308

177-
Current stable, released 2022-01-13
309+
Released 2022-01-13
178310

179311
[00e31fa...e181011](https://github.com/rust-lang/rust-clippy/compare/00e31fa...e181011)
180312

@@ -3069,6 +3201,7 @@ Released 2018-09-13
30693201
[`bytes_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#bytes_nth
30703202
[`cargo_common_metadata`]: https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
30713203
[`case_sensitive_file_extension_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#case_sensitive_file_extension_comparisons
3204+
[`cast_abs_to_unsigned`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_abs_to_unsigned
30723205
[`cast_enum_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_enum_constructor
30733206
[`cast_enum_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_enum_truncation
30743207
[`cast_lossless`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
@@ -3097,6 +3230,7 @@ Released 2018-09-13
30973230
[`comparison_chain`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
30983231
[`comparison_to_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
30993232
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
3233+
[`crate_in_macro_def`]: https://rust-lang.github.io/rust-clippy/master/index.html#crate_in_macro_def
31003234
[`create_dir`]: https://rust-lang.github.io/rust-clippy/master/index.html#create_dir
31013235
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
31023236
[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
@@ -3123,19 +3257,22 @@ Released 2018-09-13
31233257
[`double_neg`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_neg
31243258
[`double_parens`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
31253259
[`drop_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_copy
3260+
[`drop_non_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_non_drop
31263261
[`drop_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_ref
31273262
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
31283263
[`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec
31293264
[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
31303265
[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
31313266
[`empty_line_after_outer_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
31323267
[`empty_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
3268+
[`empty_structs_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_structs_with_brackets
31333269
[`enum_clike_unportable_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_clike_unportable_variant
31343270
[`enum_glob_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use
31353271
[`enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
31363272
[`eq_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
31373273
[`equatable_if_let`]: https://rust-lang.github.io/rust-clippy/master/index.html#equatable_if_let
31383274
[`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op
3275+
[`err_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#err_expect
31393276
[`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence
31403277
[`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
31413278
[`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums
@@ -3174,6 +3311,7 @@ Released 2018-09-13
31743311
[`for_kv_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_kv_map
31753312
[`for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
31763313
[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
3314+
[`forget_non_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_non_drop
31773315
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
31783316
[`format_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_in_format_args
31793317
[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect

src/tools/clippy/Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.61"
3+
version = "0.1.62"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
@@ -21,13 +21,12 @@ name = "clippy-driver"
2121
path = "src/driver.rs"
2222

2323
[dependencies]
24-
clippy_lints = { version = "0.1", path = "clippy_lints" }
24+
clippy_lints = { path = "clippy_lints" }
2525
semver = "1.0"
26-
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
26+
rustc_tools_util = { path = "rustc_tools_util" }
2727
tempfile = { version = "3.2", optional = true }
2828

2929
[dev-dependencies]
30-
cargo_metadata = "0.14"
3130
compiletest_rs = { version = "0.7.1", features = ["tmp"] }
3231
tester = "0.9"
3332
regex = "1.5"
@@ -45,7 +44,7 @@ derive-new = "0.5"
4544
if_chain = "1.0"
4645
itertools = "0.10.1"
4746
quote = "1.0"
48-
serde = { version = "1.0", features = ["derive"] }
47+
serde = { version = "1.0.125", features = ["derive"] }
4948
syn = { version = "1.0", features = ["full"] }
5049
futures = "0.3"
5150
parking_lot = "0.11.2"

src/tools/clippy/clippy_dev/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ version = "0.0.1"
44
edition = "2021"
55

66
[dependencies]
7-
bytecount = "0.6"
87
clap = "2.33"
98
indoc = "1.0"
109
itertools = "0.10.1"
1110
opener = "0.5"
12-
regex = "1.5"
1311
shell-escape = "0.1"
12+
tempfile = "3.2"
1413
walkdir = "2.3"
15-
cargo_metadata = "0.14"
1614

1715
[features]
1816
deny-warnings = []
17+
18+
[package.metadata.rust-analyzer]
19+
# This package uses #[feature(rustc_private)]
20+
rustc_private = true

src/tools/clippy/clippy_dev/src/bless.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
//! `bless` updates the reference files in the repo with changed output files
22
//! from the last test run.
33
4+
use crate::cargo_clippy_path;
45
use std::ffi::OsStr;
56
use std::fs;
67
use std::lazy::SyncLazy;
78
use std::path::{Path, PathBuf};
89
use walkdir::{DirEntry, WalkDir};
910

10-
#[cfg(not(windows))]
11-
static CARGO_CLIPPY_EXE: &str = "cargo-clippy";
12-
#[cfg(windows)]
13-
static CARGO_CLIPPY_EXE: &str = "cargo-clippy.exe";
14-
15-
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::new(|| {
16-
let mut path = std::env::current_exe().unwrap();
17-
path.set_file_name(CARGO_CLIPPY_EXE);
18-
fs::metadata(path).ok()?.modified().ok()
19-
});
11+
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> =
12+
SyncLazy::new(|| cargo_clippy_path().metadata().ok()?.modified().ok());
2013

2114
/// # Panics
2215
///

src/tools/clippy/clippy_dev/src/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
#![feature(let_else)]
12
#![feature(once_cell)]
3+
#![feature(rustc_private)]
24
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
35
// warn on lints, that are included in `rust-lang/rust`s bootstrap
46
#![warn(rust_2018_idioms, unused_lifetimes)]
57

8+
extern crate rustc_lexer;
9+
610
use std::path::PathBuf;
711

812
pub mod bless;
@@ -13,6 +17,19 @@ pub mod serve;
1317
pub mod setup;
1418
pub mod update_lints;
1519

20+
#[cfg(not(windows))]
21+
static CARGO_CLIPPY_EXE: &str = "cargo-clippy";
22+
#[cfg(windows)]
23+
static CARGO_CLIPPY_EXE: &str = "cargo-clippy.exe";
24+
25+
/// Returns the path to the `cargo-clippy` binary
26+
#[must_use]
27+
pub fn cargo_clippy_path() -> PathBuf {
28+
let mut path = std::env::current_exe().expect("failed to get current executable name");
29+
path.set_file_name(CARGO_CLIPPY_EXE);
30+
path
31+
}
32+
1633
/// Returns the path to the Clippy project directory
1734
///
1835
/// # Panics

0 commit comments

Comments
 (0)