Commit Graph

13449 Commits

Author SHA1 Message Date
Liu Dingming
6cc2eeaa56 Suggest into_iter() over drain(..)
Add doc

Add description

iter_with_drain dogfood

Disable emiting on struct field.

Fix clippy

Add eq_path for SpanlessEq

Fix tests

Better error message

Fix doc test

Fix version

Apply suggestions
2022-03-03 13:10:19 +08:00
bors
6e211eac7c Auto merge of #8489 - smoelius:unnecessary-find-map, r=llogiq
Add `unnecessary_find_map` lint

This PR adds an `unnecessary_find_map` lint. It is essentially just a minor enhancement of `unnecessary_filter_map`.

Closes #8467

changelog: New lint `unnecessary_find_map`
2022-03-02 19:50:27 +00:00
bors
2e40dc81b7 Auto merge of #8456 - ebobrow:use_self_pat, r=llogiq
check `use_self` in `pat`

fixes #6955

changelog: check `use_self` in `pat`
2022-03-02 19:31:22 +00:00
bors
27869d6d46 Auto merge of #8174 - rust-lang:missing-spin-loop, r=flip1995
new lint: `missing-spin-loop`

This fixes #7809. I went with the shorter name because the function is called `std::hint::spin_loop`. It doesn't yet detect `while let` loops. I left that for a follow-up PR.

---

changelog: new lint: [`missing_spin_loop`]
2022-03-02 19:12:32 +00:00
Andre Bogus
9f1080cc6e new lint: missing-spin-loop 2022-03-02 19:31:06 +01:00
bors
14f3d05939 Auto merge of #8432 - dtolnay-contrib:transmuteundefinedrepr2, r=Manishearth
Transmute_undefined_repr to nursery again

This PR reinstates #8418, which was reverted in #8425 (incorrectly I think).

I don't want to start a revert war over this but I feel very strongly that this lint is not in a state that would be a net benefit to users of clippy. In its current form, making this an enabled-by-default `correctness` lint with authoritative-sounding proclamations of undefined behavior does more harm than the benefit of the true positive cases.

I can file a bunch more examples of false positives but I don't want to give the author of this lint the impression that it is ready to graduate from `nursery` as soon as I've exhausted the amount of time I am willing to spend revising this lint.

Instead I would recommend that the author of the lint try running it on some reputable codebases containing transmutes. Everywhere that the lint triggers please consider critically whether it should be triggering. For cases that you think are true positives, please raise a few of them with the crate authors (in a PR or issue) to better understand their perspective if they think the transmute is correct.

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Re-remove [`transmute_undefined_repr`] from default set of enabled lints
2022-03-02 17:05:06 +00:00
bors
1a25d190e7 Auto merge of #8491 - matthiaskrgr:no_num_cpus, r=flip1995
tests: use std:🧵:available_parallelism() instead of num_cpus to get thread count

removes the dependency added in https://github.com/rust-lang/rust-clippy/pull/8451
---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: tests: use std:🧵:available_parallelism() instead of num_cpus to get thread count
2022-03-02 09:26:11 +00:00
Samuel E. Moelius III
2a588d810f Add unnecessary_find_map lint 2022-03-01 19:24:55 -05:00
Matthias Krüger
7a15061fbc tests: use std:🧵:available_parallelism() instead of num_cpus to get thread count
removes the dependency added in https://github.com/rust-lang/rust-clippy/pull/8451
2022-03-01 21:32:18 +01:00
bors
b8a205aeb8 Auto merge of #8488 - flip1995:ci-cargo-dev-new-lint, r=llogiq
Move testing of cargo dev new_lint to cargo dev workflow

This should be placed there. No need to run this in PR CI, if clippy_dev
isn't touched. (It will be run by bors anyway)

changelog: none
2022-03-01 20:05:21 +00:00
bors
28b1fe5129 Auto merge of #8313 - flip1995:msrv-internal-lint, r=xFrednet
Implement internal lint for MSRV lints

This internal lint checks if the `extract_msrv_attrs!` macro is used if
a lint has a MSRV. If not, it suggests to add this attribute to the lint
pass implementation.

Following up https://github.com/rust-lang/rust-clippy/pull/8280#discussion_r785226072. This currently doesn't implement the documentation check. But since this is just an extension of this lint, I think this is a good MVP of this lint.

r? `@camsteffen`

cc `@xFrednet`

changelog: none
2022-03-01 17:40:52 +00:00
flip1995
73944645aa
Move testing of cargo dev new_lint to cargo dev workflow
This should be placed there. No need to run this in PR CI, if clippy_dev
isn't touched. (It will be run by bors anyway)
2022-03-01 10:10:01 +00:00
flip1995
bca4ee7971
Implement internal lint for MSRV lints
This internal lint checks if the `extract_msrv_attrs!` macro is used if
a lint has a MSRV. If not, it suggests to add this attribute to the lint
pass implementation.
2022-03-01 09:40:07 +00:00
bors
e511476f24 Auto merge of #8479 - smoelius:unnecessary-filter-map, r=llogiq
Fix some `unnecessary_filter_map` false positives

This is a proposed fix for #4433.

It moves `clone_or_copy_needed` out of `unnecessary_iter_cloned.rs` and into `methods::utils`. It then adds a check of this function to `unnecessary_filter_map::check`.

Fixes #4433

changelog: none
2022-02-28 20:09:18 +00:00
Samuel E. Moelius III
d123ffc6c7 Check clone_or_copy_needed in unnecessary_filter_map::check 2022-02-28 05:24:00 -05:00
Samuel E. Moelius III
cfd32522c0 Add tests to tests/ui/unnecessary_filter_map.rs
The tests currently fail, and are fixed by the next commit.
2022-02-28 05:24:00 -05:00
bors
8d12cd4779 Auto merge of #8476 - xFrednet:0000-update-edition-for-rustfmt, r=giraffate
Update edition in rustfmt.toml

I noticed that our `rustfmt.toml` still has the edition 2018 listed. This updates the configuration to use 2021.

This luckily doesn't introduce any formatting changes 🙃

changelog: none
2022-02-27 13:01:04 +00:00
xFrednet
acddac4b96
Update edition in rustfmt.toml 2022-02-26 20:33:47 +01:00
Elliot Bobrow
914ae1e849 check use_self in pat 2022-02-26 09:23:29 -08:00
bors
d1ca1c1d0c Auto merge of #8462 - ken-matsui:use-precise-namespace-for-reverse, r=llogiq
Use the precise namespace for `Reverse`

Closes: https://github.com/rust-lang/rust-clippy/issues/8461

changelog: [`unnecessary_sort_by`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by): Use the precise namespace for `Reverse`
2022-02-26 14:49:39 +00:00
bors
e329249b6a Auto merge of #8464 - Jarcho:ptr_arg_8463, r=camsteffen
Fix `ptr_arg`

fixes: #8463

changelog: Fix `ptr_arg` when multiple arguments are being checked in one function
2022-02-26 03:00:53 +00:00
bors
2c8d5a2500 Auto merge of #8453 - tamaroning:fix_large_enum_variant, r=camsteffen
fix false positives of large_enum_variant

fixes: #8321
The size of enums containing generic type was calculated to be 0.
I changed [large_enum_variant] so that such enums are not linted.

changelog: none
2022-02-26 02:42:43 +00:00
bors
8bba6b7af0 Auto merge of #8253 - Alexendoo:print-in-fmt, r=camsteffen
Add `print_in_format_impl` lint

changelog: new lint: [`print_in_format_impl`]

Lints the use of `print`-like macros in manual `Display`/`Debug` impls. I feel like I make this mistake every time I write one 😄

r? `@camsteffen`
2022-02-25 21:12:14 +00:00
Alex Macleod
52f3d61a2a Add print_in_format_impl lint 2022-02-25 21:10:06 +00:00
Alex Macleod
bcbb07f4dc Rename RecursiveFormatImpl to FormatImpl 2022-02-25 18:22:55 +00:00
bors
4417f78e91 Auto merge of #8474 - Alexendoo:paths, r=Manishearth
Replace some more paths with diagnostic items

cc #5393

Replaces the macro & mem paths, and catches a couple others that were unused

changelog: none
2022-02-25 16:07:59 +00:00
bors
95897bfcf2 Auto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_not_trigger_on_doc_hidden_items, r=flip1995
Disable ``[`new-without-default`]`` for new() methods that are marked…

… with '#[doc(hidden)]'

Fixes #8152

changelog: Disable ``[`new-without-default`]`` for new() methods that are marked with `#[doc(hidden)]`
2022-02-25 15:51:37 +00:00
Alex Macleod
2955db493e Replace some more paths with diagnostic items 2022-02-25 15:38:06 +00:00
Florian Nagel
862211d540 Disable `[new-without-default]` for new() methods that are marked with '#[doc(hidden)]'
Fixes issue #8152
2022-02-25 16:34:37 +01:00
bors
7b2896a8fc Auto merge of #8468 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-02-24 18:37:57 +00:00
flip1995
ce1904f6cf
Bump nightly version -> 2022-02-24 2022-02-24 19:33:10 +01:00
flip1995
5ece8d2bc4
Bump Clippy Version -> 0.1.61 2022-02-24 19:32:47 +01:00
flip1995
fd495a0654
Merge remote-tracking branch 'upstream/master' into rustup 2022-02-24 19:32:17 +01:00
bors
042892a081 Auto merge of #8466 - tamaroning:fix_reduntant_closure, r=Manishearth
False positive redundant_closure when using ref pattern in closure params

fixes #8460
Fixed [redundant_closure] so that closures of which params bound as `ref` or `ref mut ` doesn't trigger the lint.
(e.g. `|ref x| some_expr` doesn't trigger the lint.)
changelog: none
2022-02-23 18:26:30 +00:00
tamaron
31b49b0be8 fix typo 2022-02-24 00:25:07 +09:00
tamaron
db62821c03 fix 2022-02-24 00:16:24 +09:00
Jason Newcomb
382b3f0601 Fix counting the number of unchangeable arguments in ptr_arg 2022-02-23 01:04:49 -05:00
bors
7f8760a44c Auto merge of #8451 - matthiaskrgr:ui_speedup, r=llogiq
tests: default to more threads for ui-tests

Benchmarks (tested on i5-7200U, 2 cores, 4 threads)

```
master branch:

cargo test // prime caches
cargo --color=always test  70,39s user 21,91s system 180% cpu 51,035 total
cargo --color=always test  70,77s user 22,13s system 180% cpu 51,579 total
cargo --color=always test  70,97s user 22,12s system 180% cpu 51,673 total

cargo --color=always nextest run  78,74s user 22,27s system 220% cpu 45,829 total
cargo --color=always nextest run  78,46s user 21,92s system 224% cpu 44,674 total
cargo --color=always nextest run  78,31s user 22,21s system 228% cpu 43,909 total

Patched (ui_speedup branch):

cargo test // prime cache
cargo --color=always test  97,51s user 32,02s system 288% cpu 44,905 total
cargo --color=always test  99,19s user 31,91s system 276% cpu 47,436 total
cargo --color=always test  98,47s user 31,84s system 284% cpu 45,744 total

cargo --color=always nextest run  102,18s user 30,80s system 350% cpu 37,902 total
cargo --color=always nextest run  99,75s user 29,86s system 350% cpu 36,935 total
cargo --color=always nextest run  100,36s user 29,93s system 351% cpu 37,061 total
```

changelog: use more threads for running clippys ui-tests for ~10% walltime speedup
2022-02-22 21:58:24 +00:00
Ken Matsui
7412e6976e
Use the precise namespace for Reverse 2022-02-23 06:06:09 +09:00
bors
9e605ef80f Auto merge of #8443 - Jarcho:match_cfg_arm, r=flip1995
Don't lint `match` expressions with `cfg`ed arms

Somehow there are no open issues related to this for any of the affected lints. At least none that I could fine from a quick search.

changelog: Don't lint `match` expressions with `cfg`ed arms in many cases
2022-02-21 08:46:42 +00:00
lcnr
e390e6c469 update clippy 2022-02-21 07:09:11 +01:00
tamaron
e3b5cac3c8 fix 2022-02-21 13:25:53 +09:00
Matthias Krüger
a89c7958f5 tests: default to more threads for ui-tests
Benchmarks (tested on i5-7200U, 2 core 4 threads)

```
master branch:

cargo test // prime caches
cargo --color=always test  70,39s user 21,91s system 180% cpu 51,035 total
cargo --color=always test  70,77s user 22,13s system 180% cpu 51,579 total
cargo --color=always test  70,97s user 22,12s system 180% cpu 51,673 total

cargo --color=always nextest run  78,74s user 22,27s system 220% cpu 45,829 total
cargo --color=always nextest run  78,46s user 21,92s system 224% cpu 44,674 total
cargo --color=always nextest run  78,31s user 22,21s system 228% cpu 43,909 total

Patched (ui_speedup branch)

cargo test // prime cache
cargo --color=always test  97,51s user 32,02s system 288% cpu 44,905 total
cargo --color=always test  99,19s user 31,91s system 276% cpu 47,436 total
cargo --color=always test  98,47s user 31,84s system 284% cpu 45,744 total

cargo --color=always nextest run  102,18s user 30,80s system 350% cpu 37,902 total
cargo --color=always nextest run  99,75s user 29,86s system 350% cpu 36,935 total
cargo --color=always nextest run  100,36s user 29,93s system 351% cpu 37,061 total
```
2022-02-20 14:07:41 +01:00
David Tolnay
fd9dd04972
Transmute_undefined_repr to nursery again 2022-02-18 15:39:29 -08:00
bors
29ee5e25d1 Auto merge of #8440 - Jarcho:transmute_undefined, r=Manishearth
Some more fixes for `transmute_undefined_repr`

changelog: Fix transmuting a struct containing a pointer into a pointer in `transmute_undefined_repr`
changelog: Allow various forms of type erasure in `transmute_undefined_repr`
2022-02-18 22:48:23 +00:00
Jason Newcomb
78345b4d09 Clarify cfg detection process in matches.rs 2022-02-18 15:41:46 -05:00
Jason Newcomb
d28d19d74c Fix transmute_undefined_repr when converting between a fat pointer and a type containing a fat pointer 2022-02-18 15:02:28 -05:00
Jason Newcomb
7c07022c98 Allow transmuting fat pointers to some types in transmute_undefined_repr 2022-02-18 15:02:28 -05:00
Jason Newcomb
447a24588a Allow various type erasure patterns in transmute_undefined_repr 2022-02-18 15:02:25 -05:00
Jason Newcomb
01732b6019 Add some comments to transmute_undefined_repr 2022-02-18 15:01:58 -05:00