Commit Graph

20292 Commits

Author SHA1 Message Date
Alex Macleod
7010d3c67e Don't suggest .cast_mut/.cast_const for types with erased lifetimes 2024-07-23 11:12:26 +00:00
Alex Macleod
afe811ad30 Suggest .cast/.cast_const/.cast_mut in transmute_ptr_as_ptr 2024-07-22 17:31:45 +00:00
bors
1807580a49 Auto merge of #12772 - phi-gamma:redundant-struct-recreation, r=y21
add lint for recreation of an entire struct

This lint makes Clippy warn about situations where an owned struct is
essentially recreated by moving all its fields into a new instance of
the struct. The lint is not machine-applicable because the source
struct may have been partially moved.

This lint originated in something I spotted during peer review. While
working on their branch a colleague ended up with a commit where a
function returned a struct that 1:1 replicated one of its owned inputs
from its members. Initially I suspected they hadn’t run their code
through Clippy but AFAICS there is no lint for this situation yet.

changelog: new lint: [`redundant_owned_struct_recreation`]

### New lint checklist

- \[+] Followed [lint naming conventions][lint_naming]
- \[+] Added passing UI tests (including committed `.stderr` file)
- \[+] `cargo test` passes locally
- \[+] Executed `cargo dev update_lints`
- \[+] Added lint documentation
- \[+] Run `cargo dev fmt`
2024-07-21 23:02:38 +00:00
bors
7f0ed11213 Auto merge of #13133 - xFrednet:lintcheck-linkify-summary, r=Alexendoo
Lintcheck: Cleanup of Lintcheck's CI summery

This PR makes three changes to lintcheck's job summary:
* Adds links to the *Added*, *Removed*, *Changed* sections
* Added the crate name to the warning info
* Removes empty lines from the rendered output

This is what the new output roughly looks like:

![image](https://github.com/user-attachments/assets/3faae0a6-e5ee-4e70-9d4d-d19b18dc6a3a)
![image](https://github.com/user-attachments/assets/028c3a92-98dc-4e00-b7bb-fecf9450f5b1)

[🖼️ Old Output 🖼️](https://github.com/xFrednet/rust-clippy/actions/runs/10019681444)

[🖼️ New Output 🖼️](https://github.com/xFrednet/rust-clippy/actions/runs/10019598141)

The links for the sections are a bit weird as you have to click on them twice. I believe this is a bug from GH's side. But it works reasonably well :D

---

changelog: none

r? `@Alexendoo`
2024-07-21 12:37:00 +00:00
bors
8fe5c757d5 Auto merge of #11700 - lengyijun:pathbuf_join, r=xFrednet
[`pathbuf_init_then_push`]:  Checks for calls to `push` immediately a…

changelog: [`pathbuf_init_then_push`]: new lint: Checks for calls to `push` immediately after creating a new `PathBuf`

Just a mirror of VEC_INIT_THEN_PUSH
2024-07-21 06:39:01 +00:00
lengyijun
cb77f12600 [pathbuf_init_then_push]: Checks for calls to push immediately after creating a new PathBuf
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2024-07-21 14:22:48 +08:00
xFrednet
69c3289f2b
Lintcheck: Include the crate name in the CI job summary 2024-07-20 13:25:44 +02:00
xFrednet
83c8385ad1
Lintcheck: Remove empty lines from rendered CI output 2024-07-20 13:25:44 +02:00
xFrednet
09906b8221
Lintcheck: Linkify counts in CI summery 2024-07-20 13:13:13 +02:00
bors
b02cb2401d Auto merge of #13131 - waywardmonkeys:reduce-typo-count, r=Alexendoo
Reduce typo count.

changelog: none
2024-07-20 11:05:12 +00:00
Bruce Mitchener
cf4270d13b Reduce typo count. 2024-07-20 12:50:36 +07:00
bors
057c4ae287 Auto merge of #13124 - xFrednet:00000-lintcheck-crates, r=Alexendoo
Lintcheck: Update crates and expand CI testset to 200 crates

This PR adds a new `ci_crates.toml` to lintcheck for our CI. The 200 crates take about 14 minutes, which is slightly more than the 10 I aimed for but still reasonable. The testset is constructed from:

* 5 crates that compile to binaries
* 4 crates that have been mentioned in ICE issues
* 1 crates "random" crates from `lintcheck_crates.toml`
* 190 crates from the top 200 crates from crates.io

During testing, I noticed a few panics in lintcheck. I've fixed them where possible, or at least improved the error message.

The new test set generates 500+ MB of json lints, which are compressed to a ~24mb artifact.

---

This PR also updates our `lintcheck_crates.toml`. I mainly updated the versions, removed some very outdated crates, and added some new ones. I targeted 25 crates as those are pretty fast to lint and a good precursor for our CI.

---

Optional TODO:

* It's likely that some crates are compiled several times. We could potentially safe some time, by using `--recursive` in our CI.
    This is something I want to investigate, but it shouldn't be a blocker for this PR.

---

r? `@Alexendoo`

changelog: none
2024-07-19 18:07:52 +00:00
xFrednet
8940bc3c46
Lintcheck: New testset for Clippy's CI (200 crates for ~10 min) 2024-07-19 19:52:07 +02:00
xFrednet
4ece12da32
Lintcheck: Update the default testset for local lintcheck 2024-07-19 19:52:03 +02:00
xFrednet
46ebe0cb68
Lintcheck: Normalize thread IDs in shared_target_dir 2024-07-19 19:51:41 +02:00
bors
ac2ba15add Auto merge of #13129 - xFrednet:interesting-life-choices, r=xFrednet
Add xFrednet back to Clippy's reviewer roulette

What the title says.

---

cc: https://github.com/rust-lang/rust-clippy/pull/12947

changelog: none

r? `@ghost`
2024-07-19 15:55:25 +00:00
xFrednet
14e271121c
Triagebot: Add xFrednet back to Clippy's reviewer roulette 2024-07-19 17:52:22 +02:00
xFrednet
9d82fb460a
Lintcheck: More info on Diags without spans 2024-07-18 16:41:06 +02:00
xFrednet
31fdc2ec09
Lintcheck: Remove rust-toolchain from downloaded crates 2024-07-18 16:41:05 +02:00
bors
b31bce4f5f Auto merge of #13104 - xFrednet:00000-lintcheck-better-md-links, r=Alexendoo
Lintcheck: Add URL to lint emission place in diff

This PR adds links to the emission code in our lintcheck CI. When reviewing changes, I would like to be able to see the bigger context, which isn't always included in the lint message. This PR adds a nice link to the lintcheck diff that allows for simple investigation of the code in question.

At first, I wanted to simply use the doc.rs links and call it a day, but then I figured out that some crates might have their source files remapped. Cargo was the crate that made me notice this. As a response, I made the link configurable. (See https://github.com/rust-lang/docs.rs/issues/2551 for a detailed explanation and possible solution to remove this workaround in the future.)

It's probably easiest to review the individual commits. The last one is just a dummy to showcase the change.

[🖼️ rendered 🖼️](https://github.com/rust-lang/rust-clippy/actions/runs/9960834924?pr=13104)

---

r? `@Alexendoo`

changelog: none

---

That's it, I hope that everyone who's reading this has a beautiful day :D
2024-07-18 13:31:12 +00:00
xFrednet
0e3d19799c
Lintcheck: Construct links for sources 2024-07-18 15:28:14 +02:00
bors
bc2feea519 Auto merge of #13117 - GuillaumeGomez:fix-single_element_loop-suggestion, r=Alexendoo
Fix wrong suggestion for `single_element_loop` where parens were missing

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

changelog: Fix missing parens in `single_element_loop` suggestion
2024-07-18 12:53:59 +00:00
Guillaume Gomez
8dd310ddd7 Fix wrong suggestion for single_element_loop where parens were missing 2024-07-18 14:50:45 +02:00
bors
073f9d9080 Auto merge of #13116 - tesuji:fix_zero_repeat_side_effects, r=y21
Lint `zero_repeat_side_effects`  only if array length is a literal zero

changelog: [`zero_repeat_side_effects` ] Lint only if array length is a literal zero
Fixes #13110 .
r? y21
2024-07-18 11:56:13 +00:00
Lzu Tao
3c50e7af5a Lint only if array length is a literal zero. 2024-07-18 12:22:08 +07:00
bors
acc41f4239 Auto merge of #13100 - Alexendoo:dogfood-progress, r=xFrednet
Show progress while running dogfood test

Outputs the regular cargo progress in colour when running the dogfood test, helpful to see because it can take a long time to run

changelog: none
2024-07-17 18:41:48 +00:00
bors
f74037e47a Auto merge of #13088 - Jarcho:conf_refactor2, r=flip1995
Create lint passes using `Conf`

This slightly reduces the amount of code changes needed to add a config to a lint and makes things makes things more consistent between passes. A dependence on the config being a static reference is also added. This would only ever be a problem if multiple crates end up compiled in a single process.

Other changes include:
* Removing useless `#[derive(..)]`s
* Removing `#[must_use]` on lint pass constructors.
* Unified the parsing of the `DisallowedPath` struct in lint passes.
* Update `disallowed_types` and `await_holding_invalid` messages to be consistent with other disallowed lints.
* Remove the `(from clippy.toml)` message. I plan on having all the configured lints point to point to a span in `clippy.toml` which will be more useful.

changelog: none
2024-07-17 18:13:07 +00:00
Jason Newcomb
e34c6dbae5 Refactor for using config values:
* Construct lint passes by taking `Conf` by reference.
* Use `HashSet` configs in less places
* Move some `check_crate` code into the pass constructor when possible.
2024-07-17 14:05:49 -04:00
Alex Macleod
0b0c39ca4d Show progress while running dogfood test 2024-07-17 12:29:18 +00:00
Lzu Tao
5540060d5d Skip linting if array length is from a macro. 2024-07-17 18:33:36 +07:00
Lzu Tao
c65ddb8728 Add regression test for issue 13110 2024-07-17 18:32:18 +07:00
bors
0ee9f44568 Auto merge of #13096 - apoisternex:issue12954, r=y21
fix [`excessive_precision`] suggestions on floats written in scientific notation

fixes #12954

changelog: fix [`excessive_precision`] suggestions on float literal written in scientific notation
2024-07-16 12:56:10 +00:00
apoisternex
489a77831c fix [excessive_precision] suggestions on float literal written in scientific notation
fixes: #12954

changelog: fix [`excessive_precision`] suggestions on float literal written in scientific notation
2024-07-15 18:52:18 -03:00
bors
eb4d88e690 Auto merge of #13102 - tesuji:fix-needless_option_as_deref, r=Alexendoo
Fix `needless_option_as_deref` false-positive on struct literals

changelog: [`needless_option_as_deref`] Fix false-positive on struct literals.

Fixes #13077 .

r?  Alexendoo
2024-07-15 16:23:41 +00:00
Lzu Tao
dcee2e8a0f Dont stop find loop node at struct field node 2024-07-15 15:56:17 +00:00
Lzu Tao
4264548283 Add regression test for issue 13077 2024-07-15 15:55:22 +00:00
bors
22eeb1109b Auto merge of #13098 - oli-obk:bump_ui_test, r=Alexendoo
Bump ui_test version

r? `@alexendoo`

the rustfix diff is caused by https://github.com/oli-obk/ui_test/pull/244

This should solve the issues around missing summaries at the end

changelog: none
2024-07-15 12:29:11 +00:00
Oli Scherer
3b390d416d Bump clippy version 2024-07-15 08:51:04 +00:00
bors
10ba798736 Auto merge of #13093 - waywardmonkeys:more-doc-valid-idents, r=Alexendoo
Add more doc-valid-idents

* "AccessKit" is a commonly used accessibility toolkit used in Rust GUIs.
* "CoreFoundation", "CoreGraphics", "CoreText" are frameworks on Apple OSes.
* "Direct2D", "Direct3D", "DirectWrite" are frameworks on Windows
* "PostScript" is a programming language and is mentioned when talking about text and vector graphics.
* "OpenAL" is an audio framework / API.
* "OpenType" is a font format (TrueType is already mentioned).
* "WebRTC", "WebSocket", "WebTransport" are web networking technologies.
* "NetBSD" and "OpenBSD" are like the already included FreeBSD.

changelog: [`doc_markdown`]: Add AccessKit, CoreFoundation, CoreGraphics, CoreText, Direct2D, Direct3D, DirectWrite, PostScript, OpenAL, OpenType, WebRTC, WebSocket, WebTransport, NetBSD, and OpenBSD to `doc-valid-idents`.
2024-07-14 14:09:20 +00:00
bors
206e4adb52 Auto merge of #13046 - Jarcho:check_conv, r=dswij
Refactor `checked_conversions`

Removes redundant checks across functions and check the HIR tree before anything else.

changelog: none
2024-07-13 16:07:29 +00:00
bors
e7d17e6cb2 Auto merge of #13061 - tesuji:fix-map-unwrap-or-13018, r=dswij
Fix `manual_unwrap_or` false positive

changelog: [`manual_unwrap_or`]: fix false positive of `if let Option<T>`

Closes #13018
2024-07-13 15:59:11 +00:00
bors
1aac7783ef Auto merge of #13085 - J-ZhengLi:issue12973, r=llogiq
make [`or_fun_call`] recursive.

fixes: #12973

---

changelog: make [`or_fun_call`] recursive.
2024-07-13 15:38:23 +00:00
J-ZhengLi
cc1bb8f57a make [or_fun_call] and [unwrap_or_default] recursive. 2024-07-13 23:15:40 +08:00
Bruce Mitchener
39378cf4f4 Add more doc-valid-idents
* "AccessKit" is a commonly used accessibility toolkit used in Rust GUIs.
* "CoreFoundation", "CoreGraphics", "CoreText" are frameworks on Apple OSes.
* "Direct2D", "Direct3D", "DirectWrite" are frameworks on Windows
* "PostScript" is a programming language and is mentioned when talking about
  text and vector graphics.
* "OpenAL" is an audio framework / API.
* "OpenType" is a font format (TrueType is already mentioned).
* "WebRTC", "WebSocket", "WebTransport" are web networking technologies.
* "NetBSD" and "OpenBSD" are like the already included FreeBSD.
2024-07-13 15:50:29 +07:00
bors
0cbbee1e6e Auto merge of #13090 - J-ZhengLi:issue9790, r=blyxyas
[`unwrap_or_default`]: skip warning when calling inside of suggested method's implementation

fixes: #10228

---

changelog: [`unwrap_or_default`]: skip warning when calling inside of suggested method's implementation
2024-07-12 14:37:10 +00:00
bors
51a1cf0787 Auto merge of #13089 - flba-eb:fix_example, r=y21
Fix syntax errors in example code (clippy::cast_nan_to_int)

Fix two small syntax errors to make the examples compile.

changelog: none
2024-07-12 09:30:24 +00:00
J-ZhengLi
983b4c3720 [unwrap_or_default]: skip warning when calling inside of suggested method's implementation 2024-07-12 17:23:08 +08:00
Florian Bartels
edeb0fcddc Fix syntax errors in example code 2024-07-12 11:12:01 +02:00
bors
86d348df90 Auto merge of #12656 - SpencerAWill:Add-expand-all-to-the-web-site, r=xFrednet
Add 'Expand All' & 'Collapse All' to the website

changelog: Add 'Expand All' and 'Collapse All' buttons to the website.
Fixes #12542

Desktop view:
![image](https://github.com/rust-lang/rust-clippy/assets/43732866/554d7782-352c-4705-83f0-1cbc809a3290)

Mobile view:
![image](https://github.com/rust-lang/rust-clippy/assets/43732866/2845fc9a-a9e8-4057-b7dd-a8a1dbf47290)

I did have some slight performance issues with lots of tabs being open. In the future it may be worth it to consider virtual scrolling. I'm not sure if this would allow ctrl+f finding on all the lints since the DOM won't contain the text of all the lints, just those that need to be immediately shown.
2024-07-11 20:04:46 +00:00
Spencer Will
6ae5fd958f
Remove event propagation calls. Adjust column spacing for filter panel to give more space for buttons on smaller screens. 2024-07-11 21:59:33 +02:00