Commit Graph

20014 Commits

Author SHA1 Message Date
Nicholas Nethercote
dc8a455a00 Simplify use crate::rustc_foo::bar occurrences.
They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)
2024-05-08 16:57:31 +10:00
roife
362ef42b68 fix: merge multiple suggestions into a single multi-span suggestion in needless_late_init 2024-05-08 13:44:22 +08:00
cocodery
a8c35cbbda Check inner caller for clone and judge whether they are mutable
if immutbale -> lint delete redudant clone
if mutable   -> lint check whether clone is needed
2024-05-07 16:07:13 +08:00
J-ZhengLi
40ec760572 fix doc test failure;
apply review suggestions by @Centri3:
use multi suggestion;
change output message format;
add macro expansion check & tests;
2024-05-07 10:49:02 +08:00
J-ZhengLi
28d5115067 add new lint that disallow renaming parameters in trait functions 2024-05-07 10:49:02 +08:00
Michael Howell
afedaf6a26 Update doc comments to avoid lazy continuations 2024-05-06 16:31:23 -07:00
Michael Howell
f3dd31e214 Add lint for markdown lazy paragraph continuations
This is a follow-up for https://github.com/rust-lang/rust/pull/121659,
since most cases of unintended block quotes are lazy continuations.
The lint is designed to be more generally useful than that, though,
because it will also catch unintended list items and unintended
block quotes that didn't coincidentally hit a pulldown-cmark bug.
2024-05-06 16:31:21 -07:00
bors
befb659145 Auto merge of #12755 - 9999years:useless-attribute, r=xFrednet,GuillaumeGomez
Allow more attributes in `clippy::useless_attribute`

Fixes #12753
Fixes #4467
Fixes #11595
Fixes #10878

changelog: [`useless_attribute`]: Attributes allowed on `use` items now include `ambiguous_glob_exports`, `hidden_glob_reexports`, `dead_code`, `unused_braces`, and `clippy::disallowed_types`.
2024-05-06 20:38:51 +00:00
Rebecca Turner
566bfff8bb
useless_attribute: Update docs for allowed attributes 2024-05-06 12:27:20 -07:00
bors
3ef3a1336f Auto merge of #12747 - flip1995:clippy-dev-cli-derive, r=Alexendoo
Type safe CLI implementation for clippy-dev

Use the derive feature of `clap` to generate CLI of clippy-dev. Adding new commands will be easier in the future and we get better compile time checking through exhaustive matching.

---

I think I tested everything locally. But I would appreciate if the reviewer could go over it again, so that everything keeps working.

changelog: none
2024-05-06 15:45:59 +00:00
Yusuf Raji
c9ea0ae502 Lint while loops with float comparison 2024-05-06 00:04:00 +02:00
Ruihan Li
509ca90bf1 Ignore significant drops of place expressions 2024-05-06 00:30:41 +08:00
Ruihan Li
a78a15c5d3 Avoid unnecessary arguments 2024-05-06 00:30:01 +08:00
Michael Baikov
79a14dea86 less aggressive needless_borrows_for_generic_args
Current implementation looks for significant drops, that can change the
behavior, but that's not enough - value might not have a Drop itself but
one of its children might have it.

A good example is passing a reference to `PathBuf` to `std::fs::File::open`.
There's no benefits to pass `PathBuf` by value, but since clippy can't
see `Drop` on `Vec` several layers down it complains forcing pass by
value and making it impossible to use the same name later.

New implementation only looks at copy values or values created inplace
so existing variable will never be moved but things that take a string
reference created and value is created inplace `&"".to_owned()` will
make it to suggest to use `"".to_owned()` still.

Fixes https://github.com/rust-lang/rust-clippy/issues/12454
2024-05-05 12:08:38 -04:00
Guillaume Gomez
10913d27a1 Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwco
Stabilize exclusive_range_pattern (v2)

This PR is identical to #124459, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F).

r? ghost

Original PR description:

---

Stabilization report: https://github.com/rust-lang/rust/issues/37854#issuecomment-1842398130
FCP: https://github.com/rust-lang/rust/issues/37854#issuecomment-1872520294

Stabilization was blocked by a lint that was merged here: #118879

Documentation PR is here: rust-lang/reference#1484

`@rustbot` label +F-exclusive_range_pattern +T-lang
2024-05-05 16:42:48 +02:00
bors
28002514d5 Auto merge of #12742 - Alexendoo:assigning-clones-nested-late-init, r=dswij
Don't lint assigning_clones on nested late init locals

Fixes #12741

changelog: none
2024-05-04 19:36:06 +00:00
bors
3cdc951b0b Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillot
Some hir cleanups

It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field.

r? compiler
2024-05-04 00:32:27 +00:00
Philipp Krones
537ab6cc87
Bump clap version -> 4.4
Same version as most other crates in rustc are using
2024-05-03 11:36:42 +02:00
Philipp Krones
a0d562a183
Type safe CLI implementation for clippy-dev
Use the derive feature of `clap` to generate CLI of clippy-dev. Adding new
commands will be easier in the future and we get better compile time checking
through exhaustive matching.
2024-05-03 11:36:42 +02:00
bors
993d8ae2a7 Auto merge of #12567 - Alexendoo:format-args-storage, r=flip1995
Fix `FormatArgs` storage when `-Zthreads` > 1

Fixes #11886

The initial way I thought of was a little gross so I never opened a PR for it, I thought of a nicer way today that no longer involves any `thread_local`s or `static`s

`rustc_data_strucutres::sync::{Lrc, OnceLock}` implement `DynSend` + `DynSync` so we can pass them to the lint passes that need the storage

changelog: none

r? `@flip1995`
2024-05-03 09:21:22 +00:00
Ross Smyth
68a6cbfc6c Update clippy tests for stable exclusive_range 2024-05-02 19:42:37 -04:00
Rebecca Turner
db0cbbacb7
useless_attribute: allow ambiguous_glob_exports
Closes https://github.com/rust-lang/rust-clippy/issues/10878
2024-05-02 14:48:18 -07:00
Rebecca Turner
96e69d9b43
useless_attribute: allow hidden_glob_reexports
Closes https://github.com/rust-lang/rust-clippy/issues/11595
2024-05-02 14:48:11 -07:00
bors
60267b26a1 Auto merge of #12750 - cakebaker:patch-1, r=Alexendoo
`assigning_clones`: add empty line to doc

changelog: none

This PR adds, for consistency reasons, an empty line to the example in the doc of the `assigning_clones` lint.
2024-05-02 20:40:55 +00:00
Rebecca Turner
e9761bdc01
useless_attribute: allow dead_code
Closes https://github.com/rust-lang/rust-clippy/issues/4467
2024-05-02 11:57:56 -07:00
Rebecca Turner
17d2ab8f62
useless_attribute: allow unused_braces 2024-05-02 11:56:05 -07:00
Rebecca Turner
8d8c0bfb0e
useless_attribute: allow clippy::disallowed_types
Closes https://github.com/rust-lang/rust-clippy/issues/12753
2024-05-02 11:55:11 -07:00
Ruihan Li
a032189503 Fix significant drop detection 2024-05-03 00:02:18 +08:00
Philipp Krones
80c6f8ff7b Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into clippy-subtree-update 2024-05-02 17:26:44 +02:00
Daniel Hofstetter
63cb56e789
assigning_clones: add empty line to doc 2024-05-02 17:11:35 +02:00
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