Commit graph

359 commits

Author SHA1 Message Date
Catherine Flores
c6a861615e
add manual_option_as_slice MSRV to the lint documentation (#14171)
`manual_option_as_slice` takes MSRV into account, but this is not
mentioned in the lint documentation.

changelog: none
2025-02-07 12:28:06 +00:00
Catherine Flores
b0ad06daa8
add MSRV check for lines_filter_map_ok (#14130)
fixes #14127

changelog: [`lines_filter_map_ok`]: respect MSRV
2025-02-07 12:24:50 +00:00
lapla-cogito
16781bf29d
add manual_option_as_slice to the lint documentation 2025-02-07 21:00:39 +09:00
Philipp Krones
f549562b81
Merge remote-tracking branch 'upstream/master' into rustup 2025-02-06 14:31:01 +01:00
Philipp Krones
660d861058
Fix docs for #[clippy::format_args] (#14161)
changelog: none
2025-02-06 09:23:50 +00:00
Philipp Krones
ee1c15eb56
Add Nursery and Deprecated groups section at Book (#13926)
[RFC](https://github.com/rust-lang/rfcs/blob/master/text/2476-clippy-uno.md#lint-audit-and-categories)
has more groups so add them

changelog: none
2025-02-06 09:23:22 +00:00
Yuri Astrakhan
694b245b20 Fix docs for #[clippy::format_args] 2025-02-06 03:21:49 -05:00
Alexey Semenyuk
c718ae8e2d Add Nursery and Deprecated lints section at Book 2025-02-05 23:09:08 +05:00
llogiq
2c51951dba
add manual_slice_fill lint (#14082)
close #13856

changelog: [`manual_slice_fill`]: new lint
2025-02-03 05:03:14 +00:00
lapla-cogito
e82b1f4653
add manual_slice_fill lint 2025-02-03 10:09:39 +09:00
Nicholas Nethercote
d30f045fce Convert two rustc_middle::lint functions to Span methods.
`rustc_middle` is a huge crate and it's always good to move stuff out of
it. There are lots of similar methods already on `Span`, so these two
functions, `in_external_macro` and `is_from_async_await`, fit right in.
The diff is big because `in_external_macro` is used a lot by clippy
lints.
2025-02-02 13:57:34 +11:00
lapla-cogito
f9669e4caf
add MSRV check for lines_filter_map_ok 2025-02-01 15:20:34 +09:00
Philipp Krones
9da9ddb7db Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
Philipp Krones
145d5adf04
Merge remote-tracking branch 'upstream/master' into rustup 2025-01-28 19:14:45 +01:00
lapla-cogito
0b818aa673
fixed a missing description of the MSRV option for manual_repeat_n 2025-01-27 04:54:40 +09:00
Kalle Wachsmuth
25a77cf4f4 remove clippy::double_neg 2025-01-26 12:15:12 +01:00
J-ZhengLi
2671e4a5c1 add new lint non_std_lazy_statics
detect usage of `once_cell::sync::Lazy` and `lazy_static!`,
recommending usage of `std::sync::LazyLock` instead
2025-01-24 14:06:46 -07:00
Fridtjof Stoldt
67e6bf33fe
Suggest using Vec::extend() in same_item_push (#13987)
Using `Vec::extend(std::iter::repeat_n(item, N))` allows to use the more
natural number of elements to add `N`, as is probably done in the
original loop, instead of computing the difference between the existing
number of elements and the wanted one.

Before MSRV 1.82, the older suggestion to use `Vec::resize()` is still
issued.

Inspired by #6156 (which predates `repeat_n()`).

changelog: [`same_item_push`]: recommend using `Vec::extend()` to extend
a vector
2025-01-22 14:41:13 +00:00
Samuel Tardieu
ded9354dcf Suggest using Vec::extend() in same_item_push
Using `Vec::extend(std::iter::repeat_n(item, N))` allows to use the more
natural number of elements to add `N`, as is probably done in the original
loop, instead of computing the difference between the existing number of
elements and the wanted one.

Before MSRV 1.82, the older suggestion to use `Vec::resize()` is still
issued.
2025-01-15 22:50:25 +01:00
Philipp Krones
6ab6c3c809
Select Rust edition 2024 for compiling Clippy (#13751)
The Cargo feature is no longer experimental and is enabled by default in
our nightly compiler.

changelog: Clippy now uses Rust edition 2024
2025-01-13 18:05:05 +00:00
Samuel Tardieu
a4805ff610 Select edition 2024 2025-01-13 16:55:42 +01:00
Philipp Krones
0db64118ca
fix(adding_lints): usage of early vs late lint pass (#13955)
changelog: none

This PR fixes explaining the difference in usage between early and late
lint passes in the book.
2025-01-13 13:21:00 +00:00
Philipp Krones
dc99034fd4
Fix link to release tags (#13930)
Since we do release tag it makes more sense to refer to tags page then
empty releases page

changelog: none
2025-01-13 13:09:33 +00:00
Philipp Krones
2d8a3e8cde
Fix not found links at Book (#13935)
Some of the links are wrong since lead to non existing docs so fix them

changelog: none
2025-01-13 10:55:57 +00:00
Philipp Krones
d0a74af979 Merge commit '19e305bb57' into clippy-subtree-update 2025-01-09 18:57:00 +01:00
lapla-cogito
f1d909034e
define_clippy_lints does not exist, declare_clippy_lints exists 2025-01-07 19:32:26 +09:00
Aaron Ang
16ee0148d4
Update adding_lints.md 2025-01-06 20:47:52 -08:00
Aaron Ang
e0625f4dd5
fix(adding_lints): usage of early vs late lint pass 2025-01-06 15:43:06 -08:00
xFrednet
4e4a2d022b
Changelog for Clippy 1.84 🧨 2025-01-03 19:40:39 +01:00
alexey semenyuk
05cb1ce0ef Fix not found links at Book 2025-01-03 20:46:44 +05:00
alexey semenyuk
a7c2e4d750 Fix link to release tags 2025-01-02 22:41:44 +05:00
Philipp Krones
998c780126
fix arguments of ExprKind::MethodCall (#13890)
changelog: none
2024-12-28 13:47:09 +00:00
lapla-cogito
09022bbd45
fix arguments of ExprKind::MethodCall 2024-12-28 22:41:29 +09:00
Timo
a8968e5dd8
Make inconsistent_struct_constructor "all fields are shorthand" requirement configurable (#13737)
Fixes #11846.

This PR has three commits:
- The first commit adds an `initializer-suggestions` configuration to
control suggestion applicability when initializers are present. The
following are the options:
  - "none": do not suggest
- "maybe-incorrect": suggest, but do not apply suggestions with `--fix`
  - "machine-applicable": suggest and apply suggestions with `--fix`
- The second commit fixes suggestions to handle field attributes
(problem [noticed by
@samueltardieu](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1859261645)).
- The third commit adds `initializer-suggestions = "machine-applicable"`
to Clippy's `clippy.toml` and applies the suggestions. (Nothing seems to
break.)

---

changelog: make `inconsistent_struct_constructor` "all fields are
shorthand" requirement configurable
2024-12-27 22:05:03 +00:00
Samuel Moelius
8a38bcc390 Make "all fields are shorthand" requirement configurable
Handle field attributes in suggestions

Fix adjacent code

Address review comments

https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124

Address all review comments but one

This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907

`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
2024-12-26 19:36:58 -05:00
Philipp Krones
1cc50519d1 Merge commit '609cd310be' into clippy-subtree-update 2024-12-26 15:15:54 +01:00
lapla-cogito
b28bfbceeb
fix examples using Ty.kind() 2024-12-25 13:59:48 +09:00
llogiq
b3fadd5a8e
Add allow-indexing-slicing-in-tests option (#13854)
Close #13842

changelog: [`indexing_slicing`]: add allow-indexing-slicing-in-tests
option to be able ignore at test
2024-12-19 20:11:48 +00:00
Alexey Semenyuk
6f6ddd299c Add allow-indexing-slicing-in-tests option 2024-12-20 01:06:49 +05:00
lapla-cogito
81c0cf8a2d
fix the team anchor in book 2024-12-17 21:53:50 +09:00
Philipp Krones
f5f2c51e70
Update backport, release and sync documentation 2024-11-29 10:16:46 +01:00
Philipp Krones
d58b911e01 Merge commit 'ff4a26d442' into clippy-subtree-update 2024-11-28 19:38:59 +01:00
Kampfkarren
671183a41f Bless 2024-11-24 23:16:27 -08:00
Yuri Astrakhan
81dceed8ba Support user format-like macros
Add support for `#[clippy::format_args]` attribute that can be attached to any macro to indicate that it functions the same as the built-in format macros like `format!`, `println!` and `write!`
2024-11-15 15:26:48 -05:00
Philipp Krones
5c1811ab94
Rename all clippy_config::msrvs -> clippy_utils::msrvs 2024-11-15 19:38:09 +01:00
Philipp Krones
6ced8c33c0 Merge commit 'f712eb5cdc' into clippy-subtree-update 2024-11-07 22:37:01 +01:00
Philipp Krones
3518178443
Merge pull request #13639 from flip1995/rustup
Rustup
2024-11-07 18:02:25 +00:00
Philipp Krones
b1166963aa
Remove CI badge from README and book 2024-11-07 18:57:29 +01:00
Philipp Krones
a28c44fc96
Merge pull request #13587 from Kobzol/ci-remove-bors
Switch CI from bors to merge queue
2024-11-07 17:42:31 +00:00
bors
5c6fe68c00 Auto merge of #13376 - decryphe:source-ordering, r=llogiq
new lint: `source_item_ordering`

changelog: [`source_item_ordering`]: Introduced a new restriction lint that checks the ordering of items in Modules, Enums, Structs, Impls and Traits.

From the written documentation:

> Why restrict this?
> Keeping a consistent ordering throughout the codebase helps with working as a team, and possibly improves maintainability of the codebase. The idea is that by defining a consistent and enforceable rule for how source files are structured, less time will be wasted during reviews on a topic that is (under most circumstances) not relevant to the logic implemented in the code. Sometimes this will be referred to as "bike-shedding".
>
> Keep in mind, that ordering source code alphabetically can lead to reduced performance in cases where the most commonly used enum variant isn't the first entry anymore, and similar optimizations that can reduce branch misses, cache locality and such. Either don't use this lint if that's relevant, or disable the lint in modules or items specifically where it matters. Other solutions can be to use profile guided optimization (PGO), or other advanced optimization methods.

I tried to build it as configurable as possible, as such a highly opinionated lint should be adjustable to personal opinions.

I'm open to any input and will be available both here and on the zulip for communication. In the meantime I'll be testing this lint against my own code-bases, which I've (manually) kept ordered with the default config, to see how well it works in practice.

And lastly, a big thanks to the community for making clippy the best linter there is!
2024-11-02 11:03:30 +00:00