Skip to content

Commit 04c9901

Browse files
committed
Auto merge of #87954 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents 13d6c5c + f92a0c8 commit 04c9901

File tree

77 files changed

+1311
-375
lines changed

Some content is hidden

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

77 files changed

+1311
-375
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ labels: A-lint
1515
*What is the advantage of the recommended code over the original code*
1616

1717
For example:
18-
- Remove bounce checking inserted by ...
19-
- Remove the need to duplicating/storing/typo ...
18+
- Remove bounds check inserted by ...
19+
- Remove the need to duplicate/store ...
20+
- Remove typo ...
2021

2122
### Drawbacks
2223

src/tools/clippy/.github/workflows/clippy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
5050
5151
- name: Build
52-
run: cargo build --features deny-warnings,internal-lints
52+
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
5353

5454
- name: Test
55-
run: cargo test --features deny-warnings,internal-lints
55+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
5656

5757
- name: Test clippy_lints
58-
run: cargo test --features deny-warnings,internal-lints
58+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
5959
working-directory: clippy_lints
6060

6161
- name: Test rustc_tools_util

src/tools/clippy/.github/workflows/clippy_bors.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ jobs:
112112
echo "$SYSROOT/bin" >> $GITHUB_PATH
113113
114114
- name: Build
115-
run: cargo build --features deny-warnings,internal-lints
115+
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
116116

117117
- name: Test
118-
run: cargo test --features deny-warnings,internal-lints
118+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
119119

120120
- name: Test clippy_lints
121-
run: cargo test --features deny-warnings,internal-lints
121+
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
122122
working-directory: clippy_lints
123123

124124
- name: Test rustc_tools_util

src/tools/clippy/.github/workflows/remark.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020

2121
- name: Setup Node.js
2222
uses: actions/[email protected]
23+
with:
24+
node-version: '12.x'
2325

2426
- name: Install remark
2527
run: npm install remark-cli remark-lint remark-lint-maximum-line-length remark-preset-lint-recommended remark-gfm

src/tools/clippy/CHANGELOG.md

+136-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,141 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[3ae8faf...master](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...master)
9+
[74d1561...master](https://github.com/rust-lang/rust-clippy/compare/74d1561...master)
10+
11+
## Rust 1.55
12+
13+
Current beta, release 2021-09-09
14+
15+
[3ae8faf...74d1561](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...74d1561)
16+
17+
### Important Changes
18+
19+
* Stabilized `cargo clippy --fix` :tada:
20+
[#7405](https://github.com/rust-lang/rust-clippy/pull/7405)
21+
22+
### New Lints
23+
24+
* [`rc_mutex`]
25+
[#7316](https://github.com/rust-lang/rust-clippy/pull/7316)
26+
* [`nonstandard_macro_braces`]
27+
[#7299](https://github.com/rust-lang/rust-clippy/pull/7299)
28+
* [`strlen_on_c_strings`]
29+
[#7243](https://github.com/rust-lang/rust-clippy/pull/7243)
30+
* [`self_named_constructors`]
31+
[#7403](https://github.com/rust-lang/rust-clippy/pull/7403)
32+
* [`disallowed_script_idents`]
33+
[#7400](https://github.com/rust-lang/rust-clippy/pull/7400)
34+
* [`disallowed_type`]
35+
[#7315](https://github.com/rust-lang/rust-clippy/pull/7315)
36+
* [`missing_enforced_import_renames`]
37+
[#7300](https://github.com/rust-lang/rust-clippy/pull/7300)
38+
* [`extend_with_drain`]
39+
[#7270](https://github.com/rust-lang/rust-clippy/pull/7270)
40+
41+
### Moves and Deprecations
42+
43+
* Moved [`from_iter_instead_of_collect`] to `pedantic`
44+
[#7375](https://github.com/rust-lang/rust-clippy/pull/7375)
45+
* Added `suspicious` as a new lint group for *code that is most likely wrong or useless*
46+
[#7350](https://github.com/rust-lang/rust-clippy/pull/7350)
47+
* Moved [`blanket_clippy_restriction_lints`] to `suspicious`
48+
* Moved [`empty_loop`] to `suspicious`
49+
* Moved [`eval_order_dependence`] to `suspicious`
50+
* Moved [`float_equality_without_abs`] to `suspicious`
51+
* Moved [`for_loops_over_fallibles`] to `suspicious`
52+
* Moved [`misrefactored_assign_op`] to `suspicious`
53+
* Moved [`mut_range_bound`] to `suspicious`
54+
* Moved [`mutable_key_type`] to `suspicious`
55+
* Moved [`suspicious_arithmetic_impl`] to `suspicious`
56+
* Moved [`suspicious_assignment_formatting`] to `suspicious`
57+
* Moved [`suspicious_else_formatting`] to `suspicious`
58+
* Moved [`suspicious_map`] to `suspicious`
59+
* Moved [`suspicious_op_assign_impl`] to `suspicious`
60+
* Moved [`suspicious_unary_op_formatting`] to `suspicious`
61+
62+
### Enhancements
63+
64+
* [`while_let_on_iterator`]: Now suggests `&mut iter` inside closures
65+
[#7262](https://github.com/rust-lang/rust-clippy/pull/7262)
66+
* [`doc_markdown`]:
67+
* Now detects unbalanced ticks
68+
[#7357](https://github.com/rust-lang/rust-clippy/pull/7357)
69+
* Add `FreeBSD` to the default configuration as an allowed identifier
70+
[#7334](https://github.com/rust-lang/rust-clippy/pull/7334)
71+
* [`wildcard_enum_match_arm`], [`match_wildcard_for_single_variants`]: Now allows wildcards for enums with unstable
72+
or hidden variants
73+
[#7407](https://github.com/rust-lang/rust-clippy/pull/7407)
74+
* [`redundant_allocation`]: Now additionally supports the `Arc<>` type
75+
[#7308](https://github.com/rust-lang/rust-clippy/pull/7308)
76+
* [`blacklisted_name`]: Now allows blacklisted names in test code
77+
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
78+
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
79+
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
80+
* [`disallowed_method`], [`disallowed_type`]: The configuration values `disallowed-method` and `disallowed-type`
81+
no longer require fully qualified paths
82+
[#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
83+
* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
84+
[#7396](https://github.com/rust-lang/rust-clippy/pull/7396)
85+
86+
### False Positive Fixes
87+
88+
* [`default_numeric_fallback`]: No longer lints on float literals as function arguments
89+
[#7446](https://github.com/rust-lang/rust-clippy/pull/7446)
90+
* [`use_self`]: No longer lints on type parameters
91+
[#7288](https://github.com/rust-lang/rust-clippy/pull/7288)
92+
* [`unimplemented`]: Now ignores the `assert` and `debug_assert` macros
93+
[#7439](https://github.com/rust-lang/rust-clippy/pull/7439)
94+
* [`branches_sharing_code`]: Now always checks for block expressions
95+
[#7462](https://github.com/rust-lang/rust-clippy/pull/7462)
96+
* [`field_reassign_with_default`]: No longer triggers in macros
97+
[#7160](https://github.com/rust-lang/rust-clippy/pull/7160)
98+
* [`redundant_clone`]: No longer lints on required clones for borrowed data
99+
[#7346](https://github.com/rust-lang/rust-clippy/pull/7346)
100+
* [`default_numeric_fallback`]: No longer triggers in external macros
101+
[#7325](https://github.com/rust-lang/rust-clippy/pull/7325)
102+
* [`needless_bool`]: No longer lints in macros
103+
[#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
104+
* [`useless_format`]: No longer triggers when additional text is being appended
105+
[#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
106+
* [`assertions_on_constants`]: `cfg!(...)` is no longer considered to be a constant
107+
[#7319](https://github.com/rust-lang/rust-clippy/pull/7319)
108+
109+
### Suggestion Fixes/Improvements
110+
111+
* [`needless_collect`]: Now show correct lint messages for shadowed values
112+
[#7289](https://github.com/rust-lang/rust-clippy/pull/7289)
113+
* [`wrong_pub_self_convention`]: The deprecated message now suggest the correct configuration value
114+
[#7382](https://github.com/rust-lang/rust-clippy/pull/7382)
115+
* [`semicolon_if_nothing_returned`]: Allow missing semicolon in blocks with only one expression
116+
[#7326](https://github.com/rust-lang/rust-clippy/pull/7326)
117+
118+
### ICE Fixes
119+
120+
* [`zero_sized_map_values`]
121+
[#7470](https://github.com/rust-lang/rust-clippy/pull/7470)
122+
* [`redundant_pattern_matching`]
123+
[#7471](https://github.com/rust-lang/rust-clippy/pull/7471)
124+
* [`modulo_one`]
125+
[#7473](https://github.com/rust-lang/rust-clippy/pull/7473)
126+
* [`use_self`]
127+
[#7428](https://github.com/rust-lang/rust-clippy/pull/7428)
128+
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)
10140

11141
## Rust 1.54
12142

13-
Current beta, release 2021-07-29
143+
Current stable, released 2021-07-29
14144

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

@@ -29,7 +159,7 @@ Current beta, release 2021-07-29
29159
### Moves and Deprecations
30160

31161
- Deprecate `pub_enum_variant_names` and `wrong_pub_self_convention` in favor of
32-
the new `avoid_breaking_exported_api` config option (see
162+
the new `avoid-breaking-exported-api` config option (see
33163
[Enhancements](#1-54-enhancements))
34164
[#7187](https://github.com/rust-lang/rust-clippy/pull/7187)
35165
- Move [`inconsistent_struct_constructor`] to `pedantic`
@@ -51,7 +181,7 @@ Current beta, release 2021-07-29
51181
[#7163](https://github.com/rust-lang/rust-clippy/pull/7163)
52182
- [`if_then_some_else_none`]: Now works with the MSRV config
53183
[#7177](https://github.com/rust-lang/rust-clippy/pull/7177)
54-
- Add `avoid_breaking_exported_api` config option for the lints
184+
- Add `avoid-breaking-exported-api` config option for the lints
55185
[`enum_variant_names`], [`large_types_passed_by_value`],
56186
[`trivially_copy_pass_by_ref`], [`unnecessary_wraps`],
57187
[`upper_case_acronyms`], and [`wrong_self_convention`]. We recommend to set
@@ -138,7 +268,7 @@ Current beta, release 2021-07-29
138268

139269
## Rust 1.53
140270

141-
Current stable, released 2021-06-17
271+
Released 2021-06-17
142272

143273
[6ed6f1e...7c7683c](https://github.com/rust-lang/rust-clippy/compare/6ed6f1e...7c7683c)
144274

@@ -2869,6 +2999,7 @@ Released 2018-09-13
28692999
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
28703000
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
28713001
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
3002+
[`unwrap_or_else_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
28723003
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
28733004
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
28743005
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug

src/tools/clippy/clippy_lints/src/as_conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_ast::ast::{Expr, ExprKind};
3-
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
3+
use rustc_lint::{EarlyContext, EarlyLintPass};
44
use rustc_middle::lint::in_external_macro;
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66

@@ -47,7 +47,7 @@ declare_lint_pass!(AsConversions => [AS_CONVERSIONS]);
4747

4848
impl EarlyLintPass for AsConversions {
4949
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
50-
if in_external_macro(cx.sess(), expr.span) {
50+
if in_external_macro(cx.sess, expr.span) {
5151
return;
5252
}
5353

src/tools/clippy/clippy_lints/src/doc.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
230230
panic_span: None,
231231
};
232232
fpu.visit_expr(&body.value);
233-
lint_for_missing_headers(
234-
cx,
235-
item.def_id,
236-
item.span,
237-
sig,
238-
headers,
239-
Some(body_id),
240-
fpu.panic_span,
241-
);
233+
lint_for_missing_headers(cx, item.def_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
242234
}
243235
},
244236
hir::ItemKind::Impl(ref impl_) => {
@@ -278,15 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
278270
panic_span: None,
279271
};
280272
fpu.visit_expr(&body.value);
281-
lint_for_missing_headers(
282-
cx,
283-
item.def_id,
284-
item.span,
285-
sig,
286-
headers,
287-
Some(body_id),
288-
fpu.panic_span,
289-
);
273+
lint_for_missing_headers(cx, item.def_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
290274
}
291275
}
292276
}

src/tools/clippy/clippy_lints/src/else_if_without_else.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use clippy_utils::diagnostics::span_lint_and_help;
44
use rustc_ast::ast::{Expr, ExprKind};
5-
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
5+
use rustc_lint::{EarlyContext, EarlyLintPass};
66
use rustc_middle::lint::in_external_macro;
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88

@@ -49,7 +49,7 @@ declare_lint_pass!(ElseIfWithoutElse => [ELSE_IF_WITHOUT_ELSE]);
4949

5050
impl EarlyLintPass for ElseIfWithoutElse {
5151
fn check_expr(&mut self, cx: &EarlyContext<'_>, mut item: &Expr) {
52-
if in_external_macro(cx.sess(), item.span) {
52+
if in_external_macro(cx.sess, item.span) {
5353
return;
5454
}
5555

src/tools/clippy/clippy_lints/src/functions/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
251251
hir_id: hir::HirId,
252252
) {
253253
too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold);
254-
too_many_lines::check_fn(cx, span, body, self.too_many_lines_threshold);
254+
too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold);
255255
not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, hir_id);
256256
}
257257

src/tools/clippy/clippy_lints/src/functions/too_many_lines.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_hir as hir;
2+
use rustc_hir::intravisit::FnKind;
23
use rustc_lint::{LateContext, LintContext};
34
use rustc_middle::lint::in_external_macro;
45
use rustc_span::Span;
@@ -8,8 +9,16 @@ use clippy_utils::source::snippet_opt;
89

910
use super::TOO_MANY_LINES;
1011

11-
pub(super) fn check_fn(cx: &LateContext<'_>, span: Span, body: &'tcx hir::Body<'_>, too_many_lines_threshold: u64) {
12-
if in_external_macro(cx.sess(), span) {
12+
pub(super) fn check_fn(
13+
cx: &LateContext<'_>,
14+
kind: FnKind<'tcx>,
15+
span: Span,
16+
body: &'tcx hir::Body<'_>,
17+
too_many_lines_threshold: u64,
18+
) {
19+
// Closures must be contained in a parent body, which will be checked for `too_many_lines`.
20+
// Don't check closures for `too_many_lines` to avoid duplicated lints.
21+
if matches!(kind, FnKind::Closure) || in_external_macro(cx.sess(), span) {
1322
return;
1423
}
1524

src/tools/clippy/clippy_lints/src/if_not_else.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use clippy_utils::diagnostics::span_lint_and_help;
55
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, UnOp};
6-
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
6+
use rustc_lint::{EarlyContext, EarlyLintPass};
77
use rustc_middle::lint::in_external_macro;
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99

@@ -48,7 +48,7 @@ declare_lint_pass!(IfNotElse => [IF_NOT_ELSE]);
4848

4949
impl EarlyLintPass for IfNotElse {
5050
fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
51-
if in_external_macro(cx.sess(), item.span) {
51+
if in_external_macro(cx.sess, item.span) {
5252
return;
5353
}
5454
if let ExprKind::If(ref cond, _, Some(ref els)) = item.kind {

src/tools/clippy/clippy_lints/src/items_after_statements.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use clippy_utils::diagnostics::span_lint;
44
use rustc_ast::ast::{Block, ItemKind, StmtKind};
5-
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
5+
use rustc_lint::{EarlyContext, EarlyLintPass};
66
use rustc_middle::lint::in_external_macro;
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88

@@ -54,7 +54,7 @@ declare_lint_pass!(ItemsAfterStatements => [ITEMS_AFTER_STATEMENTS]);
5454

5555
impl EarlyLintPass for ItemsAfterStatements {
5656
fn check_block(&mut self, cx: &EarlyContext<'_>, item: &Block) {
57-
if in_external_macro(cx.sess(), item.span) {
57+
if in_external_macro(cx.sess, item.span) {
5858
return;
5959
}
6060

@@ -68,7 +68,7 @@ impl EarlyLintPass for ItemsAfterStatements {
6868
// lint on all further items
6969
for stmt in stmts {
7070
if let StmtKind::Item(ref it) = *stmt {
71-
if in_external_macro(cx.sess(), it.span) {
71+
if in_external_macro(cx.sess, it.span) {
7272
return;
7373
}
7474
if let ItemKind::MacroDef(..) = it.kind {

0 commit comments

Comments
 (0)