Skip to content

Commit 238994f

Browse files
committed
Auto merge of #79228 - flip1995:clippyup, r=oli-obk
Update Clippy Biweekly Clippy update r? `@Manishearth`
2 parents 4167d73 + 99b9459 commit 238994f

File tree

142 files changed

+3112
-876
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

+3112
-876
lines changed

src/tools/clippy/.github/PULL_REQUEST_TEMPLATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Thank you for making Clippy better!
22

33
We're collecting our changelog from pull request descriptions.
4-
If your PR only updates to the latest nightly, you can leave the
5-
`changelog` entry as `none`. Otherwise, please write a short comment
4+
If your PR only includes internal changes, you can just write
5+
`changelog: none`. Otherwise, please write a short comment
66
explaining your change.
77

88
If your PR fixes an issue, you can add "fixes #issue_number" into this
@@ -28,5 +28,5 @@ Delete this line and everything above before opening your PR.
2828

2929
---
3030

31-
*Please keep the line below*
32-
changelog: none
31+
*Please write a short comment explaining your change (or "none" for internal only changes)*
32+
changelog:

src/tools/clippy/CHANGELOG.md

+118-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,117 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[e636b88...master](https://github.com/rust-lang/rust-clippy/compare/e636b88...master)
9+
[b20d4c1...master](https://github.com/rust-lang/rust-clippy/compare/b20d4c1...master)
10+
11+
## Rust 1.49
12+
13+
Current beta, release 2020-12-31
14+
15+
[e636b88...b20d4c1](https://github.com/rust-lang/rust-clippy/compare/e636b88...b20d4c1)
16+
17+
### New Lints
18+
19+
* [`field_reassign_with_default`] [#5911](https://github.com/rust-lang/rust-clippy/pull/5911)
20+
* [`await_holding_refcell_ref`] [#6029](https://github.com/rust-lang/rust-clippy/pull/6029)
21+
* [`disallowed_method`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
22+
* [`inline_asm_x86_att_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
23+
* [`inline_asm_x86_intel_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
24+
* [`from_iter_instead_of_collect`] [#6101](https://github.com/rust-lang/rust-clippy/pull/6101)
25+
* [`mut_mutex_lock`] [#6103](https://github.com/rust-lang/rust-clippy/pull/6103)
26+
* [`single_element_loop`] [#6109](https://github.com/rust-lang/rust-clippy/pull/6109)
27+
* [`manual_unwrap_or`] [#6123](https://github.com/rust-lang/rust-clippy/pull/6123)
28+
* [`large_types_passed_by_value`] [#6135](https://github.com/rust-lang/rust-clippy/pull/6135)
29+
* [`result_unit_err`] [#6157](https://github.com/rust-lang/rust-clippy/pull/6157)
30+
* [`ref_option_ref`] [#6165](https://github.com/rust-lang/rust-clippy/pull/6165)
31+
* [`manual_range_contains`] [#6177](https://github.com/rust-lang/rust-clippy/pull/6177)
32+
* [`unusual_byte_groupings`] [#6183](https://github.com/rust-lang/rust-clippy/pull/6183)
33+
* [`comparison_to_empty`] [#6226](https://github.com/rust-lang/rust-clippy/pull/6226)
34+
* [`map_collect_result_unit`] [#6227](https://github.com/rust-lang/rust-clippy/pull/6227)
35+
* [`manual_ok_or`] [#6233](https://github.com/rust-lang/rust-clippy/pull/6233)
36+
37+
### Moves and Deprecations
38+
39+
* Rename `single_char_push_str` to [`single_char_add_str`]
40+
[#6037](https://github.com/rust-lang/rust-clippy/pull/6037)
41+
* Rename `zero_width_space` to [`invisible_characters`]
42+
[#6105](https://github.com/rust-lang/rust-clippy/pull/6105)
43+
* Deprecate [`drop_bounds`] (uplifted)
44+
[#6111](https://github.com/rust-lang/rust-clippy/pull/6111)
45+
* Move [`string_lit_as_bytes`] to `nursery`
46+
[#6117](https://github.com/rust-lang/rust-clippy/pull/6117)
47+
* Move [`rc_buffer`] to `restriction`
48+
[#6128](https://github.com/rust-lang/rust-clippy/pull/6128)
49+
50+
### Enhancements
51+
52+
* [`manual_memcpy`]: Also lint when there are loop counters (and produce a
53+
reliable suggestion)
54+
[#5727](https://github.com/rust-lang/rust-clippy/pull/5727)
55+
* [`single_char_add_str`]: Also lint on `String::insert_str`
56+
[#6037](https://github.com/rust-lang/rust-clippy/pull/6037)
57+
* [`invisible_characters`]: Also lint the characters `\u{AD}` and `\u{2060}`
58+
[#6105](https://github.com/rust-lang/rust-clippy/pull/6105)
59+
* [`eq_op`]: Also lint on the `assert_*!` macro family
60+
[#6167](https://github.com/rust-lang/rust-clippy/pull/6167)
61+
* [`items_after_statements`]: Also lint in local macro expansions
62+
[#6176](https://github.com/rust-lang/rust-clippy/pull/6176)
63+
* [`unnecessary_cast`]: Also lint casts on integer and float literals
64+
[#6187](https://github.com/rust-lang/rust-clippy/pull/6187)
65+
* [`manual_unwrap_or`]: Also lint `Result::unwrap_or`
66+
[#6190](https://github.com/rust-lang/rust-clippy/pull/6190)
67+
* [`match_like_matches_macro`]: Also lint when `match` has more than two arms
68+
[#6216](https://github.com/rust-lang/rust-clippy/pull/6216)
69+
* [`integer_arithmetic`]: Better handle `/` an `%` operators
70+
[#6229](https://github.com/rust-lang/rust-clippy/pull/6229)
71+
72+
### False Positive Fixes
73+
74+
* [`needless_lifetimes`]: Bail out if the function has a `where` clause with the
75+
lifetime [#5978](https://github.com/rust-lang/rust-clippy/pull/5978)
76+
* [`explicit_counter_loop`]: No longer lints, when loop counter is used after it
77+
is incremented [#6076](https://github.com/rust-lang/rust-clippy/pull/6076)
78+
* [`or_fun_call`]: Revert changes addressing the handling of `const fn`
79+
[#6077](https://github.com/rust-lang/rust-clippy/pull/6077)
80+
* [`needless_range_loop`]: No longer lints, when the iterable is used in the
81+
range [#6102](https://github.com/rust-lang/rust-clippy/pull/6102)
82+
* [`inconsistent_digit_grouping`]: Fix bug when using floating point exponent
83+
[#6104](https://github.com/rust-lang/rust-clippy/pull/6104)
84+
* [`mistyped_literal_suffixes`]: No longer lints on the fractional part of a
85+
float (e.g. `713.32_64`)
86+
[#6114](https://github.com/rust-lang/rust-clippy/pull/6114)
87+
* [`invalid_regex`]: No longer lint on unicode characters within `bytes::Regex`
88+
[#6132](https://github.com/rust-lang/rust-clippy/pull/6132)
89+
* [`boxed_local`]: No longer lints on `extern fn` arguments
90+
[#6133](https://github.com/rust-lang/rust-clippy/pull/6133)
91+
* [`needless_lifetimes`]: Fix regression, where lifetime is used in `where`
92+
clause [#6198](https://github.com/rust-lang/rust-clippy/pull/6198)
93+
94+
### Suggestion Fixes/Improvements
95+
96+
* [`unnecessary_sort_by`]: Avoid dereferencing the suggested closure parameter
97+
[#6078](https://github.com/rust-lang/rust-clippy/pull/6078)
98+
* [`needless_arbitrary_self_type`]: Correctly handle expanded code
99+
[#6093](https://github.com/rust-lang/rust-clippy/pull/6093)
100+
* [`useless_format`]: Preserve raw strings in suggestion
101+
[#6151](https://github.com/rust-lang/rust-clippy/pull/6151)
102+
* [`empty_loop`]: Suggest alternatives
103+
[#6162](https://github.com/rust-lang/rust-clippy/pull/6162)
104+
* [`borrowed_box`]: Correctly add parentheses in suggestion
105+
[#6200](https://github.com/rust-lang/rust-clippy/pull/6200)
106+
* [`unused_unit`]: Improve suggestion formatting
107+
[#6247](https://github.com/rust-lang/rust-clippy/pull/6247)
108+
109+
### Documentation Improvements
110+
111+
* Some doc improvements:
112+
* [`rc_buffer`] [#6090](https://github.com/rust-lang/rust-clippy/pull/6090)
113+
* [`empty_loop`] [#6162](https://github.com/rust-lang/rust-clippy/pull/6162)
114+
* [`doc_markdown`]: Document problematic link text style
115+
[#6107](https://github.com/rust-lang/rust-clippy/pull/6107)
10116

11117
## Rust 1.48
12118

13-
Current beta, release 2020-11-19
119+
Current stable, released 2020-11-19
14120

15121
[09bd400...e636b88](https://github.com/rust-lang/rust-clippy/compare/09bd400...e636b88)
16122

@@ -56,15 +162,15 @@ Current beta, release 2020-11-19
56162

57163
* [`useless_attribute`]: permit allowing [`wildcard_imports`] and [`enum_glob_use`]
58164
[#5994](https://github.com/rust-lang/rust-clippy/pull/5994)
59-
* [`transmute_ptr_to_ptr`]: avoid suggesting dereferencing raw pointers in const contexts
165+
* [`transmute_ptr_to_ptr`]: avoid suggesting dereferencing raw pointers in const contexts
60166
[#5999](https://github.com/rust-lang/rust-clippy/pull/5999)
61167
* [`redundant_closure_call`]: take into account usages of the closure in nested functions and closures
62168
[#5920](https://github.com/rust-lang/rust-clippy/pull/5920)
63169
* Fix false positive in [`borrow_interior_mutable_const`] when referencing a field behind a pointer
64170
[#5949](https://github.com/rust-lang/rust-clippy/pull/5949)
65171
* [`doc_markdown`]: allow using "GraphQL" without backticks
66172
[#5996](https://github.com/rust-lang/rust-clippy/pull/5996)
67-
* [`to_string_in_display`]: avoid linting when calling `to_string()` on anything that is not `self`
173+
* [`to_string_in_display`]: avoid linting when calling `to_string()` on anything that is not `self`
68174
[#5971](https://github.com/rust-lang/rust-clippy/pull/5971)
69175
* [`indexing_slicing`] and [`out_of_bounds_indexing`] treat references to arrays as arrays
70176
[#6034](https://github.com/rust-lang/rust-clippy/pull/6034)
@@ -85,27 +191,27 @@ Current beta, release 2020-11-19
85191
[#5946](https://github.com/rust-lang/rust-clippy/pull/5946)
86192
* [`useless_conversion`]: show the type in the error message
87193
[#6035](https://github.com/rust-lang/rust-clippy/pull/6035)
88-
* [`unnecessary_mut_passed`]: discriminate between functions and methods in the error message
194+
* [`unnecessary_mut_passed`]: discriminate between functions and methods in the error message
89195
[#5892](https://github.com/rust-lang/rust-clippy/pull/5892)
90196
* [`float_cmp`] and [`float_cmp_const`]: change wording to make margin of error less ambiguous
91197
[#6043](https://github.com/rust-lang/rust-clippy/pull/6043)
92198
* [`default_trait_access`]: do not use unnecessary type parameters in the suggestion
93199
[#5993](https://github.com/rust-lang/rust-clippy/pull/5993)
94-
* [`collapsible_if`]: don't use expanded code in the suggestion
200+
* [`collapsible_if`]: don't use expanded code in the suggestion
95201
[#5992](https://github.com/rust-lang/rust-clippy/pull/5992)
96202
* Do not suggest empty format strings in [`print_with_newline`] and [`write_with_newline`]
97203
[#6042](https://github.com/rust-lang/rust-clippy/pull/6042)
98204
* [`unit_arg`]: improve the readability of the suggestion
99205
[#5931](https://github.com/rust-lang/rust-clippy/pull/5931)
100-
* [`stable_sort_primitive`]: print the type that is being sorted in the lint message
206+
* [`stable_sort_primitive`]: print the type that is being sorted in the lint message
101207
[#5935](https://github.com/rust-lang/rust-clippy/pull/5935)
102208
* Show line count and max lines in [`too_many_lines`] lint message
103209
[#6009](https://github.com/rust-lang/rust-clippy/pull/6009)
104210
* Keep parentheses in the suggestion of [`useless_conversion`] where applicable
105211
[#5900](https://github.com/rust-lang/rust-clippy/pull/5900)
106212
* [`option_map_unit_fn`] and [`result_map_unit_fn`]: print the unit type `()` explicitly
107213
[#6024](https://github.com/rust-lang/rust-clippy/pull/6024)
108-
* [`redundant_allocation`]: suggest replacing `Rc<Box<T>>` with `Rc<T>`
214+
* [`redundant_allocation`]: suggest replacing `Rc<Box<T>>` with `Rc<T>`
109215
[#5899](https://github.com/rust-lang/rust-clippy/pull/5899)
110216
* Make lint messages adhere to rustc dev guide conventions
111217
[#5893](https://github.com/rust-lang/rust-clippy/pull/5893)
@@ -128,7 +234,7 @@ Current beta, release 2020-11-19
128234

129235
## Rust 1.47
130236

131-
Current stable, released 2020-10-08
237+
Released 2020-10-08
132238

133239
[c2c07fa...09bd400](https://github.com/rust-lang/rust-clippy/compare/c2c07fa...09bd400)
134240

@@ -1787,6 +1893,7 @@ Released 2018-09-13
17871893
[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
17881894
[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
17891895
[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
1896+
[`let_underscore_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_drop
17901897
[`let_underscore_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_lock
17911898
[`let_underscore_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
17921899
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
@@ -1956,6 +2063,7 @@ Released 2018-09-13
19562063
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
19572064
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
19582065
[`string_extend_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_extend_chars
2066+
[`string_from_utf8_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_from_utf8_as_bytes
19592067
[`string_lit_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_lit_as_bytes
19602068
[`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string
19612069
[`struct_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
@@ -2006,6 +2114,7 @@ Released 2018-09-13
20062114
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
20072115
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
20082116
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
2117+
[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps
20092118
[`unneeded_field_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
20102119
[`unneeded_wildcard_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_wildcard_pattern
20112120
[`unnested_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns

src/tools/clippy/README.md

+13-19
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,22 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g
77

88
[There are over 400 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
99

10-
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
11-
12-
* `clippy::all` (everything that is on by default: all the categories below except for `nursery`, `pedantic`, and `cargo`)
13-
* `clippy::correctness` (code that is just **outright wrong** or **very very useless**, causes hard errors by default)
14-
* `clippy::style` (code that should be written in a more idiomatic way)
15-
* `clippy::complexity` (code that does something simple but in a complex way)
16-
* `clippy::perf` (code that can be written in a faster way)
17-
* `clippy::pedantic` (lints which are rather strict, off by default)
18-
* `clippy::nursery` (new lints that aren't quite ready yet, off by default)
19-
* `clippy::cargo` (checks against the cargo manifest, off by default)
10+
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
11+
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
12+
13+
Category | Description | Default level
14+
-- | -- | --
15+
`clippy::all` | all lints that are on by default (correctness, style, complexity, perf) | **warn/deny**
16+
`clippy::correctness` | code that is outright wrong or very useless | **deny**
17+
`clippy::style` | code that should be written in a more idiomatic way | **warn**
18+
`clippy::complexity` | code that does something simple but in a complex way | **warn**
19+
`clippy::perf` | code that can be written to run faster | **warn**
20+
`clippy::pedantic` | lints which are rather strict or might have false positives | allow
21+
`clippy::nursery` | new lints that are still under development | allow
22+
`clippy::cargo` | lints for the cargo manifest | allow
2023

2124
More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!
2225

23-
Only the following of those categories are enabled by default:
24-
25-
* `clippy::style`
26-
* `clippy::correctness`
27-
* `clippy::complexity`
28-
* `clippy::perf`
29-
30-
Other categories need to be enabled in order for their lints to be executed.
31-
3226
The [lint list](https://rust-lang.github.io/rust-clippy/master/index.html) also contains "restriction lints", which are
3327
for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used
3428
very selectively, if at all.

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
129129
if let ExprKind::Block(ref block, _) = arms[0].body.kind;
130130
if block.stmts.is_empty();
131131
if let Some(block_expr) = &block.expr;
132-
// inner block is optional. unwarp it if it exists, or use the expression as is otherwise.
132+
// inner block is optional. unwrap it if it exists, or use the expression as is otherwise.
133133
if let Some(begin_panic_call) = match block_expr.kind {
134134
ExprKind::Block(ref inner_block, _) => &inner_block.expr,
135135
_ => &block.expr,

src/tools/clippy/clippy_lints/src/await_holding_invalid.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ declare_clippy_lint! {
4545
/// }
4646
/// ```
4747
pub AWAIT_HOLDING_LOCK,
48-
correctness,
48+
pedantic,
4949
"Inside an async function, holding a MutexGuard while calling await"
5050
}
5151

@@ -65,8 +65,8 @@ declare_clippy_lint! {
6565
/// use std::cell::RefCell;
6666
///
6767
/// async fn foo(x: &RefCell<u32>) {
68-
/// let b = x.borrow_mut()();
69-
/// *ref += 1;
68+
/// let mut y = x.borrow_mut();
69+
/// *y += 1;
7070
/// bar.await;
7171
/// }
7272
/// ```
@@ -77,14 +77,14 @@ declare_clippy_lint! {
7777
///
7878
/// async fn foo(x: &RefCell<u32>) {
7979
/// {
80-
/// let b = x.borrow_mut();
81-
/// *ref += 1;
80+
/// let mut y = x.borrow_mut();
81+
/// *y += 1;
8282
/// }
8383
/// bar.await;
8484
/// }
8585
/// ```
8686
pub AWAIT_HOLDING_REFCELL_REF,
87-
correctness,
87+
pedantic,
8888
"Inside an async function, holding a RefCell ref while calling await"
8989
}
9090

src/tools/clippy/clippy_lints/src/cargo_common_metadata.rs

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ declare_clippy_lint! {
2323
/// [package]
2424
/// name = "clippy"
2525
/// version = "0.0.212"
26+
/// description = "A bunch of helpful lints to avoid common pitfalls in Rust"
27+
/// repository = "https://github.com/rust-lang/rust-clippy"
28+
/// readme = "README.md"
29+
/// license = "MIT OR Apache-2.0"
30+
/// keywords = ["clippy", "lint", "plugin"]
31+
/// categories = ["development-tools", "development-tools::cargo-plugins"]
32+
/// ```
33+
///
34+
/// Should include an authors field like:
35+
///
36+
/// ```toml
37+
/// # This `Cargo.toml` includes all common metadata
38+
/// [package]
39+
/// name = "clippy"
40+
/// version = "0.0.212"
2641
/// authors = ["Someone <[email protected]>"]
2742
/// description = "A bunch of helpful lints to avoid common pitfalls in Rust"
2843
/// repository = "https://github.com/rust-lang/rust-clippy"

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

+5
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,8 @@ declare_deprecated_lint! {
181181
pub TEMPORARY_CSTRING_AS_PTR,
182182
"this lint has been uplifted to rustc and is now called `temporary_cstring_as_ptr`"
183183
}
184+
185+
declare_deprecated_lint! {
186+
pub PANIC_PARAMS,
187+
"this lint has been uplifted to rustc and is now called `panic_fmt`"
188+
}

src/tools/clippy/clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ declare_clippy_lint! {
6969
}
7070

7171
declare_clippy_lint! {
72-
/// **What it does:** Checks for comparing to an empty slice such as "" or [],`
72+
/// **What it does:** Checks for comparing to an empty slice such as `""` or `[]`,
7373
/// and suggests using `.is_empty()` where applicable.
7474
///
7575
/// **Why is this bad?** Some structures can answer `.is_empty()` much faster

0 commit comments

Comments
 (0)