Skip to content

Commit 6f608ce

Browse files
committed
Auto merge of rust-lang#89328 - flip1995:clippyup, r=Manishearth
Update Clippy Delayed Clippy sync r? `@Manishearth`
2 parents 6df1d82 + d0fb9db commit 6f608ce

File tree

142 files changed

+2220
-1001
lines changed

Some content is hidden

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

142 files changed

+2220
-1001
lines changed

src/tools/clippy/.cargo/config

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[alias]
22
uitest = "test --test compile-test"
3-
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4-
lintcheck = "run --target-dir lintcheck/target --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
3+
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4+
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
55
collect-metadata = "test --test dogfood --features metadata-collector-lint -- run_metadata_collection_lint --ignored"
66

77
[build]
88
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests
99
rustflags = ["-Zunstable-options", "-Zbinary-dep-depinfo"]
10+
target-dir = "target"

src/tools/clippy/.github/ISSUE_TEMPLATE/blank_issue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ about: Create a blank issue.
88
Additional labels can be added to this issue by including the following command
99
(without the space after the @ symbol):
1010
11-
`@rustbot label +<label>`
11+
@ rustbot label +<label>
1212
1313
Common labels for this issue type are:
1414
* C-an-interesting-project

src/tools/clippy/.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LLVM version: 10.0
3636
Additional labels can be added to this issue by including the following command
3737
(without the space after the @ symbol):
3838
39-
`@rustbot label +<label>`
39+
@ rustbot label +<label>
4040
4141
Common labels for this issue type are:
4242
* `I-suggestion-causes-error`

src/tools/clippy/.github/ISSUE_TEMPLATE/false_positive.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LLVM version: 10.0
3737
Additional labels can be added to this issue by including the following command
3838
(without the space after the @ symbol):
3939
40-
`@rustbot label +<label>`
40+
@ rustbot label +<label>
4141
4242
Common labels for this issue type are:
4343
* I-suggestion-causes-error

src/tools/clippy/CHANGELOG.md

+80-19
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,81 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[74d1561...master](https://github.com/rust-lang/rust-clippy/compare/74d1561...master)
9+
[7bfc26e...master](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...master)
10+
11+
## Rust 1.56
12+
13+
Current beta, release 2021-10-21
14+
15+
[74d1561...7bfc26e](https://github.com/rust-lang/rust-clippy/compare/74d1561...7bfc26e)
16+
17+
### New Lints
18+
19+
* [`unwrap_or_else_default`]
20+
[#7516](https://github.com/rust-lang/rust-clippy/pull/7516)
21+
22+
### Enhancements
23+
24+
* [`needless_continue`]: Now also lints in `loop { continue; }` case
25+
[#7477](https://github.com/rust-lang/rust-clippy/pull/7477)
26+
* [`disallowed_type`]: Now also primitive types can be disallowed
27+
[#7488](https://github.com/rust-lang/rust-clippy/pull/7488)
28+
* [`manual_swap`]: Now also lints on xor swaps
29+
[#7506](https://github.com/rust-lang/rust-clippy/pull/7506)
30+
* [`map_flatten`]: Now also lints on the `Result` type
31+
[#7522](https://github.com/rust-lang/rust-clippy/pull/7522)
32+
* [`no_effect`]: Now also lints on inclusive ranges
33+
[#7556](https://github.com/rust-lang/rust-clippy/pull/7556)
34+
35+
### False Positive Fixes
36+
37+
* [`nonstandard_macro_braces`]: No longer lints on similar named nested macros
38+
[#7478](https://github.com/rust-lang/rust-clippy/pull/7478)
39+
* [`too_many_lines`]: No longer lints in closures to avoid duplicated diagnostics
40+
[#7534](https://github.com/rust-lang/rust-clippy/pull/7534)
41+
* [`similar_names`]: No longer complains about `iter` and `item` being too
42+
similar [#7546](https://github.com/rust-lang/rust-clippy/pull/7546)
43+
44+
### Suggestion Fixes/Improvements
45+
46+
* [`similar_names`]: No longer suggests to insert or add an underscore as a fix
47+
[#7221](https://github.com/rust-lang/rust-clippy/pull/7221)
48+
* [`new_without_default`]: No longer shows the full qualified type path when
49+
suggesting adding a `Default` implementation
50+
[#7493](https://github.com/rust-lang/rust-clippy/pull/7493)
51+
* [`while_let_on_iterator`]: Now suggests re-borrowing mutable references
52+
[#7520](https://github.com/rust-lang/rust-clippy/pull/7520)
53+
* [`extend_with_drain`]: Improve code suggestion for mutable and immutable
54+
references [#7533](https://github.com/rust-lang/rust-clippy/pull/7533)
55+
* [`trivially_copy_pass_by_ref`]: Now properly handles `Self` type
56+
[#7535](https://github.com/rust-lang/rust-clippy/pull/7535)
57+
* [`never_loop`]: Now suggests using `if let` instead of a `for` loop when
58+
applicable [#7541](https://github.com/rust-lang/rust-clippy/pull/7541)
59+
60+
### Documentation Improvements
61+
62+
* Clippy now uses a lint to generate its lint documentation. [Lints all the way
63+
down](https://en.wikipedia.org/wiki/Turtles_all_the_way_down).
64+
[#7502](https://github.com/rust-lang/rust-clippy/pull/7502)
65+
* Reworked Clippy's website:
66+
[#7172](https://github.com/rust-lang/rust-clippy/issues/7172)
67+
[#7279](https://github.com/rust-lang/rust-clippy/pull/7279)
68+
* Added applicability information about lints
69+
* Added a link to jump into the implementation
70+
* Improved loading times
71+
* Adapted some styling
72+
* `cargo clippy --help` now also explains the `--fix` and `--no-deps` flag
73+
[#7492](https://github.com/rust-lang/rust-clippy/pull/7492)
74+
* [`unnested_or_patterns`]: Removed `or_patterns` feature gate in the code
75+
example [#7507](https://github.com/rust-lang/rust-clippy/pull/7507)
76+
77+
### New Lints
78+
79+
* Renamed Lint: `if_let_some_result` is now called [`match_result_ok`]. Now also handles `while let` case.
1080

1181
## Rust 1.55
1282

13-
Current beta, release 2021-09-09
83+
Current stable, released 2021-09-09
1484

1585
[3ae8faf...74d1561](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...74d1561)
1686

@@ -126,21 +196,9 @@ Current beta, release 2021-09-09
126196
* [`use_self`]
127197
[#7428](https://github.com/rust-lang/rust-clippy/pull/7428)
128198

129-
### Documentation Improvements
130-
131-
* Reworked Clippy's website:
132-
[#7279](https://github.com/rust-lang/rust-clippy/pull/7279)
133-
[#7172](https://github.com/rust-lang/rust-clippy/issues/7172)
134-
* Added applicability information about lints
135-
* Added a link to jump into the implementation
136-
* Improved loading times
137-
* Adapted some styling
138-
* Clippy now uses a lint to generate its documentation
139-
[#7298](https://github.com/rust-lang/rust-clippy/pull/7298)
140-
141199
## Rust 1.54
142200

143-
Current stable, released 2021-07-29
201+
Released 2021-07-29
144202

145203
[7c7683c...3ae8faf](https://github.com/rust-lang/rust-clippy/compare/7c7683c...3ae8faf)
146204

@@ -1050,7 +1108,7 @@ Released 2020-11-19
10501108
[#5913](https://github.com/rust-lang/rust-clippy/pull/5913)
10511109
* Add example of false positive to [`ptr_arg`] docs.
10521110
[#5885](https://github.com/rust-lang/rust-clippy/pull/5885)
1053-
* [`box_vec`], [`vec_box`] and [`borrowed_box`]: add link to the documentation of `Box`
1111+
* [`box_vec`](https://rust-lang.github.io/rust-clippy/master/index.html#box_collection), [`vec_box`] and [`borrowed_box`]: add link to the documentation of `Box`
10541112
[#6023](https://github.com/rust-lang/rust-clippy/pull/6023)
10551113

10561114
## Rust 1.47
@@ -1491,7 +1549,7 @@ Released 2020-03-12
14911549
* `unknown_clippy_lints` [#4963](https://github.com/rust-lang/rust-clippy/pull/4963)
14921550
* [`explicit_into_iter_loop`] [#4978](https://github.com/rust-lang/rust-clippy/pull/4978)
14931551
* [`useless_attribute`] [#5022](https://github.com/rust-lang/rust-clippy/pull/5022)
1494-
* [`if_let_some_result`] [#5032](https://github.com/rust-lang/rust-clippy/pull/5032)
1552+
* `if_let_some_result` [#5032](https://github.com/rust-lang/rust-clippy/pull/5032)
14951553

14961554
### ICE fixes
14971555

@@ -2570,7 +2628,7 @@ Released 2018-09-13
25702628
[`bool_comparison`]: https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
25712629
[`borrow_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const
25722630
[`borrowed_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
2573-
[`box_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#box_vec
2631+
[`box_collection`]: https://rust-lang.github.io/rust-clippy/master/index.html#box_collection
25742632
[`boxed_local`]: https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
25752633
[`branches_sharing_code`]: https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
25762634
[`builtin_type_shadow`]: https://rust-lang.github.io/rust-clippy/master/index.html#builtin_type_shadow
@@ -2685,9 +2743,9 @@ Released 2018-09-13
26852743
[`identity_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
26862744
[`if_let_mutex`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_mutex
26872745
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
2688-
[`if_let_some_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result
26892746
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
26902747
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2748+
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
26912749
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
26922750
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
26932751
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
@@ -2722,6 +2780,7 @@ Released 2018-09-13
27222780
[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
27232781
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
27242782
[`iter_next_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_slice
2783+
[`iter_not_returning_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_not_returning_iterator
27252784
[`iter_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth
27262785
[`iter_nth_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
27272786
[`iter_skip_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next
@@ -2773,6 +2832,7 @@ Released 2018-09-13
27732832
[`match_on_vec_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
27742833
[`match_overlapping_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_overlapping_arm
27752834
[`match_ref_pats`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
2835+
[`match_result_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_result_ok
27762836
[`match_same_arms`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_same_arms
27772837
[`match_single_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
27782838
[`match_wild_err_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wild_err_arm
@@ -2905,6 +2965,7 @@ Released 2018-09-13
29052965
[`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
29062966
[`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
29072967
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
2968+
[`same_name_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_name_method
29082969
[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
29092970
[`self_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
29102971
[`self_named_constructors`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructors

src/tools/clippy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
88
keywords = ["clippy", "lint", "plugin"]
99
categories = ["development-tools", "development-tools::cargo-plugins"]
1010
build = "build.rs"
11-
edition = "2018"
11+
edition = "2021"
1212
publish = false
1313

1414
[[bin]]

src/tools/clippy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the
1818
| `clippy::style` | code that should be written in a more idiomatic way | **warn** |
1919
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
2020
| `clippy::perf` | code that can be written to run faster | **warn** |
21-
| `clippy::pedantic` | lints which are rather strict or might have false positives | allow |
21+
| `clippy::pedantic` | lints which are rather strict or have occasional false positives | allow |
2222
| `clippy::nursery` | new lints that are still under development | allow |
2323
| `clippy::cargo` | lints for the cargo manifest | allow |
2424

src/tools/clippy/clippy_dev/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_dev"
33
version = "0.0.1"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
bytecount = "0.6"

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

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! `bless` updates the reference files in the repo with changed output files
22
//! from the last test run.
33
4-
use std::env;
54
use std::ffi::OsStr;
65
use std::fs;
76
use std::lazy::SyncLazy;
@@ -10,17 +9,9 @@ use walkdir::WalkDir;
109

1110
use crate::clippy_project_root;
1211

13-
// NOTE: this is duplicated with tests/cargo/mod.rs What to do?
14-
pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var_os("CARGO_TARGET_DIR") {
15-
Some(v) => v.into(),
16-
None => env::current_dir().unwrap().join("target"),
17-
});
18-
1912
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::new(|| {
20-
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
21-
let mut path = PathBuf::from(&**CARGO_TARGET_DIR);
22-
path.push(profile);
23-
path.push("cargo-clippy");
13+
let mut path = std::env::current_exe().unwrap();
14+
path.set_file_name("cargo-clippy");
2415
fs::metadata(path).ok()?.modified().ok()
2516
});
2617

@@ -94,10 +85,7 @@ fn updated_since_clippy_build(path: &Path) -> Option<bool> {
9485
}
9586

9687
fn build_dir() -> PathBuf {
97-
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
98-
let mut path = PathBuf::new();
99-
path.push(CARGO_TARGET_DIR.clone());
100-
path.push(profile);
101-
path.push("test_build_base");
88+
let mut path = std::env::current_exe().unwrap();
89+
path.set_file_name("test");
10290
path
10391
}

src/tools/clippy/clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
77
license = "MIT OR Apache-2.0"
88
keywords = ["clippy", "lint", "plugin"]
9-
edition = "2018"
9+
edition = "2021"
1010

1111
[dependencies]
1212
cargo_metadata = "0.12"

src/tools/clippy/clippy_lints/src/derivable_impls.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::{in_macro, is_automatically_derived, is_default_equivalent, remove_blocks};
33
use rustc_hir::{
44
def::{DefKind, Res},
5-
Body, Expr, ExprKind, Impl, ImplItemKind, Item, ItemKind, Node, QPath,
5+
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, TyKind,
66
};
77
use rustc_lint::{LateContext, LateLintPass};
8-
use rustc_middle::ty::TypeFoldable;
98
use rustc_session::{declare_lint_pass, declare_tool_lint};
109
use rustc_span::sym;
1110

@@ -68,6 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
6867
if let ItemKind::Impl(Impl {
6968
of_trait: Some(ref trait_ref),
7069
items: [child],
70+
self_ty,
7171
..
7272
}) = item.kind;
7373
if let attrs = cx.tcx.hir().attrs(item.hir_id());
@@ -80,9 +80,18 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
8080
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
8181
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
8282
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
83+
if !attrs.iter().any(|attr| attr.doc_str().is_some());
84+
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);
85+
if !child_attrs.iter().any(|attr| attr.doc_str().is_some());
8386
then {
84-
if cx.tcx.type_of(item.def_id).definitely_has_param_types_or_consts(cx.tcx) {
85-
return;
87+
if let TyKind::Path(QPath::Resolved(_, p)) = self_ty.kind {
88+
if let Some(PathSegment { args: Some(a), .. }) = p.segments.last() {
89+
for arg in a.args {
90+
if !matches!(arg, GenericArg::Lifetime(_)) {
91+
return;
92+
}
93+
}
94+
}
8695
}
8796
let should_emit = match remove_blocks(func_expr).kind {
8897
ExprKind::Tup(fields) => fields.iter().all(|e| is_default_equivalent(cx, e)),

0 commit comments

Comments
 (0)