Commit graph

346 commits

Author SHA1 Message Date
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
chrysn
bd4aa170ef Add 'CoAP' to doc-valid-idents 2024-10-30 12:57:24 +01:00
decryphe
f7ab2c9908 new lint: source_item_ordering 2024-10-30 10:03:16 +01:00
Robert Spencer
acc3842d43 Add new map_with_unused_argument_over_ranges lint
This lint checks for code that looks like
```rust
  let something : Vec<_> = (0..100).map(|_| {
    1 + 2 + 3
  }).collect();
```
which is more clear as
```rust
  let something : Vec<_> = std::iter::repeat_with(|| {
    1 + 2 + 3
  }).take(100).collect();
```
or
```rust
  let something : Vec<_> =
      std::iter::repeat_n(1 + 2 + 3, 100)
      .collect();
```

That is, a map over a range which does nothing with the parameter
passed to it is simply a function (or closure) being called `n`
times and could be more semantically expressed using `take`.
2024-10-29 21:32:00 +00:00
Samuel Tardieu
f152bcb72e Update the number of lints (over 700 → over 750) 2024-10-28 09:21:07 +01:00
Jakub Beránek
3338611c1b
Switch CI from bors to merge queue 2024-10-25 10:28:45 +02:00
bors
c2534dcc49 Auto merge of #13460 - ROMemories:feat/freq-units-allowed-idents, r=Centri3
Add units/unit prefixes of frequency to doc-valid-idents

These units/unit prefixes often come up in the embedded world.

Should this PR also modify the `test_units` test? It seems only concerned with data units currently; should it also test frequency units?

changelog: [`doc_markdown`]: Add MHz, GHz, and THz to `doc-valid-idents`.
2024-10-24 08:50:36 +00:00
Philipp Krones
fea5e77da1 Merge commit 'a109190d70' into clippy-subtree-update 2024-10-18 13:44:06 +02:00
GnomedDev
979e297189
Update book 2024-10-13 21:17:03 +01:00
GnomedDev
26994e2519
Reduce default 'large array' threshold 2024-10-04 19:07:40 +01:00
Philipp Krones
277c4e4baf Merge commit 'aa0d551351' into clippy-subtree-update 2024-10-03 16:32:51 +02:00
Yuri Astrakhan
73a16c10db Suggest Option<&T> instead of &Option<T> 2024-09-28 11:57:34 -04:00
ROMemories
62026c3228 Add units/unit prefixes of frequency to doc-valid-idents 2024-09-26 10:07:10 +02:00
Philipp Krones
b61fcbee76 Merge commit '7901289135' into clippy-subtree-update 2024-09-24 11:58:04 +02:00