Commit graph

11899 commits

Author SHA1 Message Date
VictorHugoPilled
d66e9addd6 fix: Fixed incorrect comment form suggestion
chore: Ran cargo dev fmt

chore: Fixed spacing

fix: Fixed spacing for comment suggestion

fix: Added new module level test to too_long_first_doc_paragraph

chore: Ran cargo uibless
2024-09-12 23:33:22 +00:00
cuishuang
b0db9c285d Remove unnecessary symbols and add missing symbols
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-09 21:48:12 +08:00
bors
0ee2650e07 Auto merge of #13370 - jtherrmann:master, r=dswij
Fix possible typo in `ptr_arg` lint

This fixes a possible typo in the [`ptr_arg`](https://rust-lang.github.io/rust-clippy/master/index.html#/ptr_arg) lint. I'm new to Rust, so apologies if I misunderstood the meaning of this lint.

changelog: [`ptr_arg`]: Fix typo ("size" -> "type")
2024-09-08 15:11:09 +00:00
bors
bcf528bdef Auto merge of #13324 - WeiTheShinobi:single_match, r=dswij
[`single_match`, `single_match_else`] fix suggestion when match irrefutable

fixes #13012

changelog:[`single_match`, `single_match_else`]: fix suggestion when `match` irrefutable
2024-09-08 15:02:35 +00:00
bors
41dc86d4d3 Auto merge of #13214 - apoisternex:issue12907, r=Centri3
Fix [`needless_return`] false negative

Fixes #12907

changelog: Fix [`needless_return`] false negative when returned expression borrows a value.
2024-09-07 21:47:32 +00:00
Jake Herrmann
25efc04ea5
Fix typo 2024-09-07 12:00:34 -08:00
Samarth1696
af3346a85f Check for get method and new test case in unfixable 2024-09-07 13:21:14 +05:30
Samarth1696
d43acb803f Added checks for binary expr and added different test cases for unfixable cases 2024-09-07 13:21:14 +05:30
Samarth1696
bed44418ec refactored the code 2024-09-07 13:21:14 +05:30
Samarth1696
0f99aa992e all tests passed 2024-09-07 13:21:14 +05:30
Samarth1696
6f01273d5d dogfood test passed 2024-09-07 13:21:14 +05:30
Samarth1696
73039f654e test cases added including some edge cases 2024-09-07 13:21:14 +05:30
Samarth1696
46f8d360de Lint ready 2024-09-07 13:21:09 +05:30
WeiTheShinobi
e3ca249e96
fix single_match suggestion 2024-09-06 23:10:42 +08:00
bors
fb9913ef3b Auto merge of #13327 - Sour1emon:master, r=llogiq
Add new lint `manual_is_power_of_two`

Suggest using `is_power_of_two()` instead of the manual implementations for some basic cases

Part of https://github.com/rust-lang/rust-clippy/issues/12894

----

changelog: new [`manual_is_power_of_two`] lint
2024-09-06 10:36:57 +00:00
bors
7d7b298a4e Auto merge of #13352 - kpreid:patch-1, r=xFrednet
Correct version of `too_long_first_doc_paragraph`

`too_long_first_doc_paragraph` is, empirically, not in the Rust 1.81.0 release.

changelog: [`too_long_first_doc_paragraph`]: correct Rust version number in documentation.
2024-09-06 07:16:18 +00:00
Sour1emon
f994797e46 Add support for different orders of expression 2024-09-05 18:38:12 -07:00
Isaac Bess
6ecb48f6d0 Fixed extra backtick
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2024-09-05 18:38:12 -07:00
Isaac Bess
5515566829 Improve "Why this is bad" section
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2024-09-05 18:38:12 -07:00
Sour1emon
d7996da9da Add manual_is_power_of_two 2024-09-05 18:38:06 -07:00
Artem Belyakov
9415e6e6eb Add manual_div_ceil 2024-09-06 00:55:42 +02:00
bors
c41be9e125 Auto merge of #13345 - Alexendoo:manual-non-exhaustive-visibility, r=y21
Only lint `manual_non_exhaustive` for exported types

For types that are not exported the attribute doesn't make a difference, but the manual pattern can still be used to achieve module level non exhaustiveness

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

changelog: none
2024-09-05 21:52:42 +00:00
Kevin Reid
79081f1271
Correct version of too_long_first_doc_paragraph
`too_long_first_doc_paragraph` is, empirically, not in the Rust 1.81.0 release.
2024-09-05 14:30:27 -07:00
Philipp Krones
40fca8f7a8
Bump Clippy version -> 0.1.83 2024-09-05 17:00:55 +02:00
Philipp Krones
87ce1d8069
Merge remote-tracking branch 'upstream/master' into rustup 2024-09-05 17:00:37 +02:00
bors
c95c767663 Auto merge of #13323 - xFrednet:chnagelog-1-81, r=flip1995
Changelog for Clippy 1.81 🔰

Roses are red,
Violets are blue,
Expectations are stable,
And reasons are set

---

### The cat of this release is *Keepy* submitted by `@blyxyas:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/73757586/902dd802-5ac8-471e-bb93-e195526ba580" alt="The cats of this Clippy release" />

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

---

changelog: none
2024-09-05 09:17:12 +00:00
Alex Macleod
f7f550561e Only lint manual_non_exhaustive for exported types 2024-09-04 21:22:28 +00:00
bors
58cbf09e86 Auto merge of #13332 - nyurik:nits, r=xFrednet
Minor code simplification

changelog: none
2024-09-03 20:47:48 +00:00
bors
f2ef26d239 Auto merge of #13263 - y21:warn_manual_c_str_literals, r=Centri3
move `manual_c_str_literals` to complexity

IMO the suggestion to use `c""` literals over a hardcoded `\0` byte string literal has some fairly strong upsides (no need to manually null-terminate it and the compiler checks for intermediary null bytes) that this should just be enabled by default.

It's also written slightly conservatively to only emit a warning when we can be reasonably confident that the lint is *actually* applicable (that is, lint on e.g. `b"foo\0".as_ptr()` but not `b"foo\0"`. The latter looks like a c-string but its type is `&[u8; _]`, and if it's used in a context where a byte slice is needed then you have no nice way to convert to it from a `c"foo"` literal of type `&CStr`).

changelog: move [`manual_c_str_literals`] to complexity (now warn-by-default)
2024-09-03 18:29:20 +00:00
Soveu
273b561609 add pointers_in_nomem_asm_block lint 2024-09-03 18:58:05 +02:00
Yuri Astrakhan
cd28176025 Minor code simplification 2024-09-01 20:58:14 -04:00
bors
a81f1c8277 Auto merge of #13325 - alex-semenyuk:wrong_self_convention_doc_fix, r=y21
Provide more clear example for `WRONG_SELF_CONVENTION`

Provide more clear example for `WRONG_SELF_CONVENTION`

changelog: none
2024-09-01 08:28:00 +00:00
alexey semenyuk
989ebae2ba Provide more clear example for WRONG_SELF_CONVENTION 2024-08-31 23:06:03 +05:00
bors
ac914d3457 Auto merge of #12476 - GuillaumeGomez:add-manual_arithmetic_check, r=y21
Extend `implicit_saturating_sub` lint

Fixes #10070.

It can serve as base if we want to add equivalent checks for other arithmetic operations.

Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though...

changelog: Extend `implicit_saturating_sub` lint
2024-08-31 16:03:42 +00:00
Guillaume Gomez
2832faf895 Move MSRV check later in implicit_saturating_sub 2024-08-31 16:24:17 +02:00
Guillaume Gomez
e845366c82 Add MSRV check for saturating_sub lints in const contexts 2024-08-31 16:24:17 +02:00
WeiTheShinobi
04d70d04fc
[single_match, single_match_else] fix suggestion when match irrefutable 2024-08-31 05:25:59 +08:00
xFrednet
9e7473f08d
Update version attribute for 1.81 lints 2024-08-29 21:36:43 +02:00
Guillaume Gomez
d20fc38f0a Create new inverted_saturating_sub lint 2024-08-29 20:20:13 +02:00
Guillaume Gomez
74a2344dc1 Extend implicit_saturation_sub lint 2024-08-29 20:20:13 +02:00
Michael Goulet
5bbb0d41f1 Stop using ty::GenericPredicates for non-predicates_of queries 2024-08-29 00:17:40 -04:00
bors
04bded5d6e Auto merge of #13235 - kyoto7250:fix_issue_13191, r=llogiq
Use `is_diagnostic_item` for checking a def_id in `unnecessary_min_or_max`.

close #13191
This PR fixes the false positives in `unnecessary_min_or_max `.
We should use `is_diagnostic_item` for checking def_ids in this lint.

----

changelog: fix false positive in `unnecessary_min_or_max `.
2024-08-28 14:50:20 +00:00
y21
e8ac4ea418 new lint: zombie_processes 2024-08-27 21:51:02 +02:00
bors
603d5a19c9 Auto merge of #13294 - WeiTheShinobi:new_lint_used_underscore_items, r=llogiq
Add new lint: `used_underscore_items`

Closes #13260

---

changelog: new [`used_underscore_items`] lint against using items with a single leading underscore
2024-08-27 10:59:31 +00:00
bors
f194e684b1 Auto merge of #13311 - alex-semenyuk:fix_manual_range_patterns, r=Manishearth
Fix manual_range_patterns case with one element at OR

Close #11825
As mentioned #11825 `OR` can be used for stylistic purposes with one element, we can filter this case from triggering lint

changelog: [`manual_range_patterns`]: not trigger when `OR` has only one element
2024-08-26 21:10:54 +00:00
Alexey Semenyuk
494112e51f Fix manual_range_patterns case with one element at OR 2024-08-27 01:32:07 +05:00
bors
b3fc578ca6 Auto merge of #13300 - kyoto7250:issue_13292, r=llogiq
check std::panic::panic_any in panic lint

close #13292
This PR detects `std::panic::panic_any` in panic lint.

changelog: check std::panic::panic_any in panic lint
2024-08-26 19:32:11 +00:00
bors
ebcd6bc785 Auto merge of #13091 - Alexendoo:empty-line-after-rewrite, r=dswij
Rewrite `empty_line_after_doc_comments` and `empty_line_after_outer_attr`, move them from `nursery` to `suspicious`

changelog: [`empty_line_after_doc_comments`], [`empty_line_after_outer_attr`]: rewrite and move them from `nursery` to `suspicious`

They now lint when there's a comment between the last attr/doc comment and the empty line, to cover the case:

```rust
/// Docs for `old_code
// fn old_code() {}

fn new_code() {}
```

When these lints or `suspicious_doc_comments` trigger we no longer trigger any other doc lint as a broad fix for #12917, reverts some of #13002 as the empty line lints cover it

I ended up not doing https://github.com/rust-lang/rust-clippy/issues/12917#issuecomment-2161828859 as I don't think it's needed
2024-08-25 17:47:09 +00:00
bors
083e20a6dc Auto merge of #13113 - nyurik:ignore-pass-by-val-for-pfx, r=blyxyas
Ignore underscore-prefixed args for needless_pass_by_value lint

When a user explicitly tags a param as unused (yet?), there is no need to raise another lint on it.

fixes #7295

Note that I had to rename all `_*` params in the tests, but kept the variable name length to avoid extra changes in the expected output.

changelog: [`needless_pass_by_value`]: do not warn if the argument name starts with an `_`
2024-08-25 17:28:51 +00:00
WeiTheShinobi
d40e04a1cb
used_underscore_items will not lint exteranl item 2024-08-26 00:52:52 +08:00