Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clippy #84001

Merged
merged 144 commits into from
Apr 8, 2021
Merged

Update Clippy #84001

merged 144 commits into from
Apr 8, 2021

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Apr 8, 2021

Biweekly Clippy update

r? @Manishearth

flip1995 and others added 30 commits March 25, 2021 19:29
Co-authored-by: Takayuki Nakata <[email protected]>
Update changelog for 1.52

I've underestimated the work that goes into this a bit, but it just shows that a lot has happened again in Clippy in 1.52 🙃.

[Rendered](https://github.com/xFrednet/rust-clippy/blob/changelog-1-52/CHANGELOG.md)

---

changelog: none
Fix bad suggestion when a reborrow might be required
Fix bad suggestion when the value being sliced is a macro call
Don't lint inside of a macro due to the previous context sensitive changes
Improve `redundant_slicing`

fixes: rust-lang#6968

changelog: Fix `redundant_slicing` suggestion when a reborrow might be required or when the value is from a macro call
Add MSRV options to `unnested_or_patterns`

changelog: [`unnested_or_patterns`] can now be configured with the `msrv` config/attribute.

Fixes rust-lang#6953
When the character next to `{}` is "shifted" (when mapping a byte index
in the format string to span) we should avoid shifting the span end
index, so first map the index of `}` to span, then bump the span,
instead of first mapping the next byte index to a span (which causes
bumping the end span too much).

Regression test added.

Fixes rust-lang#83344
Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
`len_without_is_empty` improvements

fixes: rust-lang#6958
fixes: rust-lang#6972

changelog: Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
changelog: Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
Add missing lints to MSRV config doc

r? `@giraffate`

changelog: Add missing lints to MSRV config doc
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in rust-lang#78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
look inside refs and detect if let &None = ...

Fixes rust-lang/rust-clippy#5396

changelog:  redundant_pattern_matching: look inside Refs to fix FNs with "if let &None = .. "
bors and others added 20 commits April 5, 2021 19:00
…, r=phansch

New Lint: `branches_sharing_code`

This lint checks if all `if`-blocks contain some statements that are the same and can be moved out of the blocks to prevent code duplication. Here is an example:

```rust
let _ = if ... {
    println!("Start"); // <-- Lint for code duplication
    let _a = 99;
    println!("End"); // <-- Lint for code duplication
    false
} else {
    println!("Start");
    let _b = 17;
    println!("End");
    false
};
```

This could be written as:

```rust
println!("Start");

let _ = if ... {
    let _a = 99;
    false
} else {
    let _b = 17;
    false
};

println!("End");
```

---

This lint will get masked by the `IF_SAME_THEN_ELSE` lint. I think it makes more sense to only emit one lint per if block. This means that the folloing example:

```rust
if ... {
    let _a = 17;
} else {
    let _a = 17;
}
```

Will only trigger the `IF_SAME_THEN_ELSE` lint and not the `SHARED_CODE_IN_IF_BLOCKS` lint.

---

closes: rust-lang#5234

changelog: Added a new lint: `branches_sharing_code`

And hello to the one that is writing the changelog for this release :D
fix `missing_panics_doc` not detecting `assert_eq!` and `assert_ne!`

fixes rust-lang#6997
changelog: `missing_panics_doc` detects `assert_eq!` and `assert_ne!`

---
searching for `assert_eq!` and `assert_ne!` in `FindPanicUnwrap`
Don't trigger `same_item_push` if the vec is used in the loop body

fixes rust-lang#6987
changelog: `same_item_push`: Don't trigger if the `vec` is used in the loop body
consider mutability on useless_vec suggestions

fixes rust-lang#7035

changelog: Now the suggested by `useless_vec` considers mutability to suggest either `&[]`, as before, or `&mut []` if the used reference is mutable.
…1995

Fix all occurences `needless_borrow` internally

The bug that got 'needless_borrow' moved into the nursery was fixed two years ago in d4370f8.

This did trigger over a thousand times internally, so that's all the other changes. I vetted most of them, but there's a lot The only interesting change is to the lint list. `declare_tool_lint` already makes a reference, so there's no need to take a reference to the lints.

changelog: None
Remove some dead utils

changelog: none
Use AnonConst for asm! constants

This replaces the old system which used explicit promotion. See rust-lang#83169 for more background.

The syntax for `const` operands is still the same as before: `const <expr>`.

Fixes rust-lang#83169

Because the implementation is heavily based on inline consts, we suffer from the same issues:
- We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`.
- We are hitting the same ICEs as inline consts, for example rust-lang#78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
Rustup

changelog: none

r? `@ghost`
@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2021

📌 Commit 6b37cd3 has been approved by Manishearth

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 8, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 8, 2021
Update Clippy

Biweekly Clippy update

r? `@Manishearth`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 8, 2021
Rollup of 6 pull requests

Successful merges:

 - rust-lang#80733 (Improve links in inline code in `core::pin`.)
 - rust-lang#81764 (Stabilize `rustdoc::bare_urls` lint)
 - rust-lang#81938 (Stabilize `peekable_peek_mut`)
 - rust-lang#83980 (Fix outdated crate names in compiler docs)
 - rust-lang#83992 (Merge idents when generating source content)
 - rust-lang#84001 (Update Clippy)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f77be84 into rust-lang:master Apr 8, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 8, 2021
@flip1995 flip1995 deleted the clippyup branch April 9, 2021 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.