Commit graph

461 commits

Author SHA1 Message Date
Jason Newcomb
083b1c1059 Remove is_type_lang_item 2025-10-10 22:44:01 -04:00
Jason Newcomb
748a593a7f Add new utils for defninition identification. 2025-10-10 22:30:25 -04:00
Nick Drozd
b71fe9254d Check structs and enums for use_self 2025-10-09 18:23:12 -05:00
Jason Newcomb
6cc8f8dbaa
Do not trigger inefficient_to_string after Rust 1.82 (#15729)
Starting with Rust version 1.82.0, the compiler generates similar code
with and without the `with_ref` cfg:

```rust
fn f(x: impl IntoIterator<Item = String>) {
    for y in x { println!("{y}"); }
}

fn main() {
    #[cfg(with_ref)]
    let a = ["foo", "bar"].iter().map(|&s| s.to_string());
    #[cfg(not(with_ref))]
    let a = ["foo", "bar"].iter().map(|s| s.to_string());
    f(a);
}
```

The generated code is strictly identical with `-O`, and identical modulo
some minor reordering without.

changelog: [`inefficient_to_string`]: do not trigger for Rust ≥ 1.82.0
2025-10-01 22:02:53 +00:00
Samuel Tardieu
951d35eeb6
Do not trigger inefficient_to_string after Rust 1.82
Starting with Rust version 1.82.0, the compiler generates similar code with
and without the `with_ref` cfg:

```rust
fn f(x: impl IntoIterator<Item = String>) {
    for y in x { println!("{y}"); }
}

fn main() {
    #[cfg(with_ref)]
    let a = ["foo", "bar"].iter().map(|&s| s.to_string());
    #[cfg(not(with_ref))]
    let a = ["foo", "bar"].iter().map(|s| s.to_string());
    f(a);
}
```

The generated code is strictly identical with `-O`, and identical modulo
some minor reordering without.
2025-10-01 23:13:33 +02:00
Alejandra González
0c7e0344cf
Do not suggest using a if let chain if it is not supported (#15746)
This might be due to a low edition (< 2024) or too low a MSRV. In this
case, we will suggest only `match`.

Fixes rust-lang/rust-clippy#15744

changelog: [`unnecessary_unwrap`]: do not suggest using `if let` chains
if this is not supported with the current edition or MSRV
changelog:[`collapsible_if`]: Do not suggest using `if let` if this is
not supported with the current edition or MSRV
2025-10-01 16:08:15 +00:00
Samuel Tardieu
f1079915b4
Do not suggest using a if let chain if it is not supported
This might be due to a low edition (< 2024) or too low a MSRV.
2025-10-01 07:41:49 +02: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
Ada Alakbarova
7449d63ab7
fix(or_fun_call): respect MSRV for Result::unwrap_or_default suggestion 2025-09-24 19:25:08 +02:00
Ada Alakbarova
38a2829c97
doc(trait_checking): use is_some_and 2025-09-23 16:58:45 +02:00
Samuel Tardieu
301092e249
Remove automatic feature freeze comment
The feature freeze period is over.
2025-09-17 18:46:08 +02:00
Emmanuel Thompson
2972ae5e53 rename_lint: unchecked_duration_subtraction to unchecked_time_subtraction 2025-09-17 09:30:22 -04: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
yanglsh
54ced9fd1c doc_markdown: add InfiniBand and RoCE to whitelist 2025-08-26 06:13:26 +08:00
Philipp Krones
7dd11b8119
Check config options in test suite (#15397)
Check that all configuration options reference existing lints. This was
prompted by a discussion on a PR review in which a non-detected
discrepancy was introduced.

While adding and testing this test, references to two non-existing lints
were removed.

This test doesn't run as part of the rustc test suite.

changelog: none
2025-08-23 13:45:35 +00:00
Philipp Krones
874f1c8dc0
Update actions/checkouts to v5 (#15457)
Update
[actions/checkouts](https://github.com/actions/checkout?tab=readme-ov-file#usage)
to v5

changelog: none
2025-08-11 17:59:04 +00:00
Alexey Semenyuk
696d96daa1 Update actions/checkouts to v5 2025-08-11 19:40:49 +05:00
Ada Alakbarova
2293095c91
doc: use is_some_and instead of map_or(false, _)
see
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
2025-08-11 09:48:20 +02:00
Alex Macleod
7dd3ecb1f9
Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust (#15448)
JetBrains has transitioned from the IntelliJ Rust plugin to RustRover as
their dedicated Rust IDE. This updates the documentation to reflect this
change while maintaining backward compatibility with the existing `cargo
dev setup intellij` command.

Changes:
- Replace IntelliJ Rust references with RustRover in CONTRIBUTING.md
- Update links to point to official RustRover homepage
- Update development guide in book/src/development/basics.md
- Keep existing command names for backward compatibility

**Question**: Do we also need to change the `intellij` command to
`rustrover`?

fixes rust-lang/rust-clippy#15406

changelog: Update CONTRIBUTING.md to reference RustRover instead of
deprecated IntelliJ Rust
2025-08-10 13:52:35 +00:00
reddevilmidzy
aeec153974 Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust
JetBrains has transitioned from the IntelliJ Rust plugin to RustRover
as their dedicated Rust IDE. This updates the documentation to reflect
this change while maintaining backward compatibility with the existing
cargo dev setup intellij command.

Changes:
- Replace IntelliJ Rust references with RustRover in CONTRIBUTING.md
- Update links to point to official RustRover homepage
- Update development guide in book/src/development/basics.md
- Keep existing command names for backward compatibility
2025-08-10 01:45:54 +09:00
Dave Rolsky
5c617b4867
Add "PowerPC" to the list of valid CamelCase strings in docs 2025-08-09 10:28:14 -05:00
Samuel Tardieu
a7162e416e
Remove references to two unknown lints in config
`option_map_unwrap_or` and `seek_rewind` are not current lints, and
cannot be referenced as having the `msrv` configuration option.
2025-08-03 00:04:55 +02:00
Samuel Tardieu
18a13b15fe
Do not treat NixOS as a Pascal-cased identifier 2025-07-28 15:25:46 +02:00
alexey semenyuk
f3b3c096fd Polishing changelog update doc 2025-06-30 17:19:12 +05:00
Samuel Tardieu
9117cb0223
zero_ptr: lint in const context as well
The lint was extra restrictive, and didn't suggest using
`core::ptr::null` and `core::ptr::null_mut` in `const` contexts although
they have been const-stabilized since Rust 1.24.
2025-06-26 23:09:37 +02:00
Philipp Krones
8050e591b6
Update book and templates with feature freeze (#14456)
This PR announces the feature freeze period talked about in
https://github.com/rust-lang/rust-clippy/issues/14364

1. Add the page to the book
2. Modify the in-Github templates.
3. The third commit (to be squashed into the first) rolls the date
mentioned 6 weeks (so, starting on May 9th and ending on August 20th).
This gives us a comfortable buffer to make choices for this period.

We have a pending discussion on the #14364. So having some more time to
make choices is very nice. I'm also preparing a Github action for
detecting new lints and posting a comment about the feature freeze
(being worked on in another branch)

Something I'd like comment on is the date formatting. I'm not sure if
"May 9th to the first of August" is the correct way of writing this
information in a book 😅.

changelog: Announce the feature freeze from May 9th to the first of
August
2025-06-26 16:45:13 +00:00
Philipp Krones
b88d162d2a
Add link to the feature freeze tracking issue to the book 2025-06-26 18:40:51 +02:00
Samuel Tardieu
19c1c70905
Add allow-invalid configuration option for disallowed_* to the documentation (#14845)
Close rust-lang/rust-clippy#14836

changelog: none
2025-06-17 09:05:05 +00:00
Samuel Tardieu
506411d9d1
Fix collapsible_else_if FP on conditionally compiled stmt (#14906)
Closes rust-lang/rust-clippy#14799

changelog: [`collapsible_else_if`] fix FP on conditionally compiled stmt
2025-06-13 15:45:00 +00:00
yanglsh
fea8dd28a0 Lint more cases in collapsible_else_if 2025-06-13 22:54:59 +08:00
Samuel Tardieu
af5b6e8c8e
docs(trait_checking): import the right function (#14891)
`is_trait_method` is not even used in this codeblock, whereas
`implements_trait` is used but not imported

(not sure if this is _actually_ a "changelog: none", since the
documentation is at least contributor-facing)

changelog: none
2025-05-30 08:28:04 +00:00
Kazuki Obata
402fc8105b
Update trait_checking.md 2025-05-28 23:37:31 +09:00
blyxyas
6f0fae3748 Minor fixes and date correction to book page 2025-05-28 14:05:19 +02:00
Ada Alakbarova
aa667f4317
use the correct path to the function 2025-05-25 13:39:03 +02:00
Ada Alakbarova
6291b91cad
docs(trait_checking): import the right function
`is_trait_method` is not even used in this codeblock, whereas `implements_trait` is used but not imported
2025-05-25 02:41:29 +02:00
Jason Newcomb
9fa448a119
Make trivial-copy-size-limit consistently the size of the target pointer (#13319)
Fixes
https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Ambiguous.20default.20value.20for.20.60trivial-copy-size-limit.60

The current situation is

| Target width | `trivial-copy-size-limit`|
|--------|--------|
| 8-bit | 2 |
| 16-bit | 4 |
| 32-bit | 8 |
| 64-bit | 8 |

~~Since practically speaking it's almost always 8, let's go with that as
the unconditional default to make it easier to understand~~

Now defaults to `target_pointer_width`

changelog: [`trivial-copy-size-limit`] now also defaults to the size of
a target pointer (unchanged for 64-bit targets)
2025-05-21 20:05:31 +00:00
Timo
03ba508d0e
Fixes manual_slice_size_computation ICE and triggers in const context (#14804)
The first commit fixes rust-lang/rust-clippy#14802: when a slice is
directly present, it must be dereferenced (instead of referenced -1
times) before being passed to `mem::size_of_val()`.

The second commit triggers the lint in a `const` contact when MSRV ≥
1.85.

changelog: [`manual_slice_size_computation`]: fix ICE in suggestion to
efficiently compute the size of a slice, and trigger the lint in `const`
context as well
2025-05-20 22:35:15 +00:00
Alexey Semenyuk
0bac1ca2a7 Add allow-invalid configuration option for disallowed_* to the documentation 2025-05-20 09:22:37 +05:00
Philipp Krones
7123f2acf7
Docs: Use spaces in good first issue label
This unifies the Clippy repo with the rest of the rust org repos.
2025-05-19 09:37:47 +02:00
Pete LeVasseur
1e3fc3cc46 fix minor typo: toolcahin => toolchain
changelog: none
2025-05-18 17:26:28 +09:00
Samuel Tardieu
fe4b4e8329
mem::size_of_val is const-stable since Rust 1.85 2025-05-14 23:38:37 +02:00
SLUCHABLUB
488e4e53d2 Add the allow_exact_repetitions option to the module_name_repetitions lint. 2025-05-14 10:49:01 +02:00
Philipp Krones
54aa120f18
Update "Changelog update walkthrough" section (#14785)
Update "Changelog update walkthrough" section based on
rust-lang/rust-clippy#14748 discussion

changelog: none
2025-05-12 19:29:36 +00:00
Alexey Semenyuk
2215282fa4 Update Changelog update walkthrough docs section 2025-05-12 22:15:53 +05:00
Kazuki Obata
18eb293435
update dev doc: update FnKind::Fn matching
Ident was moved to the struct Fn in https://github.com/rust-lang/rust/pull/138740
2025-05-11 16:05:31 +09:00
Samuel Tardieu
bde939058b
char::is_digit() is const-stable only since Rust 1.87
The `to_digit_is_some()` lint suggests using `char::is_digit()`. It
should not trigger in const contexts before Rust 1.87.
2025-05-10 00:20:55 +02:00
Alex Macleod
33f81c08aa Use cargo dev setup toolchain in install from source docs 2025-05-09 01:38:20 +00:00
Samuel Tardieu
73dd05cc7a
add allow_unused config to missing_docs_in_private_items (#14453)
fixes #14413
add allow_unused config to missing_docs_in_private_items for underscored
field

changelog: [`missing_docs_in_private_items`]: add allow_unused config to
missing_docs_in_private_items for underscored field

Explaination (quoted from the issue's author): When writing structures
that must adhere to a specific format (such as memory mapped I/O
structures) there are inevitably fields that are "reserved" by
specifications and thus need no documentation. In cases where private
docs are preferred but reserved fields need no explanation, having to
#[allow/expect] this lint removes the ability to check for otherwise
used fields' documentation.
2025-05-06 17:18:14 +00:00
Alex Macleod
b768fbe4bc Replace str path utils with new PathLookup type 2025-05-04 15:26:37 +00:00
Quang Duong Nguyen
481abc1361 fix doc 2025-05-03 15:17:03 -07:00