Skip to content

Commit a985d8e

Browse files
committed
Auto merge of #87579 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents 5fb3394 + 8570a36 commit a985d8e

File tree

284 files changed

+3439
-3116
lines changed

Some content is hidden

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

284 files changed

+3439
-3116
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ dependencies = [
542542

543543
[[package]]
544544
name = "clippy"
545-
version = "0.1.55"
545+
version = "0.1.56"
546546
dependencies = [
547547
"cargo_metadata 0.12.0",
548548
"clippy_lints",
@@ -575,7 +575,7 @@ dependencies = [
575575

576576
[[package]]
577577
name = "clippy_lints"
578-
version = "0.1.55"
578+
version = "0.1.56"
579579
dependencies = [
580580
"cargo_metadata 0.12.0",
581581
"clippy_utils",
@@ -596,7 +596,7 @@ dependencies = [
596596

597597
[[package]]
598598
name = "clippy_utils"
599-
version = "0.1.55"
599+
version = "0.1.56"
600600
dependencies = [
601601
"if_chain",
602602
"itertools 0.9.0",

src/tools/clippy/.github/deploy.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ rm -rf out/master/ || exit 0
88
echo "Making the docs for master"
99
mkdir out/master/
1010
cp util/gh-pages/index.html out/master
11-
python3 ./util/export.py out/master/lints.json
11+
cp util/gh-pages/lints.json out/master
1212

1313
if [[ -n $TAG_NAME ]]; then
1414
echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
15-
cp -r out/master "out/$TAG_NAME"
16-
rm -f out/stable
17-
ln -s "$TAG_NAME" out/stable
15+
cp -Tr out/master "out/$TAG_NAME"
16+
ln -sf "$TAG_NAME" out/stable
1817
fi
1918

2019
if [[ $BETA = "true" ]]; then
@@ -28,8 +27,8 @@ cp util/gh-pages/versions.html out/index.html
2827
echo "Making the versions.json file"
2928
python3 ./util/versions.py out
3029

31-
cd out
3230
# Now let's go have some fun with the cloned repo
31+
cd out
3332
git config user.name "GHA CI"
3433
git config user.email "[email protected]"
3534

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,23 @@ jobs:
3939
if: github.ref == 'refs/heads/beta'
4040
run: echo "BETA=true" >> $GITHUB_ENV
4141

42-
- name: Use scripts and templates from master branch
42+
# We need to check out all files that (transitively) depend on the
43+
# structure of the gh-pages branch, so that we're able to change that
44+
# structure without breaking the deployment.
45+
- name: Use deploy files from master branch
4346
run: |
4447
git fetch --no-tags --prune --depth=1 origin master
45-
git checkout origin/master -- .github/deploy.sh util/gh-pages/ util/*.py
48+
git checkout origin/master -- .github/deploy.sh util/versions.py util/gh-pages/versions.html
49+
50+
# Generate lockfile for caching to avoid build problems with cached deps
51+
- name: cargo generate-lockfile
52+
run: cargo generate-lockfile
53+
54+
- name: Cache
55+
uses: Swatinem/[email protected]
56+
57+
- name: cargo collect-metadata
58+
run: cargo collect-metadata
4659

4760
- name: Deploy
4861
run: |

src/tools/clippy/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,6 @@ Released 2018-09-13
24232423
<!-- begin autogenerated links to lint list -->
24242424
[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
24252425
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
2426-
[`append_instead_of_extend`]: https://rust-lang.github.io/rust-clippy/master/index.html#append_instead_of_extend
24272426
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
24282427
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
24292428
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
@@ -2522,6 +2521,7 @@ Released 2018-09-13
25222521
[`explicit_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
25232522
[`explicit_write`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_write
25242523
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
2524+
[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
25252525
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
25262526
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
25272527
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
@@ -2772,7 +2772,7 @@ Released 2018-09-13
27722772
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
27732773
[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
27742774
[`self_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
2775-
[`self_named_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructor
2775+
[`self_named_constructors`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructors
27762776
[`semicolon_if_nothing_returned`]: https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
27772777
[`serde_api_misuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse
27782778
[`shadow_reuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse

src/tools/clippy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.55"
3+
version = "0.1.56"
44
authors = ["The Rust Clippy Developers"]
55
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
66
repository = "https://github.com/rust-lang/rust-clippy"

src/tools/clippy/clippy_dev/src/new_lint.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,11 @@ use rustc_session::{{declare_lint_pass, declare_tool_lint}};
169169
{pass_import}
170170
171171
declare_clippy_lint! {{
172-
/// **What it does:**
172+
/// ### What it does
173173
///
174-
/// **Why is this bad?**
175-
///
176-
/// **Known problems:** None.
177-
///
178-
/// **Example:**
174+
/// ### Why is this bad?
179175
///
176+
/// ### Example
180177
/// ```rust
181178
/// // example code where clippy issues a warning
182179
/// ```

src/tools/clippy/clippy_dev/src/serve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub fn run(port: u16, lint: Option<&str>) -> ! {
1515

1616
loop {
1717
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
18-
Command::new("python3")
19-
.arg("util/export.py")
18+
Command::new("cargo")
19+
.arg("collect-metadata")
2020
.spawn()
2121
.unwrap()
2222
.wait()

src/tools/clippy/clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.1.55"
4+
version = "0.1.56"
55
# end automatic update
66
authors = ["The Rust Clippy Developers"]
77
description = "A bunch of helpful lints to avoid common pitfalls in Rust"

src/tools/clippy/clippy_lints/src/absurd_extreme_comparisons.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@ use clippy_utils::ty::is_isize_or_usize;
1111
use clippy_utils::{clip, int_bits, unsext};
1212

1313
declare_clippy_lint! {
14-
/// **What it does:** Checks for comparisons where one side of the relation is
14+
/// ### What it does
15+
/// Checks for comparisons where one side of the relation is
1516
/// either the minimum or maximum value for its type and warns if it involves a
1617
/// case that is always true or always false. Only integer and boolean types are
1718
/// checked.
1819
///
19-
/// **Why is this bad?** An expression like `min <= x` may misleadingly imply
20+
/// ### Why is this bad?
21+
/// An expression like `min <= x` may misleadingly imply
2022
/// that it is possible for `x` to be less than the minimum. Expressions like
2123
/// `max < x` are probably mistakes.
2224
///
23-
/// **Known problems:** For `usize` the size of the current compile target will
25+
/// ### Known problems
26+
/// For `usize` the size of the current compile target will
2427
/// be assumed (e.g., 64 bits on 64 bit systems). This means code that uses such
2528
/// a comparison to detect target pointer width will trigger this lint. One can
2629
/// use `mem::sizeof` and compare its value or conditional compilation
2730
/// attributes
2831
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
2932
///
30-
/// **Example:**
31-
///
33+
/// ### Example
3234
/// ```rust
3335
/// let vec: Vec<isize> = Vec::new();
3436
/// if vec.len() <= 0 {}

src/tools/clippy/clippy_lints/src/approx_const.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ use rustc_span::symbol;
77
use std::f64::consts as f64;
88

99
declare_clippy_lint! {
10-
/// **What it does:** Checks for floating point literals that approximate
10+
/// ### What it does
11+
/// Checks for floating point literals that approximate
1112
/// constants which are defined in
1213
/// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)
1314
/// or
1415
/// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),
1516
/// respectively, suggesting to use the predefined constant.
1617
///
17-
/// **Why is this bad?** Usually, the definition in the standard library is more
18+
/// ### Why is this bad?
19+
/// Usually, the definition in the standard library is more
1820
/// precise than what people come up with. If you find that your definition is
1921
/// actually more precise, please [file a Rust
2022
/// issue](https://github.com/rust-lang/rust/issues).
2123
///
22-
/// **Known problems:** None.
23-
///
24-
/// **Example:**
24+
/// ### Example
2525
/// ```rust
2626
/// let x = 3.14;
2727
/// let y = 1_f64 / x;

src/tools/clippy/clippy_lints/src/arithmetic.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
66
use rustc_span::source_map::Span;
77

88
declare_clippy_lint! {
9-
/// **What it does:** Checks for integer arithmetic operations which could overflow or panic.
9+
/// ### What it does
10+
/// Checks for integer arithmetic operations which could overflow or panic.
1011
///
1112
/// Specifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable
1213
/// of overflowing according to the [Rust
1314
/// Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow),
1415
/// or which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is
1516
/// attempted.
1617
///
17-
/// **Why is this bad?** Integer overflow will trigger a panic in debug builds or will wrap in
18+
/// ### Why is this bad?
19+
/// Integer overflow will trigger a panic in debug builds or will wrap in
1820
/// release mode. Division by zero will cause a panic in either mode. In some applications one
1921
/// wants explicitly checked, wrapping or saturating arithmetic.
2022
///
21-
/// **Known problems:** None.
22-
///
23-
/// **Example:**
23+
/// ### Example
2424
/// ```rust
2525
/// # let a = 0;
2626
/// a + 1;
@@ -31,14 +31,14 @@ declare_clippy_lint! {
3131
}
3232

3333
declare_clippy_lint! {
34-
/// **What it does:** Checks for float arithmetic.
34+
/// ### What it does
35+
/// Checks for float arithmetic.
3536
///
36-
/// **Why is this bad?** For some embedded systems or kernel development, it
37+
/// ### Why is this bad?
38+
/// For some embedded systems or kernel development, it
3739
/// can be useful to rule out floating-point numbers.
3840
///
39-
/// **Known problems:** None.
40-
///
41-
/// **Example:**
41+
/// ### Example
4242
/// ```rust
4343
/// # let a = 0.0;
4444
/// a + 1.0;

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use rustc_middle::lint::in_external_macro;
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66

77
declare_clippy_lint! {
8-
/// **What it does:** Checks for usage of `as` conversions.
8+
/// ### What it does
9+
/// Checks for usage of `as` conversions.
910
///
1011
/// Note that this lint is specialized in linting *every single* use of `as`
1112
/// regardless of whether good alternatives exist or not.
@@ -15,14 +16,13 @@ declare_clippy_lint! {
1516
/// There is a good explanation the reason why this lint should work in this way and how it is useful
1617
/// [in this issue](https://github.com/rust-lang/rust-clippy/issues/5122).
1718
///
18-
/// **Why is this bad?** `as` conversions will perform many kinds of
19+
/// ### Why is this bad?
20+
/// `as` conversions will perform many kinds of
1921
/// conversions, including silently lossy conversions and dangerous coercions.
2022
/// There are cases when it makes sense to use `as`, so the lint is
2123
/// Allow by default.
2224
///
23-
/// **Known problems:** None.
24-
///
25-
/// **Example:**
25+
/// ### Example
2626
/// ```rust,ignore
2727
/// let a: u32;
2828
/// ...

src/tools/clippy/clippy_lints/src/asm_syntax.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr
5353
}
5454

5555
declare_clippy_lint! {
56-
/// **What it does:** Checks for usage of Intel x86 assembly syntax.
56+
/// ### What it does
57+
/// Checks for usage of Intel x86 assembly syntax.
5758
///
58-
/// **Why is this bad?** The lint has been enabled to indicate a preference
59+
/// ### Why is this bad?
60+
/// The lint has been enabled to indicate a preference
5961
/// for AT&T x86 assembly syntax.
6062
///
61-
/// **Known problems:** None.
62-
///
63-
/// **Example:**
63+
/// ### Example
6464
///
6565
/// ```rust,no_run
6666
/// # #![feature(asm)]
@@ -89,14 +89,14 @@ impl EarlyLintPass for InlineAsmX86IntelSyntax {
8989
}
9090

9191
declare_clippy_lint! {
92-
/// **What it does:** Checks for usage of AT&T x86 assembly syntax.
92+
/// ### What it does
93+
/// Checks for usage of AT&T x86 assembly syntax.
9394
///
94-
/// **Why is this bad?** The lint has been enabled to indicate a preference
95+
/// ### Why is this bad?
96+
/// The lint has been enabled to indicate a preference
9597
/// for Intel x86 assembly syntax.
9698
///
97-
/// **Known problems:** None.
98-
///
99-
/// **Example:**
99+
/// ### Example
100100
///
101101
/// ```rust,no_run
102102
/// # #![feature(asm)]

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99

1010
declare_clippy_lint! {
11-
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
11+
/// ### What it does
12+
/// Checks for `assert!(true)` and `assert!(false)` calls.
1213
///
13-
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
14+
/// ### Why is this bad?
15+
/// Will be optimized out by the compiler or should probably be replaced by a
1416
/// `panic!()` or `unreachable!()`
1517
///
16-
/// **Known problems:** None
18+
/// ### Known problems
19+
/// None
1720
///
18-
/// **Example:**
21+
/// ### Example
1922
/// ```rust,ignore
2023
/// assert!(false)
2124
/// assert!(true)

src/tools/clippy/clippy_lints/src/assign_ops.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ use rustc_middle::hir::map::Map;
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313

1414
declare_clippy_lint! {
15-
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
15+
/// ### What it does
16+
/// Checks for `a = a op b` or `a = b commutative_op a`
1617
/// patterns.
1718
///
18-
/// **Why is this bad?** These can be written as the shorter `a op= b`.
19+
/// ### Why is this bad?
20+
/// These can be written as the shorter `a op= b`.
1921
///
20-
/// **Known problems:** While forbidden by the spec, `OpAssign` traits may have
22+
/// ### Known problems
23+
/// While forbidden by the spec, `OpAssign` traits may have
2124
/// implementations that differ from the regular `Op` impl.
2225
///
23-
/// **Example:**
26+
/// ### Example
2427
/// ```rust
2528
/// let mut a = 5;
2629
/// let b = 0;
@@ -37,17 +40,20 @@ declare_clippy_lint! {
3740
}
3841

3942
declare_clippy_lint! {
40-
/// **What it does:** Checks for `a op= a op b` or `a op= b op a` patterns.
43+
/// ### What it does
44+
/// Checks for `a op= a op b` or `a op= b op a` patterns.
4145
///
42-
/// **Why is this bad?** Most likely these are bugs where one meant to write `a
46+
/// ### Why is this bad?
47+
/// Most likely these are bugs where one meant to write `a
4348
/// op= b`.
4449
///
45-
/// **Known problems:** Clippy cannot know for sure if `a op= a op b` should have
50+
/// ### Known problems
51+
/// Clippy cannot know for sure if `a op= a op b` should have
4652
/// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore, it suggests both.
4753
/// If `a op= a op b` is really the correct behaviour it should be
4854
/// written as `a = a op a op b` as it's less confusing.
4955
///
50-
/// **Example:**
56+
/// ### Example
5157
/// ```rust
5258
/// let mut a = 5;
5359
/// let b = 2;

0 commit comments

Comments
 (0)