Commit Graph

1471 Commits

Author SHA1 Message Date
Nick Drozd b71fe9254d Check structs and enums for use_self 2025-10-09 18:23:12 -05:00
llogiq e6febbd13b Add lint unnecessary_option_map_or_else (#14662)
changelog: [`unnecessary_option_map_or_else`]: Added lint
unnecessary_option_map_or_else. As suggested in the issue description,
the implementation takes as reference the issue
rust-lang/rust-clippy#7328. The tests for lints `option_if_let_else` and
`or_fun_call` needed to be adjusted to comply with new lint.
fixes rust-lang/rust-clippy#14588
2025-10-09 21:56:14 +00:00
+merlan #flirora 517ef604af Add replace_box lint 2025-10-07 11:33:54 -04:00
Pietro Nuti 4c128d9ee0 Add lint unnecessary_option_map_or_else 2025-09-28 14:39:58 +02:00
Jeremy Fitzhardinge 1d7c1afde0 Implement volatile_composites lint
Volatile reads and writes to non-primitive types are not well-defined, and can cause problems.

See https://github.com/rust-lang/rust-clippy/issues/15529 for more details.
2025-09-27 16:22:00 -07:00
Jason Newcomb 5e02a4eecf rename unchecked_duration_subtraction to unchecked_time_subtraction and check for Duration - Duration (#13800)
fixes https://github.com/rust-lang/rust-clippy/issues/13734

This PR renames `unchecked_duration_subtraction` lint to
`unchecked_time_subtraction` and extends it to include `Duration -
Duration` operations. Previously, it was only `Instant - Duration`.
`Duration - Duration` is a common operation which may panic in the same
way.

Note: This is my first clippy PR, feedback is appreciated.

changelog: [`unchecked_time_subtraction`]: renamed from
`unchecked_duration_subtraction`, extend lint to include subtraction of
a `Duration` with a `Duration`
2025-09-27 08:28:58 +00:00
Samuel Tardieu 8ea47a6dd7 Add clippy::self_only_used_in_recursion lint (#14787)
and use it instead of `clippy::only_used_in_recursion` when the
parameter in question is self.

Fixes rust-lang/rust-clippy#10370

changelog: [`only_used_in_recursion`]: Don't lint if parameter is
`self`; add pedantic `self_only_used_in_recursion` lint.
2025-09-19 11:25:56 +00:00
pommicket 63a55083aa Add clippy::self_only_used_in_recursion lint
and use it instead of clippy::only_used_in_recursion
when the parameter in question is self.
2025-09-18 13:48:04 -04:00
Samuel Tardieu 8a5dc7c171 Changelog: fix heading level in 1.90 section (#15703)
changelog: none
2025-09-18 15:40:20 +00:00
Alejandra González 4b109ed0f4 redundant_clone: split iterator checks into redundant_iter_cloned (#15277)
Needed to split the lints crate.

changelog: split `redundant_clone` iterator checks into
`redundant_iter_cloned`

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Feature-freeze](https://github.com/rust-lang/rust-clippy/pull/15277#issuecomment-3073454006)
by [github-actions[bot]](https://github.com/github-actions[bot])

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-09-18 14:50:18 +00:00
Kevin Reid 427774af07 Changelog: fix heading level in 1.90 section 2025-09-18 07:46:17 -07:00
Emmanuel Thompson 2972ae5e53 rename_lint: unchecked_duration_subtraction to unchecked_time_subtraction 2025-09-17 09:30:22 -04:00
Alexey Semenyuk 8af6638666 Changelog for Clippy 1.90 2025-09-14 20:16:51 +05:00
Teodoro Freund fc3959044f Supress excessive_precision when constants are overly precise
Added const associated items matching and static

Added configurable threshold

Addressed comments

Renamed lint config field
2025-08-31 16:38:57 +01:00
Philipp Krones 008b8a546a Add 1.89 beta-accepted changes to changelog 2025-08-22 17:45:53 +02:00
Alejandra González 264bc97b26 Split possible_missing_else from suspicious_else_formatting (#15317)
This has always been one lint (added in rust-lang/rust-clippy#720), but
the two cases are also quite distinct.

changelog: Split `possible_missing_else` from
`suspicious_else_formatting`

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Feature-freeze](https://github.com/rust-lang/rust-clippy/pull/15317#issuecomment-3094592022)
by [github-actions[bot]](https://github.com/github-actions[bot])

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-08-04 22:57:06 +00:00
Alexey Semenyuk 9f7a8f8f9e Changelog for Clippy 1.89 2025-07-31 20:38:41 +05:00
Jason Newcomb 9e50049157 Split possible_missing_else from suspicious_else_formatting. 2025-07-20 10:21:18 -04:00
Jason Newcomb 81e8c6797c redundant_clone: split iterator checks into redundant_iter_cloned lint 2025-07-15 09:33:38 -04:00
Philipp Krones 40554ef4aa Add beta-accepted to CHANGELOG for 1.88 (#15130)
Add beta-accepted to CHANGELOG for 1.88 since it was missed at
rust-lang/rust-clippy#5095

changelog: none

r? flip1995
2025-06-26 16:30:45 +00:00
Alexey Semenyuk 95f0991ad4 Add beta-nominated to changelog for 1.88 2025-06-25 15:38:20 +05:00
Ada Alakbarova c11bc75fb0 changelog: link to the correct PR 2025-06-25 01:00:34 +02:00
Alexey Semenyuk 2e63c7c684 Changelog for Clippy 1.88 2025-06-23 22:26:52 +05:00
Samuel Tardieu 6ffff5f009 New lint: manual_is_multiple_of 2025-06-20 09:42:28 +02:00
Jason Newcomb af9d56860e Add lint for broken doc links (#13696)
fixes https://github.com/rust-lang/rust-clippy/issues/2179

changelog: [`doc_broken_link`]: Add pedantic lint to catch broken doc
links that won't produce a link tag by rustdoc.
2025-06-16 15:19:03 +00:00
llogiq b379d54c22 Introduce coerce_container_to_any (#14812)
This PR introduces a lint which detects when `&Box<dyn Any>` is coerced
to `&dyn Any`, which is usually a mistake where the intent was to
directly pass the `dyn Any` inside the box without coercion.

cc @llogiq

Remaining work:
- [x] Documentation
- [x] Generalize from Box to any implementer of `Deref<Target=dyn Any>`

----

changelog: add [`coerce_container_to_any`] lint
2025-06-05 19:37:32 +00:00
llogiq 6ef2a2d177 add new lint: ip_constant (#14878)
Closes: rust-lang/rust-clippy#14819

changelog: new lint: [`ip_constant`]
2025-06-05 19:36:33 +00:00
Max Claus Nunes 8964f6ed27 Add lint for broken doc links
Fix false positives on broken link detection

Refactor variable names

Fix doc comment about broken link lint

Refactor, remove not used variable

Improve broken link to catch more cases and span point to whole link

Include reason why a link is considered broken

Drop some checker because rustdoc already warn about them

Refactor to use a single enum instead of multiple bool variables

Fix lint warnings

Rename function to collect broken links

Warn directly instead of collecting all entries first

Iterate directly rather than collecting

Temporary change to confirm with code reviewer the next steps

Handle broken links as part of the fake_broken_link_callback handler

Simplify broken link detection without state machine usage

Fix typos

Add url check to reduce false positives

Drop reason enum as there is only one reason

Fix duplicated diagnostics

Fix linter
2025-06-05 15:59:21 -03:00
relaxcn 8d8b3f16d7 Add new lint: ip_consant 2025-06-03 09:11:20 +00:00
Michael Howell fcfbcc81f2 doc_suspicious_footnotes: lint text that looks like a footnote 2025-06-02 13:20:49 -07:00
Benjamin Saunders b51e73701d Introduce coerce_container_to_any 2025-06-02 11:11:56 -07:00
llogiq d7b27ecbf3 add lint infallible_try_from (#14813)
Looks for `TryFrom` implementations with uninhabited error types and
suggests to implement `From` instead.

Fixes rust-lang/rust-clippy#2144

---

changelog: Add [`infallible_try_from`] lint
2025-06-02 11:52:57 +00:00
Andre Bogus e64dd8ed96 new restriction lint: pointer_format 2025-05-30 09:15:53 +02:00
Dan Johnson 8e581e31a2 add lint infallible_try_from
Looks for `TryFrom` implementations with uninhabited error types and
suggests to implement `From` instead.
2025-05-26 08:39:07 -07:00
Samuel Tardieu ebc2a68fe8 Add new useless_concat lint (#13829)
Fixes #13793.

Interestingly enough, to actually check that the macro call has at least
two arguments, we need to use the rust lexer after getting the original
source code snippet.

changelog: Add new `useless_concat` lint
2025-05-19 15:11:37 +00:00
SLUCHABLUB 488e4e53d2 Add the allow_exact_repetitions option to the module_name_repetitions lint. 2025-05-14 10:49:01 +02:00
llogiq 7bac114c86 Add new lint: cloned_ref_to_slice_refs (#14284)
Added lint for catching `&[foo.clone()]` where foo is a reference and
suggests `std::slice::from_ref(foo)`.

changelog: new lint: [`cloned_ref_to_slice_refs`]
2025-05-13 05:32:33 +00:00
asdfish 40e1b0ed00 add lint cloned_ref_to_slice_refs
remove merge

removed false positive and improved tests

clarify known problems for `cloned_ref_to_slice_refs`
2025-05-12 21:12:58 -04:00
llogiq b363499457 Add new confusing_method_to_numeric_cast lint (#13979)
Fixes https://github.com/rust-lang/rust-clippy/issues/13973.

I don't think we can make `fn_to_numeric_cast_any` to be emitted in some
special cases. Its category cannot be changed at runtime.

I think in this case, the best might be a specialized new lint so we can
target exactly what we want.

----

changelog: Add new `confusing_method_to_numeric_cast` lint
2025-05-12 15:27:33 +00:00
Guillaume Gomez a8679816dc Add new useless_concat lint 2025-05-12 14:14:45 +02:00
Philipp Krones 2ce5451850 Changelog for Clippy 1.87 🦡 (#14748)
Violets are red,
Roses are blue,
It’s wrong on purpose —
We don’t break tradition.

<hr>

This is cat-penguin of this release [nominated
by](https://github.com/rust-lang/rust-clippy/pull/12224#issuecomment-1927555104)
@xFrednet some time ago:

![image](https://github.com/user-attachments/assets/49bd7783-9d56-4a15-b026-1c7e799ea7ba)

Cats for the next release can be traditionally nominated in the comments
:D
Please be more active and cat-minded 😻

<hr>

changelog: none

r? flip1995
2025-05-12 10:00:01 +00:00
Alexey Semenyuk 55b5c835c5 Changelog for Clippy 1.87 2025-05-12 14:50:27 +05:00
Guillaume Gomez 06fa0452eb Rename lint into confusing_method_to_numeric_cast 2025-05-07 21:38:38 +02:00
Guillaume Gomez be40534457 Add primitive_method_to_numeric_cast lint 2025-05-07 18:18:04 +02:00
Quang Duong Nguyen c468552097 add allow_unused config to missing_docs_in_private_items
add allow_unused config to missing_docs_in_private_items for underscored field
2025-05-03 15:17:03 -07:00
Timo ac88357f83 New lint: swap_with_temporary (#14046)
This lint detects inefficient or useless `{std,core}::mem::swap()` calls
such as:

```rust
    // Should be `a = temp();`
    swap(&mut a, &mut temp());
    // Should be `*b = temp();`
    swap(b, &mut temp());
    // Should be `temp1(); temp2();` if we want to keep the side effects
    swap(&mut temp1(), &mut temp2());
```

It also takes care of using a form appropriate for a `()` context if
`swap()` is part of a larger expression (don't ask me why this wouldn't
happen, I have no idea), by suggesting `{ x = y; }` (statement in block)
or `{std,core}::mem::drop((temp1(), temp2())`.

changelog: [`swap_with_temporary`]: new lint

Close #1968
2025-04-17 12:42:46 +00:00
Samuel Tardieu 05448bd9c7 New lint: swap_with_temporary 2025-04-17 13:17:43 +02:00
Victor Farazdagi e2422a618d new lint: redundant_test_prefix 2025-04-15 14:42:09 +03:00
Samuel Tardieu e463309f4a add manual_abs_diff lint (#14482)
changelog: [`manual_abs_diff`]: Initial implementation

Hey, first time writing a new lint for clippy, hope I got it right. I
think it's pretty self-explanatory!
Added a few `fixme` test cases, where the lint can be improved to catch
more (probably rare) patterns, but opening a PR with this initial
implementation to make sure I'm on the right track, and that this lint
is acceptable at all.

😁
2025-04-09 10:29:48 +00:00
Philipp Krones 944dfc749f Changelog for Clippy 1.86 2025-04-03 21:42:16 +02:00