Commit graph

328 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Ruairidh Williamson
05ebce8e1a
Add lint unused_trait_names 2024-09-21 00:56:38 +01:00
Alex Macleod
a22ce2d005 Remove HashSets from Conf 2024-08-12 20:24:47 +00:00
Alex Macleod
182cd5f278 Replace the metadata collector with tests 2024-08-12 20:24:46 +00:00
Jason Newcomb
7422202ca5 Add missing default values 2024-07-27 23:34:16 -04:00
Jason Newcomb
84dc56923b Add docs for await_holding_invalid_types 2024-07-27 18:17:26 -04:00
xFrednet
e34db99b2e
Update version attribute for 1.80 lints 2024-07-18 20:13:39 +02:00
Jason Newcomb
e34c6dbae5 Refactor for using config values:
* Construct lint passes by taking `Conf` by reference.
* Use `HashSet` configs in less places
* Move some `check_crate` code into the pass constructor when possible.
2024-07-17 14:05:49 -04:00
Bruce Mitchener
39378cf4f4 Add more doc-valid-idents
* "AccessKit" is a commonly used accessibility toolkit used in Rust GUIs.
* "CoreFoundation", "CoreGraphics", "CoreText" are frameworks on Apple OSes.
* "Direct2D", "Direct3D", "DirectWrite" are frameworks on Windows
* "PostScript" is a programming language and is mentioned when talking about
  text and vector graphics.
* "OpenAL" is an audio framework / API.
* "OpenType" is a font format (TrueType is already mentioned).
* "WebRTC", "WebSocket", "WebTransport" are web networking technologies.
* "NetBSD" and "OpenBSD" are like the already included FreeBSD.
2024-07-13 15:50:29 +07:00
Philipp Krones
ae47b97655
needless-pass-by-ref-mut: Update conf documentation 2024-07-03 09:53:05 +02:00
Kornel
eb33c1ac74
Image-related valid idents 2024-06-29 12:18:09 +01:00
Philipp Krones
e9e7a815a7
Merge remote-tracking branch 'upstream/master' into rustup 2024-06-27 18:49:59 +02:00
Reilly Tucker Siemens
80b25b4c82
Fix doc_markdown DevOps false positive 2024-06-26 15:22:38 -07:00
xFrednet
1b4c281fe7 RFC 2383: Stabilize lint_reasons in Clippy 🖇️ 2024-06-25 17:50:48 +02:00