Commit graph

19830 commits

Author SHA1 Message Date
bors
20b085d500 Auto merge of #12745 - y21:collapsible_match_or_pat, r=llogiq
Suggest collapsing nested or patterns if the MSRV allows it

Nested `or` patterns have been stable since 1.53, so we should be able to suggest `Some(1 | 2)` if the MSRV isn't set below that.

This change adds an msrv check and also moves it to `matches/mod.rs`, because it's also needed by `redundant_guards`.

changelog: [`collapsible_match`]: suggest collapsing nested or patterns if the MSRV allows it
2024-05-02 12:57:59 +00:00
bors
c36918329f Auto merge of #12743 - CBSpeir:remove-paths-vec_resize, r=y21
Remove `dead_code` paths

The following paths are `dead_code` and can be removed:

### `clippy_utils::paths::VEC_RESIZE`
* Introduced when `vec_resize_to_zero` lint added in PR https://github.com/rust-lang/rust-clippy/pull/5637
* No longer used after commit 8acc4d2f1e
### `clippy_utils::paths::SLICE_GET`
* Introduced when `get_first` lint added in PR https://github.com/rust-lang/rust-clippy/pull/8882
* No longer used after commit a8d80d531f
### `clippy_utils::paths::STR_BYTES`
* Introduced when `bytes_count_to_len` lint added in PR https://github.com/rust-lang/rust-clippy/pull/8711
* No longer used after commit ba6a459528

When the lints were moved into the `Methods` lint pass, they switched from using paths to diagnostic items.  However, the paths were never removed.  This occurred in PR https://github.com/rust-lang/rust-clippy/pull/8957.

This relates to issue https://github.com/rust-lang/rust-clippy/issues/5393

changelog: none
2024-05-02 12:47:40 +00:00
bors
a2bd02b57e Auto merge of #12515 - bend-n:🦀, r=llogiq
fix `for x in y unsafe { }`

fixes #12514

----

changelog: [`needless_for_each`]: unsafe block in for loop body suggestion
2024-05-02 12:36:42 +00:00
bors
1325425589 Auto merge of #12748 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-05-02 12:26:02 +00:00
Philipp Krones
d878e0e8ee
Bump nightly version -> 2024-05-02 2024-05-02 14:21:32 +02:00
Philipp Krones
76b95fd249
Bump Clippy version -> 0.1.80 2024-05-02 14:21:19 +02:00
Philipp Krones
e8492355a3
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-02 14:21:00 +02:00
bors
7eb380967e Auto merge of #12746 - oli-obk:bump_ui_test, r=blyxyas
Bump ui_test to 0.23

Notable changes: more control over run/rustfix/... and other rustc-specific features. All of these can in theory now be implemented entirely out of tree

changelog: none
2024-05-02 11:55:59 +00:00
Oliver Scherer
dcfc3b5de1 Bump ui_test to 0.23 2024-05-02 12:44:40 +02:00
bors
546408be41 Auto merge of #12735 - xFrednet:changelog-1-78, r=dswij
Changelog for Clippy 1.78 🪄

Roses and Violets have colors,
Red and Blue are the two,
I'm getting to the end of my masters,
what a cool goal to pursue

---

### The cat of this release is: *Shadow* submitted by `@benwh1:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/32911992/c56af314-4644-482a-a08e-f32f4c7d7b22" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
2024-05-02 10:19:15 +00:00
Fridtjof Stoldt
5c23f138dd
Apply suggestions from code review <3
Co-authored-by: Timo <30553356+y21@users.noreply.github.com>
2024-05-02 12:15:08 +02:00
Christopher B. Speir
5e05821af3 Remove clippy_utils::paths::{SLICE_GET, STR_BYTES}
Both clippy_utils::paths::SLICE_GET and clippy_utils::paths::STR_BYTES
are dead_code and can therefore be removed.
2024-05-01 22:23:31 -05:00
y21
790fb9396a check for matches! macro directly in redundant_guards 2024-05-02 05:05:26 +02:00
y21
272413f458 allow or patterns for a high enough MSRV in collapsible_match 2024-05-02 04:45:45 +02:00
Nilstrieb
b10be16702 Handle rustc_on_unimplemented in duplicated_attributes 2024-05-01 17:57:23 +02:00
bors
852a64f875 Auto merge of #11988 - J-ZhengLi:issue11324, r=Alexendoo
fix suggestion error for [`manual_is_ascii_check`] with missing type

fixes: #11324
fixes: #11776

changelog: improve [`manual_is_ascii_check`] to suggest labeling type in closure, fix FP with type generics, and improve linting on ref expressions.
2024-05-01 13:54:24 +00:00
Christopher B. Speir
fed9940e57 Remove clippy_utils::paths::VEC_RESIZE
This path is no longer used and can be removed.
2024-05-01 08:45:45 -05:00
Alex Macleod
c313ef51df Don't lint assigning_clones on nested late init locals 2024-05-01 12:22:50 +00:00
bors
a7f66baaf1 Auto merge of #12687 - Alexendoo:box-default-generic-fn, r=xFrednet
Don't suggest `Box::default()` in functions with differing generics

Fixes #12684

changelog: none
2024-05-01 12:02:17 +00:00
Alex Macleod
c187bff864 Fix FormatArgs storage when -Zthreads > 1 2024-05-01 11:35:04 +00:00
bendn
a3ef100fa6 warning 2024-05-01 07:51:23 +07:00
bors
d8e76ecaf1 Auto merge of #12596 - ARandomDev99:issue-12595, r=Alexendoo
Modify lint pass note for consistency with the book

This PR:
- removes the note which appears when an early lint pass is created using `cargo dev new_lint`.
- adds a note that encourages contributors to use an early pass unless type information is needed if a late lint pass is created using `cargo dev new_lint`.

Late pass remains the default value if no pass is specified as most lints use late pass.

Closes #12595

changelog: none
2024-04-30 12:51:27 +00:00
Matthias Krüger
fc15bc169e Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, r=oli-obk
Add StaticForeignItem and use it on ForeignItemKind

This is in preparation for unsafe extern blocks that adds a safe variant for functions inside extern blocks.

r? `@oli-obk`
cc `@compiler-errors`
2024-04-30 06:43:42 +02:00
bors
4bee9788a8 Auto merge of #124398 - klensy:trailing-ws, r=compiler-errors
tests: remove some trailing ws

Cleans one more case of trailing whitespace in tests.
2024-04-30 00:42:32 +00:00
bors
4261e0b28d Auto merge of #12734 - y21:issue12733, r=Manishearth
suppress `readonly_write_lock` for underscore-prefixed bindings

Fixes #12733

Unsure if there's a better way to prevent this kind of false positive but this is the one that made most sense to me.
In my experience, prefixing bindings with an underscore is the usual way to name variables that aren't used and that exist purely for executing drop code at the end of the scope.

-------

changelog: suppress [`readonly_write_lock`] for underscore-prefixed bindings
2024-04-29 22:40:30 +00:00
bors
70e74b11da Auto merge of #12736 - UlazkaMateusz:fix-type_complexity_duplicate_errors, r=xFrednet
[`type_complexity`]: Fix duplicate errors

Relates to #12379

Following message was duplicated:
```
LL |     fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: very complex type used. Consider factoring parts into `type` definitions
  --> tests/ui/type_complexity.rs:55:15
```

Methods `check_trait_item` and `check_fn` were both checking method named def_method.
Now `check_trait_item` only checks methods without body.

---
changelog: [`type_complexity`]: Fix duplicate diagnostics
2024-04-29 21:30:38 +00:00
Ulążka Mateusz
71db2d1451 [type_complexity]: Fix duplicate errors 2024-04-29 22:32:36 +02:00
bors
9e02abec3e Auto merge of #12726 - kornelski:else_applicable, r=blyxyas
clippy::single_match(_else) may be machine applicable

```
changelog: [`single_match`]: make the lint machine-applicable
changelog: [`single_match_else`]: make the lint machine-applicable
```

---

The lint doesn't use placeholders. I've tried it on my codebases, and all instances of it applied without problems.
2024-04-29 20:20:25 +00:00
xFrednet
7ac1529ff6
Changelog for Clippy 1.78 🪄 2024-04-29 22:01:33 +02:00
xFrednet
b1fa2842b1
Update version attribute for 1.78 lints 2024-04-29 21:26:14 +02:00
Santiago Pastorino
9276ce1cf3 Add StaticForeignItem and use it on ForeignItemKind 2024-04-29 13:15:51 -03:00
y21
f0beaedf83 suppress readonly_write_lock for underscore-prefixed bindings 2024-04-29 17:30:01 +02:00
bors
0fc9a65b8f Auto merge of #12694 - J-ZhengLi:issue11783, r=dswij
check if closure as method arg has read access in [`collection_is_never_read`]

fixes: #11783

---

changelog: fix [`collection_is_never_read`] misfires when use `retain` for iteration
2024-04-29 14:09:05 +00:00
J-ZhengLi
cbdc36aa09 skip warning when generic evolved;
suggest explicit type when its inferred in closure
2024-04-29 13:38:45 +08:00
bors
e68fcb0973 Auto merge of #12725 - llogiq:allow-useless-test-vecs, r=blyxyas
configurably allow `useless_vec` in tests

This adds a `àllow-useless-vec-in-test` configuration which, when set to `true` will allow the `useless_vec` lint in `#[test]` functions and code within `#[cfg(test)]`. It also moves a `is_in_test` helper to `clippy_utils`.

---

changelog: configurably allow [`useless_vec`] in test code
2024-04-28 20:10:33 +00:00
Andre Bogus
87efce4fa2 configurably allow useless_vec in tests
This adds a `àllow-useless-vec-in-test` configuration which, when set
to `true` will allow the `useless_vec` lint in `#[test]` functions and
code within `#[cfg(test)]`. It also moves a `is_in_test` helper to
`clippy_utils`.
2024-04-28 22:07:56 +02:00
Aneesh Kadiyala
e2861d5652 Encourage using LateLintPass 2024-04-29 00:30:23 +05:30
bors
ca1ddc0e7c Auto merge of #12722 - MATSMACKE:master, r=Alexendoo
Fix false positive in `cast_possible_truncation`

Fixes [#12721](https://github.com/rust-lang/rust-clippy/issues/12721)

changelog: [`cast_possible_truncation`]:  Separated checking whether integer constant has sufficient leading zeroes to be safely casted when getting remainder from bitwise and, since the latter allows a constant on either side of the operator to increase the number of leading zeroes that can be guaranteed.
2024-04-28 17:53:03 +00:00
bors
a18f50fe6a Auto merge of #12728 - y21:rr, r=dswij
Add myself back to review rotation

changelog: none
2024-04-28 15:45:33 +00:00
Alex Macleod
fa8f4b88cb Lint direct priority conflicts in [lints.workspace] 2024-04-28 14:16:19 +00:00
Mats Macke
0b1f09e6f7 Fixed reduction of & in cast_possible_truncation
Fixed formatting

Added tests for issue #12721

Checking for reduction on RHS
2024-04-28 16:01:33 +02:00
y21
ef1b0210bd remove myself from vacation 2024-04-28 15:13:41 +02:00
Kornel
b700d9c928
clippy::single_match(_else) may be machine applicable 2024-04-28 00:15:56 +01:00
bors
c6bf9548d5 Auto merge of #12624 - J-ZhengLi:issue12586, r=xFrednet
fix [`large_stack_arrays`] linting in `vec` macro

fixes: #12586

this PR also adds a wrapper function `matching_root_macro_call` to `clippy_utils::macros`, considering how often that same pattern appears in the codebase.

(I'm always very indecisive towards naming, so, if anyone have better idea of how that function should be named, feel free to suggest it)

---

changelog: fix [`large_stack_arrays`] linting in `vec` macro; add `matching_root_macro_call` to clippy_utils
2024-04-27 09:30:20 +00:00
klensy
a8e0bcb336 clippy: bless tests 2024-04-27 10:54:35 +03:00
Roddy Rappaport
1c9bf96b96 Fix website dash replacement #12718
Searching for a lint on the website will replace all of the dashes with
underscores instead of only the first one.
2024-04-26 21:58:08 +03:00
Oli Scherer
b1a4f87257 put hir::AnonConst on the hir arena 2024-04-26 12:57:02 +00:00
Vadim Petrochenkov
ec9ddc7b7a ast: Generalize item kind visiting
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-25 22:49:58 +03:00
bors
de4fce8686 Auto merge of #12711 - Alexendoo:assigning-clones-msrv, r=Manishearth
Rename `msrvs::ASSIGNING_CLONES` to `msrvs::CLONE_INTO`

A nit I missed in the PR that added it

changelog: none
2024-04-25 07:42:03 +00:00
Alex Macleod
69a4a46631 Rename msrvs::ASSIGNING_CLONES to msrvs::CLONE_INTO 2024-04-24 19:02:43 +00:00