Commit Graph

7102 Commits

Author SHA1 Message Date
bors
53189ad190 Auto merge of #8500 - rust-lang:testless-dbg-macro, r=Manishearth
Omit dbg_macro in test code

This fixes #8481.

---

changelog: none
2022-03-03 18:32:07 +00:00
Andre Bogus
63907234d7 Omit dbg_macro in test code 2022-03-03 19:28:05 +01:00
bors
c5faf992d2 Auto merge of #8414 - MiSawa:fix/optimize-redundant-clone, r=oli-obk
Optimize `redundant_clone`

Fixes #8412

changelog: none
2022-03-03 14:47:49 +00:00
bors
d56f457715 Auto merge of #8483 - ldm0:iter_with_drain_simple, r=flip1995,giraffate
Use `.into_iter()` rather than `.drain(..)`

Replacing `.drain(..)` with `.into_iter()` makes my project's binary size smaller.

Fixes #1908

Applicability of this suggestion is `MaybeIncorrect` rather than `MachineApplicable` due to the complexity of "checking otherwise usage" X-|

changelog: Add new lint [`iter_with_drain`]
2022-03-03 13:36:49 +00:00
bors
ef4af1d2d8 Auto merge of #8497 - Manishearth:transmute-undefined-repr-note, r=flip1995
comment about transmute_undefined_repr in nursery

See discussion in https://github.com/rust-lang/rust-clippy/pull/8432

changelog: none
2022-03-03 09:05:21 +00:00
Manish Goregaokar
78547b1716
comment about transmute_undefined_repr in nursery 2022-03-03 09:03:27 +00:00
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
Samuel E. Moelius III
2a588d810f Add unnecessary_find_map lint 2022-03-01 19:24:55 -05: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
Samuel E. Moelius III
d123ffc6c7 Check clone_or_copy_needed in unnecessary_filter_map::check 2022-02-28 05:24:00 -05: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
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
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
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
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
mi_sawa
6d2a04250c Don't assume DAG 2022-02-23 13:38:48 +09: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
David Tolnay
fd9dd04972
Transmute_undefined_repr to nursery again 2022-02-18 15:39:29 -08: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
Jason Newcomb
c02dff7167 Fix transmute_undefined_repr when converting between a pointer and a type containing a pointer 2022-02-18 15:01:58 -05:00
Jason Newcomb
88ecdd0804 Extract some util functions 2022-02-18 09:45:11 -05:00
Jason Newcomb
90bb7a3476 New lint cast_enum_truncation 2022-02-18 09:16:17 -05:00
Jason Newcomb
8a466454ab Lint enum-to-int casts with cast_possible_truncation 2022-02-18 09:11:15 -05:00
bors
02f3c17593 Auto merge of #8419 - flip1995:await_parking_alot, r=llogiq
Fix `await_holding_lock` not linting `parking_lot` Mutex/RwLock

This adds tests for `RwLock` and `parking_lot::{Mutex, RwLock}`, which were added before in 2dc8c083f5, but never tested in UI tests. I noticed this while reading [fasterthanli.me](https://fasterthanli.me/articles/a-rust-match-made-in-hell) latest blog post, complaining that Clippy doesn't catch this for `parking_lot`. (Too many people read his blog, he's too powerful)

Some more things:
- Adds a test for #6446
- Improves the lint message

changelog: [`await_holding_lock`]: Now also lints for `parking_lot::{Mutex, RwLock}`
2022-02-18 10:55:05 +00:00
bors
76f91b6f5a Auto merge of #8442 - rsmantini:issue-8120-fix, r=Manishearth
trigger  `ptr_as_ptr` inside macros

This PR makes `ptr_as_ptr` trigger inside macros

Fixes issue #8120

changelog: ``[`ptr_as_ptr`]`` is now triggered inside macros

r? `@llogiq`
2022-02-17 22:57:23 +00:00
Jason Newcomb
8912d659cd Remove hack testing for cfg attribute in match_single_binding 2022-02-17 14:16:21 -05:00
Rodrigo Mantini
aaeeed6a59 trigger ptr_as_ptr inside macros 2022-02-17 20:16:14 +01:00
Jason Newcomb
8ce2d46cac Check for cfg attrubutes before linting match expressions 2022-02-17 14:04:10 -05:00
flip1995
ea0ce7bb76
Move await_holding_* lints to suspicious and improve doc
Even though the FP for that the lints were moved to pedantic isn't fixed
yet, running the lintcheck tool over the most popular 279 crates didn't
trigger this lint once. I would say that this lint is valuable enough,
despite the known FP, to be warn-by-default. Especially since a pretty
nice workaround exists.
2022-02-17 18:03:17 +01:00