Commit Graph

18170 Commits

Author SHA1 Message Date
jonboh
8b02dac542 add lint for struct field names
side effect for `enum_variants`:
use .first() instead of .get(0) in enum_variants lint
move to_camel_case to str_util module
move module, enum and struct name repetitions check to a single file `item_name_repetitions`
rename enum_variants threshold config option
2023-10-18 19:20:08 +02:00
bors
2640d5cc85 Auto merge of #11622 - GuillaumeGomez:needless_pass_by_ref_mut-regression-test-11610, r=blyxyas
Add regression test for #11610 about mutable usage of argument in async function for the `needless_pass_by_ref_mut` lint

Fixes https://github.com/rust-lang/rust-clippy/issues/11610.

This was already fixed. I simply added a regression test.

changelog: Add regression test for #11610 about mutable usage of argument in async function for the `needless_pass_by_ref_mut` lint
2023-10-17 12:20:03 +00:00
bors
2cf708d04f Auto merge of #11646 - Nilstrieb:compiler-does-not-comply-with-the-lints!!, r=giraffate
Make `multiple_unsafe_ops_per_block` ignore await desugaring

The await desugaring contains two calls (`Poll::new_unchecked` and `get_context`) inside a single unsafe block. That violates the lint.

fixes #11312

changelog: [`multiple_unsafe_ops_per_block`]: fix false positives in `.await`
2023-10-17 00:35:50 +00:00
bors
9f27b1562c Auto merge of #11673 - y21:issue11672, r=Manishearth
[`unnecessary_lazy_eval`]: reduce applicability if closure has return type annotation

Fixes #11672

We already check if closure parameters don't have type annotations and reduce the applicability to `MaybeIncorrect` if they do, since those help type inference and removing them breaks code. We didn't do this for return type annotations however. This PR adds it. This doesn't change it to produce a fix that will compile, but it will prevent rustfix from auto-applying it.

(In general I'm not sure if we can suggest a fix that will compile. In this specific example, it might be possible to suggest `&[] as &[u8]`, but as-casts won't always work, e.g. `Default::default() as &[u8]` is a compile error, so just reducing applicability should be a safe fix in any case for now)

changelog: [`unnecessary_lazy_eval`]: reduce applicability to `MaybeIncorrect` if closure has return type annotation
2023-10-16 16:27:01 +00:00
bors
387d756540 Auto merge of #11666 - c410-f3r:dsadasewqasdsa, r=flip1995
Document conflicting lints

Documents the outcome described in https://github.com/rust-lang/rust-clippy/issues/11662 so that the situation can be avoided in the future by other individuals.

changelog: none
2023-10-16 11:07:43 +00:00
bors
ae52ee5015 Auto merge of #11514 - pitaj:triagebot_no-merges_exclude-titles, r=flip1995
triagebot no-merges: exclude "Rustup"s, add labels

https://github.com/rust-lang/triagebot/pull/1720

changelog: none
2023-10-16 00:33:10 +00:00
bors
ef95be517c Auto merge of #11609 - y21:get_first_non_primitives, r=giraffate
[`get_first`]: lint on non-primitive slices

Fixes #11594

I left the issue open for a couple days before making the PR to see if anyone has something to say, but it looks like there aren't any objections to removing this check that prevented linting on non-primitive slices, so here's the PR now.
There's a couple of instances in clippy itself where we now emit the lint. The actual relevant change is in the first commit and fixing the `.get(0)` instances in clippy itself is in the 2nd commit.

changelog: [`get_first`]: lint on non-primitive slices
2023-10-15 23:53:22 +00:00
y21
bb6516ace0 [unnecessary_lazy_eval]: don't emit autofix suggestion if closure has return type 2023-10-16 00:47:13 +02:00
Nilstrieb
6ed04af81c Make multiple_unsafe_ops_per_block ignore await desugaring
The await desugaring contains two calls (`Poll::new_unchecked` and
`get_context`) inside a single unsafe block. That violates the lint.
2023-10-14 23:15:00 +02:00
Caio
8c0870de7f Address comment 2023-10-13 10:31:02 -03:00
Caio
d1796054fe Document conflicting lints 2023-10-13 10:09:58 -03:00
bors
c40359d97a Auto merge of #11664 - koka831:fix/11134, r=blyxyas
Fix/11134

Fix #11134

Hir of `qpath` will be `TypeRelative(Ty { kind: Path(LangItem...` when a closure contains macro (e.g. https://github.com/rust-lang/rust-clippy/issues/11651) and #11134, it causes panic.
This PR avoids panicking and emitting incomplete path string when `qpath` contains `LangItem`.

changelog: none
2023-10-13 10:18:49 +00:00
koka
9fc717dea3
add test for macro-in-loop 2023-10-13 17:12:41 +09:00
koka
eb6fb18a99
Avoid panic!, omit instead 2023-10-13 17:07:29 +09:00
bors
ff00e9c8c0 Auto merge of #11659 - aDotInTheVoid:hexdigit, r=Jarcho
[`manual_is_ascii_check`]: Also check for `is_ascii_hexdigt`

changelog: [`manual_is_ascii_check`]: Also check for `is_ascii_hexdigt`
2023-10-12 19:30:32 +00:00
Alona Enraght-Moony
b5488f9850 [manual_is_ascii_check]: Also check for is_ascii_hexdigt 2023-10-12 19:12:42 +00:00
bors
929a288aa7 Auto merge of #11645 - Alexendoo:ui_test, r=flip1995
Update ui_test to 0.21.2

Hopefully fixes #11489

r? `@flip1995`

changelog: none
2023-10-09 08:54:38 +00:00
bors
bde04824cc Auto merge of #11550 - blyxyas:fix-impl_trait_in_params-for_assocfn, r=dswij
`impl_trait_in_params` now supports impls and traits

Before this PR, the lint `impl_trait_in_params`. This PR gives the lint support for functions in impls and traits. (Also, some pretty heavy refactor)

fixes #11548
changelog:[`impl_trait_in_params`] now supports `impl` blocks and functions in traits
2023-10-08 21:57:56 +00:00
blyxyas
775573768e
Fix tests, only lint for public tests 2023-10-08 23:49:32 +02:00
blyxyas
5ed338dff9
impl_trait_in_params now supports impls and traits 2023-10-08 23:49:32 +02:00
Alex Macleod
850f2f5b61 Update ui_test to 0.21.2 2023-10-08 19:35:41 +01:00
bors
33f49f33d6 Auto merge of #11638 - samueltardieu:into-iter, r=Manishearth
Fix two typos in lint description

Fix #11636

changelog: none
2023-10-07 21:33:53 +00:00
bors
7624045997 Auto merge of #11639 - y21:issue11635, r=llogiq
[`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods

Fixes #11635

changelog: [`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods
2023-10-07 15:55:34 +00:00
y21
1c6fa2989d [into_iter_without_iter]: look for iter method in deref chains 2023-10-07 16:33:06 +02:00
Samuel Tardieu
bffba76b52 Fix two typos in lint description 2023-10-07 10:58:52 +02:00
bors
3662bd8f58 Auto merge of #11623 - koka831:fix/11619, r=llogiq
Fix ice in `redundant_locals`

Fixes #11619

Rebinding over macro like the code below, idents will be different (`x#4` and `x#0` in that case).

```rust
fn reassign_in_macro() {
  let x = 10;
  macro_rules! mac {
    ($i:ident) => {
      let mut x = x;
    }
  }
  mac!(y);
}
```

It causes unwrapping `None`.

9554e477c2/clippy_lints/src/redundant_locals.rs (L88-L98)

changelog: ICE: [`redundant_locals`]: No longer lints rebinding over macro
2023-10-06 17:24:50 +00:00
koka
68d2082d69
Fix ice 2023-10-07 01:28:06 +09:00
bors
b105fb4c39 Auto merge of #11629 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-10-06 15:34:34 +00:00
Philipp Krones
b8677e54d4
Bump Clippy version -> 0.1.75 2023-10-06 17:32:44 +02:00
Philipp Krones
50754da9fa
Bump nightly version -> 2023-10-06 2023-10-06 17:32:32 +02:00
Philipp Krones
82c3064c47
Merge remote-tracking branch 'upstream/master' into rustup 2023-10-06 17:31:44 +02:00
bors
7217c0f3ac Auto merge of #11628 - koka831:fix/11625, r=blyxyas
Improve `redundant_locals` help message

Fixes #11625

AFAIK, `span_lint_and_help` points the beginning of spans when we pass multiple spans to the second argument, so This PR I also modified its help span and its message.

lint result of the given example in the issue will be:

```console
error: redundant redefinition of a binding `apple`
 --> src/main.rs:5:5
  |
5 |     let apple = apple;
  |     ^^^^^^^^^^^^^^^^^^
  |
help: `apple` is initially defined here
 --> src/main.rs:4:9
  |
4 |     let apple = 42;
  |         ^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
```

I hope that this change might help reduce user confusion, but I'd appreciate alternative suggestions:)

changelog: [`redundant_locals`]: Now points at the rebinding of the variable
2023-10-06 15:06:00 +00:00
bors
279127ce2e Auto merge of #11611 - Alexendoo:items-after-test-module-check-crate, r=blyxyas
Fix `items_after_test_module` for non root modules, add applicable suggestion

Fixes #11050
Fixes #11153

changelog: [`items_after_test_module`]: Now suggests a machine-applicable suggestion.
changelog: [`items:after_test_module`]: Also lints for non root modules
2023-10-06 14:19:45 +00:00
koka
48d2770e52
Improve redundant_locals help message 2023-10-06 22:18:11 +09:00
Alex Macleod
dcc400191e Fix items_after_test_module for non root modules, add applicable suggestion 2023-10-06 12:46:04 +00:00
Guillaume Gomez
ddd1564e5d Add regression test for #11610 about mutable usage of argument in async function for the needless_pass_by_ref_mut lint 2023-10-06 11:18:34 +02:00
Michael Goulet
c5c6d703de Point to closure return instead of output if defaulted 2023-10-04 21:09:54 +00:00
Michael Goulet
56794fa5f1 Fix clippy 2023-10-04 21:09:54 +00:00
y21
e6f29f1900 dogfood 2023-10-04 18:08:30 +02:00
y21
31fd282732 [get_first]: lint on non-primitive types 2023-10-04 18:07:54 +02:00
bors
9554e477c2 Auto merge of #11605 - xFrednet:changelog-1-73, r=blyxyas
Changelog for Rust 1.73 🖊️

Roses are red,
violets are blue,
I'm tired... 💤
Oh nice, tea 🍵

---

### The cat of this release:

![cat-like-doritos](https://github.com/rust-lang/rust-clippy/assets/114838443/1ca9eb1e-3e5c-42a4-bda9-6f24a2e03015)

cc: `@Centri3` & `@blyxyas`

As the author, I call dibs on the 1.74 cat picture 🐈

---

changelog: none
2023-10-04 14:12:50 +00:00
bors
716f211030 Auto merge of #116360 - compiler-errors:async-span, r=oli-obk
Point to full `async fn` for future

Semi-follow-up to https://github.com/rust-lang/rust/pull/116296#discussion_r1342007575

cc `@asquared31415`
2023-10-04 09:55:02 +00:00
xFrednet
404217e631
Address PR Review <3 2023-10-04 10:28:52 +02:00
xFrednet
948355586f
sudo CI=green 2023-10-04 01:19:38 +02:00
xFrednet
8d920a8b03
Changelog for Rust 1.73 🖊️ 2023-10-04 01:09:46 +02:00
xFrednet
eab0a75ff9
Update version attribute for 1.73 lints 2023-10-04 01:08:45 +02:00
bors
b437069f59 Auto merge of #11603 - koka831:fix/11599, r=y21
Fix: avoid changing drop order

Fixes https://github.com/rust-lang/rust-clippy/issues/11599

changelog: [`redundant_locals`] No longer lints which implements Drop trait to avoid reordering
2023-10-03 15:49:28 +00:00
koka
c7152679ef
Apply review suggestions from @y21 2023-10-04 00:13:53 +09:00
bors
29958f0764 Auto merge of #11602 - koka831:fix/11601, r=xFrednet
Avoid invoking `ignored_unit_patterns` in macro definition

Fixes https://github.com/rust-lang/rust-clippy/issues/11601

The reported problem occured in [a derive macro](https://github.com/mpalmer/ct-structs/actions/runs/6386980382/job/17334587328#step:6:239). This PR avoid linting in macros.

changelog: [`ignored_unit_patterns`] No longer lints inside macro definitions
2023-10-03 13:07:13 +00:00
koka
1a56f90ee5
Fix: avoid changing drop order 2023-10-03 21:28:01 +09:00