Commit graph

425 commits

Author SHA1 Message Date
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
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
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
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
Alex Macleod
b52bd96713 Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
Timo
781fdab9a9
Move internal lints to their own crate (#13223)
This makes it so switching the internal feature on/off no longer
rebuilds `clippy_lints`.

r? @flip1995

changelog: none
2025-04-18 12:04:08 +00:00
Alejandra González
02764f611a
Various fixes for manual_is_power_of_two (#14463)
Fix #14461:

- insert parentheses as required in suggestion
- check MSRV before suggesting fix in `const` context
- do not lint macro expansion result

Commits have been logically separated to facilitate review, and start
with a refactoring (and simplification) of the existing code.

changelog: [`manual_is_power_of_two`]: insert parentheses as required in
suggestion, check MSRV before suggesting fix in `const` context, do not
lint macro expansion results
2025-04-14 22:56:38 +00:00
Samuel Tardieu
4d343d56e1 Check MSRV before suggesting fix in const context 2025-04-14 22:05:44 +02:00
Jason Newcomb
5b4b463d49 Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
Samuel Tardieu
dd21b6ecea book: indicate that at least one error marker is required
This is a recent change, and no error marker is inserted by default in
the file generated by `cargo dev new_lint`.
2025-04-11 13:11:25 +02:00
Alex Macleod
ae0e3b7e38 Default trivial_copy_size_limit to the width of a target pointer 2025-04-03 12:18:45 +00:00
Yotam Ofek
52a3082056 add manual_abs_diff lint 2025-04-02 19:40:14 +00:00
Timo
d88818d1e7
Rename inconsistent_struct_constructor configuration; don't suggest deprecated configurations (#14280)
This PR does two things:
- It renames `inconsistent_struct_constructor`'s configuration from
`lint-inconsistent-struct-field-initializers` to
`check-inconsistent-struct-field-initializers`. (I should have suggested
`check-...` in
[#13737](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1875118516).)
- It causes Clippy to no longer suggest deprecated configurations.
(Previously, Clippy would suggest `cyclomatic-complexity-threshold`, for
example.)

r? @y21

changelog: Rename `lint-inconsistent-struct-field-initializers` to
`check-inconsistent-struct-field-initializers`
changelog: No longer suggest deprecated configurations
2025-03-25 11:56:47 +00:00
Timo
9c6cb5150f
wildcard_imports: lint on pub use if asked to (#14182)
`warn_on_all_wildcard_imports` should warn on all wildcard imports,
including the reexported ones.

Fix #13660

changelog: [`warn_on_all_wildcard_imports`]: when asked to warn on all
wildcard imports, include the reexported ones
2025-03-25 00:08:45 +00:00
Samuel Tardieu
809c931804 wildcard_imports: lint on pub use if asked to
`warn_on_all_wildcard_imports` should warn on all wildcard imports,
including the reexported ones.
2025-03-24 15:49:29 +01:00
Samuel Moelius
88b590bf46 lint-inconsistent-... -> check-inconsistent-... 2025-03-23 15:22:37 -04:00
Philipp Krones
e9aed8764e
set concurrency for the deploy job (#14448)
In the current GitHub Actions CI/CD setup, the `deploy` job is not
triggered when a PR is enqueued in the merge queue but only when it is
merged. Since concurrency is not configured for this job, deployments
may fail for later PRs if multiple PRs are merged in quick succession.
(e.g. the deployment for [this
commit](c418714518)
was successful, but the deployment for [this
commit](0a141ab7b8)
that was pushed to `main` immediately afterward failed. (edit: the
latter deployment seems to be rerun))

changelog: none

r? flip1995
2025-03-23 12:15:07 +00:00
lapla-cogito
3786c07463
remove the notation of the deploy job 2025-03-23 21:09:28 +09:00
Philipp Krones
cad9083d71
Lint more cases in collapsible_if (#14231)
Replace the use of `Sugg::ast()` which prevented combining `if` together
when they contained comments by span manipulation.

A new configuration option `lint_commented_code`, which is `true` by
default, allows opting out from this behavior.

If reviewed on GitHub, the second commit of this PR is best looked at
side by side, with whitespace differences turned off.

changelog: [`collapsible_if`]: lint more cases
2025-03-23 11:17:46 +00:00
Alex Macleod
c033a4c741
Document and improve (a lot) lintcheck --perf (#14194)
In #14116 we added a benchmarking option for Lintcheck, this commit adds
a new chapter to the book AND improves that option into a more usable
state.

It's recommended to review one commit at a time.

- **Document how to benchmark with lintcheck --perf**
- **Several improvements on lintcheck perf (desc.)**

    - Now lintcheck perf deletes target directory after benchmarking,
benchmarking with a cache isn't very useful or telling of any
precise outcome.

    - Support for benchmarking several times without having to do
a cargo clean.

    - Compress perf.data

changelog: none
2025-03-23 00:01:53 +00:00
Samuel Tardieu
82381608c9 Lint more cases in collapsible_if
Replace the use of `Sugg::ast()` which prevented combining `if`
together when they contained comments by span manipulation.

A new configuration option `lint_commented_code`, which is `true` by
default, opts out from this behavior.
2025-03-22 15:12:42 +01:00
Philipp Krones
e8e0126c18
Add comment annotations (#14414)
Fix missing comment annotations in the clippy book

changelog: none
2025-03-22 13:32:51 +00:00
lapla-cogito
19c7c46d48
rename rust-toolchain to rust-toolchain.toml 2025-03-21 09:37:59 +09:00
Jan Verbeek
d793c0abfa Add MSRV check for question_mark 2025-03-19 09:33:58 +01:00
Heshan Padmasiri
5d7e55cc11 Mention about .fixed files 2025-03-17 17:55:26 +05:30
xFrednet
9845b100ec
Remove @xFrednet from docs 👋 2025-03-16 15:19:49 +01:00
Heshan Padmasiri
ae3216e702 Add comment annotations 2025-03-16 18:52:35 +05:30
y21
44094e5148 explain is_from_proc_macro in the book 2025-03-12 18:25:25 +01:00
decryphe
5df68878bf Make alphabetic ordering in module item groups configurable (new default: off)
From feedback to this lint after its inclusion in clippy 1.82, this has
turned out to be the most requested improvement. With this improvement,
it is possible to make the lint check certain top-level structural
checks on modules (e.g. use statements and module inclusions at the top),
but still leaving everything else up to the developer.
2025-03-04 09:50:47 +01:00
Alex Macleod
0972c3b565 Check for MSRV attributes in late passes using the HIR 2025-02-28 18:09:44 +00:00
Timo
2cdb90d961
New lint: manual_midpoint (#13851)
changelog: [`manual_midpoint`]: new lint

Closes #13849
2025-02-28 16:27:34 +00:00
Alejandra González
e1c1ac1592
configuration option to lint incompatible_msrv in test code (#14279)
fixes #14277

changelog: [`incompatible_msrv`]: add config option
[`check-incompatible-msrv-in-tests`] to enable in `#[test]` and
`#[cfg(test)]` code.
2025-02-28 12:41:46 +00:00
Samuel Tardieu
baadee8fd3 New lint: manual_midpoint 2025-02-27 22:12:16 +01:00
Bryce Berger
325bfef88d
configuration option to lint incompatible_msrv in test code 2025-02-25 19:54:05 -05:00
Manish Goregaokar
35d5ee0e41
add MSRV check for repeat_vec_with_capacity (#14126)
changelog: [`repeat_vec_with_capacity`]: add MSRV check
2025-02-23 15:50:44 +00:00