Commit graph

371 commits

Author SHA1 Message Date
Alejandra González
649cef0e81
rename MANUAL_DIV_CEIL MSRV alias and add missing conf info for manual_div_ceil (#14263)
- The name of an MSRV alias should describe its functionality, and it is
not appropriate for it to be the same as the name of the lint that uses
it.
- Additionally, while `manual_div_ceil` allows setting MSRV, this is not
correctly reflected in the configuration information.

changelog: none
2025-02-21 18:02:30 +00:00
lapla-cogito
55f32d9259
add missing MSRV configuration information for manual_div_ceil 2025-02-20 23:27:15 +09:00
Andre Bogus
83f5cbad18 add owned_cow lint 2025-02-19 23:12:46 +01:00
lapla-cogito
939429a8b9
update rustfix link 2025-02-19 05:50:45 +09:00
Philipp Krones
8ae4750155
fix broken link of UI test in the book (#14077)
r? flip1995

changelog: none
2025-02-13 09:47:06 +00:00
llogiq
4129f5c824
New lint: mem_replace_option_with_some (#14197)
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.

Close #14195

changelog: [`mem_replace_option_with_some`]: new lint
2025-02-12 19:02:06 +00:00
Samuel Tardieu
342ac8ee28 New lint: mem_replace_option_with_some
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
2025-02-12 19:57:14 +01:00
Samuel Tardieu
da6a05977d {expect,unwrap}_used: add options to lint at compilation time
By default, do not lint `.unwrap()` and `.expect(…)` in always const
contexts, as a failure would be detected at compile time anyway.

New options `allow_expect_in_consts` and `allow_unwrap_in_consts`,
defaulting to `true`, can be turned unset to still lint in always const
contexts.
2025-02-11 22:14:52 +01:00
lapla-cogito
749eb371bf
correct "Affected lints" for allow-one-hash-in-raw-strings 2025-02-10 20:20:27 +09:00
dswij
5211148dbd
add MSRV check for manual_flatten (#14086)
`manual_flatten` should respect MSRV.

changelog: [`manual_flatten`]: add MSRV check
2025-02-08 04:17:43 +00:00
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
665e78f20f
add MSRV check for manual_flatten 2025-01-27 23:17:05 +09: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
lapla-cogito
40c2c641c2
fix broken link of UI test in the book 2025-01-26 15:59:44 +09: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