Commit Graph

14412 Commits

Author SHA1 Message Date
Jason Newcomb
adbc8499d3 Don't lint while_let_loop when drop order would change 2022-06-29 13:43:05 -04:00
Jason Newcomb
58434ae385 Extract util functions from redundant_pattern_match 2022-06-29 13:42:59 -04:00
bors
70f1d0d8fd Auto merge of #9043 - dswij:9037-test, r=Manishearth
`extra_unused_lifetimes` add FP test case emitting from derived attributes.

Add test to cover for #9014 which is fixed in #9037.

changelog: [`extra_unused_lifetimes`] Add FP test case emitting from derived attributes.

---

Seeing the FP from the test:

```sh
$ git revert -m 1 1d1ae10876
$ TESTNAME=extra_unused_lifetime cargo uitest
```
2022-06-29 15:09:37 +00:00
bors
90227c10f7 Auto merge of #8981 - PrestonFrom:more_details_for_significant_drop_lint, r=flip1995
Add details about how significant drop in match scrutinees can cause deadlocks

Adds more details about how a significant drop in a match scrutinee can cause a deadlock and include link to documentation.

changelog: Add more details to significant drop lint to explicitly show how temporaries in match scrutinees can cause deadlocks.
2022-06-29 13:23:21 +00:00
bors
4995b4e584 Auto merge of #9046 - xFrednet:rust-97660-expection-something-something, r=Jarcho
Fix `#[expect]` for most clippy lints

This PR fixes most `#[expect]` - lint interactions listed in rust-lang/rust#97660. [My comment in the issue](https://github.com/rust-lang/rust/issues/97660#issuecomment-1147269504) shows the current progress (Once this is merged). I plan to work on `duplicate_mod` and `multiple_inherent_impl` and leave the rest for later. I feel like stabilizing the feature is more important than fixing the last few nits, which currently also don't work with `#[allow]`.

---

changelog: none

r? `@Jarcho`

cc: rust-lang/rust#97660
2022-06-28 18:28:38 +00:00
bors
a4130e1612 Auto merge of #8355 - Jarcho:explicit_auto_deref_2, r=flip1995
Add lint `explicit_auto_deref` take 2

fixes: #234
fixes: #8367
fixes: #8380

Still things to do:

* ~~This currently only lints `&*<expr>` when it doesn't trigger `needless_borrow`.~~
* ~~This requires a borrow after a deref to trigger. So `*<expr>` changing `&&T` to `&T` won't be caught.~~
* The `deref` and `deref_mut` trait methods aren't linted.
* Neither ~~field accesses~~, nor method receivers are linted.
* ~~This probably shouldn't lint reborrowing.~~
* Full slicing to deref should probably be handled here as well. e.g. `&vec[..]` when just `&vec` would do

changelog: new lint `explicit_auto_deref`
2022-06-28 18:09:26 +00:00
bors
23c6765276 Auto merge of #8921 - Jarcho:merge_passes, r=llogiq
Add `Operators` lint pass

changelog: None
2022-06-28 17:24:06 +00:00
Jason Newcomb
ffbba8550a Move SelfAssignment into Operators lint pass 2022-06-28 13:03:08 -04:00
Jason Newcomb
5e2a2d3ac9 Fix dogfood 2022-06-28 13:02:08 -04:00
Jason Newcomb
92891a01a1 Move PtrEq into Operators lin pass 2022-06-28 12:51:30 -04:00
Jason Newcomb
fc5eac5894 Move NeedlessBitwiseBool into Operators lint pass 2022-06-28 12:51:30 -04:00
Jason Newcomb
71c2daa60a Move ModuloArithmetic into Operators lint pass 2022-06-28 12:51:30 -04:00
Jason Newcomb
c0b0ee5bdc Move some lints from Misc to Operators 2022-06-28 12:51:30 -04:00
Jason Newcomb
a8df16ae1d Move IntegerDivision into Operators lint pass 2022-06-28 12:51:30 -04:00
Jason Newcomb
83de67cfec Move IdentityOp into Operators lint pass 2022-06-28 12:51:30 -04:00
Jason Newcomb
56f50d36e7 Move FloatEqualityWithoutAbs into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
3de70a4996 Move ErasingOp into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
0adb3c0518 Move EqOp into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
732d7162ab Move DurationSubsec into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
4ac3626f2e Move DoubleComparison into Operators lint pass 2022-06-28 12:51:29 -04:00
Jason Newcomb
68a7fd22ad Move BitMask into Operators lint pass 2022-06-28 12:51:26 -04:00
Jason Newcomb
751131b4ac Move AssignOps into Operators lint pass 2022-06-28 12:51:03 -04:00
Jason Newcomb
448b6f45bd Move Arithmetic into Operators lint pass 2022-06-28 12:51:00 -04:00
Jason Newcomb
dd78ce7bbe Add Operators lint pass 2022-06-28 12:50:33 -04:00
Jason Newcomb
85c1f74fef Add explicit_auto_deref test for variadic function 2022-06-28 12:48:50 -04:00
Jason Newcomb
15df2289ea Code cleanup 2022-06-28 12:48:49 -04:00
Jason Newcomb
9788107931 Handle future precedence issues in explicit_auto_deref + cleanup 2022-06-28 12:48:27 -04:00
Jason Newcomb
6d21b79be9 Fix needless_borrow suggestion when calling a trait method taking self 2022-06-28 12:48:27 -04:00
Jason Newcomb
0b4ba734cb Refactor dereference.rs
Merge `Position` and `AutoDerefStability`
2022-06-28 12:48:26 -04:00
Jason Newcomb
0204b95357 Lint explicit_auto_deref immediately after needless_borrow 2022-06-28 12:48:26 -04:00
Jason Newcomb
65bc6cb8bf Lint explicit_auto_deref without a leading borrow 2022-06-28 12:48:26 -04:00
Jason Newcomb
442a68c64b Only check parent node once in dereference.rs 2022-06-28 12:48:26 -04:00
Jason Newcomb
20ea26234a Lint field accesses in explicit_auto_deref 2022-06-28 12:48:26 -04:00
Jason Newcomb
a187d6412b Merge different parent walking loops in dereference.rs
`needless_borrow` will now walk further to find the target type.
2022-06-28 12:48:26 -04:00
Jason Newcomb
ee532c0222 Don't lint explicit_auto_deref on reborrows 2022-06-28 12:48:26 -04:00
Jason Newcomb
8a74d33570 Add explicit_auto_deref lint 2022-06-28 12:48:24 -04:00
Jason Newcomb
c107c97e69 Better support projection types when finding the signature for an expression 2022-06-28 12:47:26 -04:00
xFrednet
d11618e6fa
Update boxed_local expect attribute location 2022-06-28 12:38:52 +02:00
bors
b776fb8294 Auto merge of #8774 - hellow554:cargo-rust-version, r=flip1995
try reading rust-version from Cargo.toml

Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry

changelog: respect `rust-version` from `Cargo.toml`

closes #8746
closes #7765
2022-06-28 07:27:08 +00:00
bors
373bb573af Auto merge of #8639 - Jarcho:trivially_copy_pass_by_ref_5953, r=dswij
`trivially_copy_pass_by_ref` fixes

fixes #5953
fixes #2961

The fix for #5953 is overly aggressive, but the suggestion is so bad that it's worth the false negatives. Basically three things together:
* It's not obviously wrong
* It compiles
* It may actually work when tested

changelog: Don't lint `trivially_copy_pass_by_ref` when unsafe pointers are used.
changelog: Better track lifetimes when linting `trivially_copy_pass_by_ref`.
2022-06-28 07:03:57 +00:00
Marcel Hellwig
f0a1cd5645 add uitests for cargo rust-version field 2022-06-28 08:04:10 +02:00
Marcel Hellwig
6384765665 parse Cargo.toml file in ui-cargo tests
compiletest_rs is not meant to test full cargo projects, but instead
only files.
So we need to parse the `Cargo.toml` file ourself and set the
corresponding environment variable. In this case we just set
`CARGO_PKG_RUST_VERSION`, nothing more. But, of course, this can be
extended.
2022-06-28 08:03:48 +02:00
Marcel Hellwig
83511d1d9a update README.md to reflect rust-version in cargo.toml 2022-06-28 08:03:44 +02:00
Marcel Hellwig
81737bf850 try reading rust-version from Cargo.toml
Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry
2022-06-28 08:01:50 +02:00
Preston From
7bc40967a4 Run cargo dev fmt 2022-06-27 23:01:47 -06:00
Preston From
3cfd1e5233 Make messages more accurate, check lint enabled 2022-06-27 22:52:22 -06:00
bors
d85539571f Auto merge of #9045 - alex-semenyuk:self_assignment_example, r=llogiq
Fix example `SELF_ASSIGNMENT`

changelog: Fix example in `SELF_ASSIGNMENT` docs
2022-06-27 17:33:31 +00:00
bors
fdd0e727e2 Auto merge of #8649 - ebobrow:imperative_find, r=flip1995
add [`manual_find`] lint for function return case

part of the implementation discussed in #7143

changelog: add [`manual_find`] lint for function return case
2022-06-27 17:15:25 +00:00
Jason Newcomb
c10101cf1c Don't lint trivially_copy_pass_by_ref when unsafe pointers are used 2022-06-27 13:14:27 -04:00
Jason Newcomb
2315f76f9d Actually check lifetimes in trivially_copy_pass_by_ref 2022-06-27 13:14:25 -04:00