Commit graph

352 commits

Author SHA1 Message Date
Samuel Tardieu
331a474142
Add new duration_suboptimal_units lint (#16250)
`Duration::from_mins` and `Duration::from_hours` where [recently
stabilized](https://github.com/rust-lang/rust/issues/140881) in Rust
1.91.0.

In our codebase we often times have things like

```rust
Duration::from_secs(5 * 60);
// Since Rust 1.91.0 one can use
Duration::from_mins(5)
```

During the Rust 1.91.0 bump I noticed we can finally switch to
`Duration::from_mins(5)`, but many users might not be aware of this. I
started manually updating the places, but halfway through I figured
"Can't a lint do this for me?", so I added exactly that in this PR. It
does it for all stabilized `from_XXX` time units.

changelog: Add new [`duration_suboptimal_units`] lint
Closes rust-lang/rust-clippy#16335
2026-01-09 16:08:40 +00:00
Sebastian Bernauer
0946c867a8
Add new duration_suboptimal_units lint 2026-01-09 16:40:04 +01:00
Philipp Krones
28d62f0833
Don't take rustc-literal-escaper from sysroot
This resulted in the following error for me:

    error[E0464]: multiple candidates for `rlib` dependency `rustc_literal_escaper` found
      --> clippy_dev/src/lib.rs:25:1
       |
    25 | extern crate rustc_literal_escaper;
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: candidate #1: /home/pkrones/.rustup/toolchains/nightly-2025-12-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_literal_escaper-4f30574e01c3dad1.rlib
       = note: candidate #2: /home/pkrones/.rustup/toolchains/nightly-2025-12-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_literal_escaper-c8a0e29ad1040cee.rmeta

Other tools in the Rust repo also take that as an explicit dependency, like rust-analyzer or lint-docs.
2025-12-25 20:51:01 +01:00
Philipp Krones
44731205b8 Merge commit '62589a21d3' into clippy-subtree-update 2025-11-16 15:19:59 +01:00
Jason Newcomb
2027c0e02b Update dev new_lint to add passes to each array. 2025-11-14 07:50:55 -05:00
Philipp Krones
c71f7b63f8 Merge commit 'c936595d17' into clippy-subtree-update 2025-10-31 19:15:42 +01:00
Jason Newcomb
bae625fed0 clippy_dev: Allocate onto an arena when parsing. 2025-10-22 19:09:23 -04:00
Jason Newcomb
7579e71c1f clippy_dev: Inline and simplify read_src_with_module. 2025-10-22 19:09:23 -04:00
Jason Newcomb
fcfab5fe4b clippy_dev: Move all parsing within a parse context. 2025-10-22 19:09:23 -04:00
Philipp Krones
8f61305722 Merge commit 'd9fb15c4b1' into clippy-subtree-update 2025-10-16 20:38:28 +02:00
Jason Newcomb
1b31b09c89 clippy_dev: Add specialized helpers for finding identifiers to the token cursor. 2025-10-11 17:58:26 -04:00
Jason Newcomb
422d459308 clippy_dev: Capture token patterns by position and length. 2025-10-11 17:53:19 -04:00
Jason Newcomb
5e36990de0 clippy_dev: Use the new ranges. 2025-10-11 17:53:19 -04:00
Jason Newcomb
88c0674bc8 clippy_dev: Rename RustSearcher to Cursor and move it to its own module. 2025-10-11 17:53:19 -04:00
Jason Newcomb
4f403f39b5 clippy_dev: Validate lint name format during argument parsing. 2025-10-11 11:30:33 -04:00
Jason Newcomb
813eb082f3 clippy_dev: Move parsing code to it's own module. 2025-10-10 23:57:05 -04:00
Nick Drozd
5318883d75 Use expect for lint warnings 2025-10-06 20:17:12 -04:00
Philipp Krones
71b79ab466 Merge commit '877967959a' into clippy-subtree-update 2025-08-22 14:57:22 +02:00
Jason Newcomb
fc42a205e9
Misc clippy_dev changes (#14896)
changelog: none
2025-08-17 11:26:46 +00:00
Philipp Krones
5c7418b38a Merge commit '1db89a1b1c' into clippy-subtree-update 2025-07-25 15:54:22 +02:00
Philipp Krones
c98e60a56e
Merge remote-tracking branch 'upstream/master' into rustup 2025-07-25 15:04:01 +02:00
Jason Newcomb
913681464e Make utils module private. 2025-07-11 01:05:40 -04:00
Jason Newcomb
e624b77592 Inline cargo_clippy_path and add a note about removing it when possible 2025-07-11 01:05:40 -04:00
Jason Newcomb
ed1088eec4 Use track_caller more for better error spans in clippy_dev 2025-07-11 00:59:19 -04:00
Jason Newcomb
46ff0a8565 Add helper function for creating cargo commands. 2025-07-11 00:59:19 -04:00
Jason Newcomb
ed50c8a0e9 Make dev serve actually detect all updates 2025-07-11 00:57:50 -04:00
Jason Newcomb
fc8bf97095 Rename exit_if_err to run_exit_on_err 2025-07-11 00:57:50 -04:00
Philipp Krones
4e614bf683 Merge commit 'cdbbf3afda' into clippy-subtree-update 2025-07-10 20:25:36 +02:00
Philipp Krones
9e0f749e08
Merge remote-tracking branch 'upstream/master' into rustup 2025-07-10 20:01:08 +02:00
Jason Newcomb
6030997800 Remove verify_inside_clippy_dir since we always set the current directory. 2025-07-09 11:09:29 -04:00
Samuel Tardieu
fc3d5e6827
Remove unneeded .as_bytes()
`&str` already implements `AsRef<[u8]>`
2025-07-02 00:25:37 +02:00
Philipp Krones
074ccaf3c0 Merge commit 'c5dbd1de07' into clippy-subtree-update 2025-06-27 12:20:57 +02:00
Philipp Krones
90364dd178
Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
Marijn Schouten
05b74d558f update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
Samuel Tardieu
7c828e63ba
or_fun_call: lint more methods (#15071)
Extend `or_fun_call` lint with new checks for Option::get_or_insert,
Result::map_or.

changelog: [`or_fun_call`]: lint more methods
2025-06-21 09:21:42 +00:00
Jason Newcomb
acd8810e77 Prepare to split lints into multiple crates
* Move `declare_clippy_lint` to it's own crate
* Move lint/group registration into the driver
* Make `dev update_lints` handle multiple lint crates
2025-06-18 22:37:23 -04:00
klensy
9ed1843653 dogfood clippy::or_fun_call 2025-06-17 15:42:54 +03:00
Philipp Krones
cbd683fe31 Merge commit '4ef75291b5' into clippy-subtree-update 2025-06-13 11:24:45 +02:00
krikera
89dc07acb5 chore: fix smart quote in comment used by update_lints script 2025-06-01 19:20:33 +05:30
Philipp Krones
9f86a576e3 Merge commit '57cbadd68a' 2025-05-31 14:22:15 +02:00
Samuel Tardieu
3da4c1033a
Improve speed of cargo dev fmt (#14862)
This stops using `cargo fmt` and instead calls rustfmt directly with the
list of all files.

All `cargo fmt` does is find the crate roots and passes the edition from
`cargo.toml`. Since the edition is set in `rustfmt.toml` for the test
files and we're already iterating through all the files this is not
needed.

`--skip-children` is used since we already pass all the files, so the
automatic detection isn't buying us anything other than running slower.

~Second commit~ (part of the first commit now) is a change to only use
the `ignore` option in `rustfmt.toml` rather than having a way in `cargo
dev fmt` to ignore files.

r? @samueltardieu

changelog: none
2025-05-21 20:31:46 +00:00
Jason Newcomb
106ac79ecb Add expect_action helper to clippy_dev 2025-05-21 15:09:35 -04:00
Jason Newcomb
544c300fb6 Improve speed of cargo dev fmt. 2025-05-21 15:09:35 -04:00
Philipp Krones
7debaf6b44 Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
Philipp Krones
8a28b797b8
Bump nightly version -> 2025-05-21 2025-05-21 14:50:25 +02:00
Samuel Tardieu
82bf659dc8
Ensure that symbols list stays sorted 2025-05-19 22:47:57 +02:00
Samuel Tardieu
608f6822ca
cargo dev fmt: format clippy_lints_internal as well 2025-05-19 18:10:59 +02:00
Jason Newcomb
232be55859 clippy_dev: refactor rustfmt calls 2025-05-17 06:11:19 -04:00
Jason Newcomb
9d47e0c8ce clippy_dev: remove the need for markers when bumping the version 2025-05-17 04:27:39 -04:00
Jason Newcomb
13b070e356 clippy_dev: Fix previous renames in rename_lint 2025-05-16 06:43:55 -04:00