Commit graph

20459 commits

Author SHA1 Message Date
bors
cfb38819cc Auto merge of #13145 - xFrednet:07797-restriction-and-then-why, r=Jarcho
Make restriction lint's use `span_lint_and_then` (q -> w)

This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797.

I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways`

---

cc: https://github.com/rust-lang/rust-clippy/issues/7797

sister PR of: https://github.com/rust-lang/rust-clippy/pull/13136

changelog: none
2024-08-06 04:47:27 +00:00
bors
5f6d07b64e Auto merge of #13222 - dtolnay-contrib:deterministic, r=flip1995
Use a deterministic number of digits in rustc_tools_util commit hashes

Using `git rev-parse --short` in rustc_tools_util causes nondeterministic compilation of projects that use `setup_version_info!` and `get_version_info!` when built from the exact same source code and git commit. The number of digits printed by `--short` is sensitive to how many other branches and tags in the repository have been fetched so far, what other commits have been worked on in other branches, how recently you had run `git gc`, platform-specific variation in git's default configuration, and platform differences in the sequence of steps performed by the release pipeline. Someone can compile a tool from a particular commit, switch branches to work on a different commit (or simply do a git fetch), go back to the first commit and be unable to reproduce the binary that was built from it previously.

Currently, variation in short commit hashes causes Clippy version strings to be out of sync between different targets. On x86_64-unknown-linux-gnu:

```console
$ clippy-driver +1.80.0 --version
clippy 0.1.80 (0514789 2024-07-21)
```

Whereas on aarch64-apple-darwin:

```console
$ clippy-driver +1.80.0 --version
clippy 0.1.80 (05147895 2024-07-21)
```

---

changelog: none
2024-08-05 19:36:16 +00:00
David Tolnay
9f6536ce6f
Use a deterministic number of digits in rustc_tools_util commit hashes 2024-08-05 08:17:18 -07:00
bors
c082bc2cb8 Auto merge of #13136 - xFrednet:07797-restriction-and-then, r=blyxyas
Make restriction lint's use `span_lint_and_then` (a -> e)

This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797.

I'm also interested if it will have an impact on performance. With some of these lints, like [`clippy::implicit_return`](https://rust-lang.github.io/rust-clippy/master/index.html#/implicit_return) I expect an impact, as it was previously creating a suggestion **for every implicit return** which is just wild.

I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways`

---

`@blyxyas` Could you benchmark this PR? I want to get all the numbers :3

---

This also crashed our new lintcheck CI with the following message:

> Error: $GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of 1024k, got 46731k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary

Which is just wild. Like, I've [tested the first 20 lints](https://github.com/xFrednet/rust-clippy/actions/runs/10027528172) and got like four changes and then this. 50 MB of changed lint messages o.O. Looks like I'll create a separate PR to fix that step ^^

---

cc: https://github.com/rust-lang/rust-clippy/issues/7797

changelog: none

r? `@blyxyas`
2024-08-05 13:33:16 +00:00
bors
e17d254e2b Auto merge of #13180 - Jarcho:deprecated_shrink, r=flip1995
Simplify lint deprecation

A couple of small changes:
* A few deprecations were changed to renames. They all had a message similar to "this lint has been replaced by ..." which is just describing a rename.
* The website and warning message are now the same. The website description was usually just a wordier version that contained no extra information. This can be worked around if needed, but I don't think that will happen.
* The legacy deprecations have been removed. rustc should handle this since it already suggests adding the `clippy::` for all lints (deprecated or not) when they're used without it. It wouldn't be a problem to add them back in.
* The website no longer has a "view source" link for deprecated lints since they're no longer read from the HIR tree. I could store the line number, but the link seems totally useless for these lints.

This came up as part of separating the internal lints into their own crate. Both the metadata collector and the lint registration code needs access to the deprecated and renamed lists. This form lets all the deprecations be a separate crate.

r? `@flip1995`

changelog: none
2024-08-05 13:23:16 +00:00
Jason Newcomb
c2186e14de Make cargo dev deprecate require a reason 2024-08-05 09:17:46 -04:00
Jason Newcomb
2c34d58159 Store deprecated lints as an array of tuples.
Remove legacy deprecations.
Remove "View Source" link for deprecated lints.
2024-08-05 09:15:55 -04:00
Jason Newcomb
1672d5d4ed Mark some lint deprecations as renames 2024-08-05 09:10:49 -04:00
bors
e611c8e1c4 Auto merge of #13217 - dtolnay-contrib:toolsutil, r=flip1995
Check exit status of subcommands spawned by rustc_tools_util

The git commands `git rev-parse --short HEAD` and `git log -1 --date=short --pretty=format:%cd` that clippy runs from its build script might fail with **"fatal: not a git repository (or any of the parent directories): .git"** if clippy is being built from a source tarball rather than a git repository. That message is written by git to stderr, and nothing is written to stdout.

For `clippy-driver --version` this PR wouldn't make a difference because it treats empty stdout and failed spawns (`git` is not installed) identically:

7ac242c3d0/rustc_tools_util/src/lib.rs (L35-L42)

But other users of `rustc_tools_util` should be able to expect that the distinction between Some and None is meaningful. They shouldn't need extra code to handle None vs Some-and-empty vs Some-and-nonempty.

---

changelog: none
2024-08-05 13:00:02 +00:00
David Tolnay
234ea1fcd9
Check exit status of subcommands spawned by rustc_tools_util 2024-08-04 11:13:06 -07:00
bors
7ac242c3d0 Auto merge of #13213 - Alexendoo:multispan-sugg, r=y21
Remove `multispan_sugg[_with_applicability]`

They're thin wrappers over the corresponding diag method so we should just use that instead

changelog: none
2024-08-04 15:05:27 +00:00
Alex Macleod
1ea7bddbdf Remove multispan_sugg[_with_applicability] 2024-08-04 13:14:23 +00:00
bors
377d72ae8b Auto merge of #13194 - sheshnath-at-knoldus:fix-typos, r=Jarcho
fix-typos

fixes some typos in lintcheck

changelog: None
2024-08-03 18:51:51 +00:00
sheshnath-at-knoldus
b9716dd32a fix-typos 2024-08-03 23:18:29 +05:30
bors
8dd459d4c7 Auto merge of #13209 - Alexendoo:nonminimal-bool-limit-ops, r=y21
Limit number of `nonminimal_bool` ops

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

changelog: none
2024-08-03 15:50:00 +00:00
bors
eb7b6769f1 Auto merge of #13208 - alex-semenyuk:fix_doc_from_iter_instead_of_collect, r=llogiq
Add clarification for from_iter_instead_of_collect

Close #13147

As mentioned at #13147 we should prefer to use collect depends on situation so clarify this at documentation and provide examples this cases.

changelog: none
2024-08-03 15:09:06 +00:00
alexey semenyuk
35dcc9bbfa Add clarification for from_iter_instead_of_collect 2024-08-03 19:28:21 +05:00
Alex Macleod
b2d0631300 Limit number of nonminimal_bool ops 2024-08-03 12:07:42 +00:00
bors
0347280d5f Auto merge of #13107 - yaxum62:i5757, r=xFrednet
Add test for `try_err` lint within try blocks.

Fixes #5757

Turns out the current `try_err` implementation already skips expressions inside of a try block.

When inside of a try block, `Err(_)?` is desugared to a `break` instead of normal `return` . This makes `find_return_type()` function at [this line](eb4d88e690/clippy_lints/src/matches/try_err.rs (L29)) always returns `None` and skips the check.

I just added a test case for try block.

changelog: none
2024-08-03 08:25:37 +00:00
xFrednet
0532104247
Migrating restriction lints to span_lint_and_then (e -> i) 2024-08-03 10:18:15 +02:00
xFrednet
a9d72c7107
Migrating restriction lints to span_lint_and_then (a -> d) 2024-08-03 10:18:05 +02:00
bors
1ea827fa03 Auto merge of #13115 - tesuji:rm-dup-peels, r=dswij
Remove duplicated `peel_middle_ty_refs`

TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?

changelog: none
2024-08-03 07:32:30 +00:00
bors
1aa686b9c0 Auto merge of #13126 - apoisternex:issue12751, r=dswij
Fix [`redundant_slicing`] when the slice is behind a mutable reference

Fixes #12751

changelog: Fix [`redundant_slicing`] when the slice is behind a mutable reference and a immutable reference is expected.
2024-08-03 07:23:58 +00:00
bors
2fc74a3931 Auto merge of #13108 - tesuji:fix_redundant_closure, r=xFrednet
Fix `redundant_closure` false positive with closures has return type contains  `'static`

Fix #13073 .

Please enable "ignore white-space change" settings in github UI for easy reviewing.

HACK: The third commit contains a hack to check if a type `T: 'static` when `fn() -> U where U: 'static`.
I don't have a clean way to check for it.

changelog: [`redundant_closure`] Fix false positive with closures has return type contains  `'static`
2024-08-01 07:55:37 +00:00
bors
5542309895 Auto merge of #13195 - GuillaumeGomez:fix-false-positive-13183, r=Manishearth
Fix false positive for `missing_backticks` in footnote references

Fixes #13183.

changelog: Fix false positive for `missing_backticks` in footnote references
2024-07-31 16:06:27 +00:00
Guillaume Gomez
edca73003b Fix false positive for missing_backticks in footnote references 2024-07-31 17:27:53 +02:00
bors
ea06fa326d Auto merge of #13177 - GuillaumeGomez:fix-broken-list-lints-config, r=xFrednet
Fix broken list for lints config

Follow-up of #13166.

Finally figured out that it was a transformation and not the source that was the problem. It now looks like this:

![Screenshot from 2024-07-29 16-29-10](https://github.com/user-attachments/assets/4b89b3fe-8f85-47b8-8d9a-505badeaeac4)

r? `@xFrednet`

changelog: none
2024-07-31 11:11:39 +00:00
bors
c6f45df3c1 Auto merge of #13181 - Alexendoo:implicit-hasher-suggestion, r=llogiq
Use a single multipart suggestion for `implicit_hasher`

The second commit individually shows the diagnostic change

----

changelog: none
2024-07-30 20:02:53 +00:00
bors
8f3cfb4974 Auto merge of #13182 - Alexendoo:remove-allows, r=Manishearth
Remove some miscellaneous `#[allow]`s

Some were unneeded, others were removed by fixing/removing the thing they allow

changelog: none
2024-07-30 02:34:26 +00:00
bors
accf6868ee Auto merge of #13178 - GuillaumeGomez:clippy-lints-page-improvement, r=Alexendoo
Add possibility to focus on search input using keyboard

This PR adds the possibility to focus on the search input with `S` or `/` like in rustdoc and `mdbook` and `docs.rs` (unification++). Pressing escape will blur it.

r? `@Alexendoo`

changelog: Add possibility to focus on search input using keyboard
2024-07-29 19:58:12 +00:00
Alex Macleod
943a8e0646 Remove some miscellaneous #[allow]s 2024-07-29 19:57:39 +00:00
Guillaume Gomez
63174792c2 Add possibility to focus on search input using keyboard 2024-07-29 21:55:36 +02:00
Alex Macleod
33b16d31c2 implicit_hasher: use a single multipart suggestion 2024-07-29 17:56:27 +00:00
Alex Macleod
79783e95ad Fix implicit_hasher test not compiling 2024-07-29 17:44:57 +00:00
bors
834b691a9f Auto merge of #13174 - y21:if_let_mutex_multi_mutex, r=llogiq
Emit `if_let_mutex` in presence of other mutexes

Currently (master, not nightly nor stable) `if_let_mutex` does not emit a warning here:
```rs
let m1 = Mutex::new(10);
let m2 = Mutex::new(());

if let 100..=200 = *m1.lock().unwrap() {
  m2.lock();
} else {
  m1.lock();
}
```
It currently looks for the first call to `.lock()` on *any* mutex receiver inside of the if/else body, and only later (outside of the visitor) checks that the receiver matches the mutex in the scrutinee. That means that in cases like the above, it finds the `m2.lock()` expression, stops the visitor, fails the check that it's the same mutex (`m2` != `m1`) and then does not look for any other `.lock()` calls.

So, just make the receiver check also part of the visitor so that we only stop the visitor when we also find the right receiver.

The first commit has the actual changes described here. The sceond one just unnests all the `if let`s

----

changelog: none
2024-07-29 17:41:34 +00:00
bors
53420926ae Auto merge of #13179 - GuillaumeGomez:clean-up-lints-page-js, r=Alexendoo
Clean up clippy lints page JS source code

Just a small cleanup for the lints page JS source code.

r? `@Alexendoo`

changelog: Clean up clippy lints page JS source code
2024-07-29 15:04:30 +00:00
Guillaume Gomez
957a301083 Clean up clippy lints page JS source code 2024-07-29 16:49:56 +02:00
Guillaume Gomez
712e8f4f48 Fix broken list for lints config 2024-07-29 16:30:59 +02:00
bors
3b64ca95a9 Auto merge of #13173 - Jarcho:conf_order, r=xFrednet
Misc changes to `clippy_config`

Contains part of #13084

Changes include:
* Sort config list and each configs lint list.
* Add default text for the two configs that were missing it.
* Switch the lint list in the configs to an attribute.
* Make `dev fmt` sort the config list.

r? `@xFrednet`

changelog: none
2024-07-29 13:19:01 +00:00
bors
f7db8952e6 Auto merge of #13176 - shenyifu:master, r=Manishearth
Fix fix under loop may dropping loop label when applying fix.

changelog: [`explicit_counter_loop`]: fix label drop
changelog: [`for_kv_map`]: add label drop test
2024-07-29 10:38:25 +00:00
shenyifu
38a3462037 Fix fix under loop may dropping loop label when applying fix. 2024-07-29 17:43:03 +08:00
y21
61dcf6cfe0 inline a bunch of if lets into a single let chain 2024-07-28 18:28:24 +02:00
y21
1a1c978f8e [if_let_mutex]: make the mutex check part of the expr visitor 2024-07-28 18:27:53 +02:00
bors
668b659b47 Auto merge of #13166 - GuillaumeGomez:fix-clippy-doc, r=xFrednet
Fix display of configs in clippy doc page

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

It was simply some empty lines missing between configs. With this fix it looks like expected:

![image](https://github.com/user-attachments/assets/89c609b4-e24a-4f4a-91c1-3b49fc83584c)

r? `@xFrednet`

changelog: Fix display of configs in clippy doc page
2024-07-28 08:45:28 +00:00
Jason Newcomb
78a750e890 Sort the config list using dev fmt 2024-07-28 00:55:46 -04:00
Jason Newcomb
1d06ad5599 Mark the lints for each config via an attribute instead of a doc comment.. 2024-07-28 00:55:46 -04:00
Jason Newcomb
7422202ca5 Add missing default values 2024-07-27 23:34:16 -04:00
Jason Newcomb
7a25ead416 Remove unneeded parens in config macro 2024-07-27 19:23:23 -04:00
Jason Newcomb
84dc56923b Add docs for await_holding_invalid_types 2024-07-27 18:17:26 -04:00
Jason Newcomb
a54e3130ca alphabetize the config fields 2024-07-27 18:10:56 -04:00