Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
1566879
clean-up
ada4a Oct 13, 2025
4d79522
fix: use `snippet_with_context` for spans that are likely to contain …
ada4a Oct 13, 2025
b270954
s/snippet/snippet_with_applicability while we're at it
ada4a Oct 13, 2025
d160cb7
`double_comparison`: add missing cases
ianbollinger Nov 4, 2025
f2283e2
fix: `map_unwrap_or` fail to cover `Result::unwrap_or`
profetia Sep 19, 2025
9565b28
fix: `map_unwrap_or` FN on references
profetia Sep 23, 2025
bd03414
Post `needless_continue` diagnostic on the right node
samueltardieu Dec 19, 2025
9bfc9a4
fix: `main_recursion` enable lint in no_std crates and fix broken tests
WaterWhisperer Dec 18, 2025
aede29f
Enhance `needless_collect` to cover vec `push`
profetia Dec 28, 2025
6417c8f
Extend `needless_collect` to also cover `extend`
profetia Dec 28, 2025
0127720
Extend `needless_collect` to cover `push_front`
profetia Jan 2, 2026
ce012da
accept test changes related to binary ops
andjsrk Jan 6, 2026
6b11237
Add span field for ConstArg
mu001999 Jan 6, 2026
d37d04a
recognize safety comments inside blocks and on same line in macros
borngraced Jan 4, 2026
0db25db
fix: `map_unwrap_or` suggests wrongly for empty slice
profetia Sep 24, 2025
4976fdf
fix: `significant_drop_tightening` suggests wrongly for non-method usage
profetia Jan 7, 2026
53267d7
Rollup merge of #150675 - mgca/tuple-expr, r=BoxyUwU
matthiaskrgr Jan 8, 2026
72f1ac9
Compile-Time Reflection MVP: tuples
oli-obk Mar 12, 2025
21f6afc
Update `literal-escaper` version to `0.0.7`
GuillaumeGomez Jan 8, 2026
fb5c850
MGCA: literals support
Human9000-bit Jan 5, 2026
331f75f
Do not warn on arithmetic side effect for `String`+`String`
samueltardieu Jan 8, 2026
a4f0937
clean-up
ada4a Jan 7, 2026
0cfc4ee
fix: respect applicability reduction due to `Sugg`
ada4a Jan 7, 2026
bdb1050
fix: don't lint if `std` or `core` are required for a suggestion but …
ada4a Jan 7, 2026
55b0788
Rollup merge of #150809 - update-literal-escaper, r=Urgau
matthiaskrgr Jan 8, 2026
d0d7251
clean-up
ada4a Jan 8, 2026
cb9a079
fix(float_point_arithmetic): respect reduced applicability
ada4a Jan 8, 2026
7a377d6
move `floating_point_arithmetic.rs` to `floating_point_arithmetic/mod…
ada4a Jan 8, 2026
44a4104
extract each check into a separate module
ada4a Jan 8, 2026
7d0b1e1
`transmuting_null`: Add checks for `without_provenance` and `without_…
Coca162 Jan 2, 2026
6a9dae4
Merge commit '500e0ff18726cd44b23004a02fc1b99f52c11ab1' into clippy-s…
flip1995 Jan 9, 2026
7c3cc4f
Make Clippy compile with `ConstArgKind::Tup()`
samueltardieu Jan 8, 2026
b4dea7c
`transmuting_null`: Add checks for `without_provenance` and `without_…
samueltardieu Jan 9, 2026
697e9e2
Further Clippy fixes for Tup/Literal ConstArgKind
flip1995 Jan 9, 2026
c5d0c45
Rollup merge of #150385 - fix-expr-can-have-side-effects, r=jdonszelm…
GuillaumeGomez Jan 9, 2026
ea21831
Do not warn on arithmetic side effect for `String`+`String` (#16358)
Jarcho Jan 9, 2026
92608aa
fix(float_point_arithmetic): respect reduced applicability (#16366)
Jarcho Jan 9, 2026
0a83962
chore(unnecessary_sort_by): small fixes and clean-up (#16350)
Jarcho Jan 9, 2026
b022edc
add test for unstacking cognitive_complexity= attribute
wonkodv Jan 9, 2026
13b82eb
Fix LimitStack::pop_attrs in release mode
wonkodv Jan 9, 2026
0946c86
Add new `duration_suboptimal_units` lint
sbernauer Dec 17, 2025
331a474
Add new `duration_suboptimal_units` lint (#16250)
samueltardieu Jan 9, 2026
f73e504
fix(useless_conversion): respect reduced applicability
ada4a Jan 9, 2026
11fe0c6
Fix `LimitStack::pop_atr` in release builds (#16371)
llogiq Jan 9, 2026
3ec7666
clean-up
ada4a Jan 9, 2026
0180ec4
fix: negative literals are not literals
ada4a Jan 9, 2026
df65d1a
introduce `LeOrGe`
ada4a Jan 9, 2026
d554092
get rid of `Side`
ada4a Jan 9, 2026
ccaa2fa
fix: respect reduced applicability
ada4a Jan 9, 2026
43077ee
Auto merge of #150818 - flip1995:clippy-subtree-update, r=Manishearth…
rust-bors[bot] Jan 9, 2026
ea591b5
fix `clippy_utils::std_or_core(_)`
llogiq Jan 9, 2026
b94106a
fix `clippy_utils::std_or_core(_)` (#16374)
samueltardieu Jan 9, 2026
f4a6e4f
Fix clippy
reddevilmidzy Jan 8, 2026
c87bb01
Changelog for Clippy 1.93
alex-semenyuk Jan 10, 2026
5ebb322
fix(useless_conversion): respect reduced applicability (#16372)
samueltardieu Jan 10, 2026
5366824
refactor(floating_point_arithmetic): split each check into a separate…
samueltardieu Jan 10, 2026
9eb4d7c
remove `no-rustfix`
ada4a Jan 10, 2026
f228056
improve lint messages
ada4a Jan 10, 2026
4f2b878
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
rust-bors[bot] Jan 10, 2026
8bd0931
refactor(suspicious_to_owned): improve lint messages (#16376)
llogiq Jan 10, 2026
e4dd947
introduce `Self::as_x_{plus,minus}_one`
ada4a Jan 10, 2026
306254b
improve the doc of `doc_paragraphs_missing_punctuation`
relaxcn Jan 10, 2026
bcd52c1
overhaul `int_plus_one` (#16373)
llogiq Jan 11, 2026
669fbcb
Fix `map_unwrap_or` fail to cover `Result::unwrap_or` (#15718)
samueltardieu Jan 11, 2026
47b987e
Do not show spans from external crates in `missing_trait_methods`
samueltardieu Jan 11, 2026
88ab1a3
Do not show spans from external crates in `missing_trait_methods` (#1…
llogiq Jan 11, 2026
6f5048d
Fix `significant_drop_tightening` suggests wrongly for non-method usa…
llogiq Jan 11, 2026
a47cbd0
Fix `undocumented_unsafe_block` recognize safety comments inside bloc…
llogiq Jan 11, 2026
1437ea0
improve the doc of `doc_paragraphs_missing_punctuation` (#16377)
dswij Jan 11, 2026
8a71deb
add `manual_take` lint
llogiq Jan 8, 2026
637108e
Enhance `needless_collect` to cover vec `push`-alike (#16305)
llogiq Jan 11, 2026
d419bdd
clippy: remove `ty_has_erased_regions`.
nnethercote Jan 8, 2026
756e1ba
`clippy_dev`: Move lint uplifting into its own command.
Jarcho Oct 12, 2025
d9fa6d9
`clippy_dev`: Rename `deprecate_lint` module to `edit_lints`.
Jarcho Oct 12, 2025
8d4e435
`clippy_dev`: Move `rename_lint` command to `edit_lints` module.
Jarcho Oct 12, 2025
31db6aa
`clippy_dev`: When renaming a lint better handle the case where the r…
Jarcho Oct 13, 2025
5e8d1b5
`clippy_dev`: Re-enable deleting the module declaration on deprecatio…
Jarcho Oct 13, 2025
2e556c4
fix(unnecessary_map_or): respect reduced applicability
ada4a Jan 10, 2026
0a5825e
fix(unnecessary_map_or): respect reduced applicability (#16387)
samueltardieu Jan 12, 2026
6fa61df
Do not ignore statements before a `break` when simplifying loop
samueltardieu Jan 11, 2026
2b50456
clean-up `unnecessary_map_or` and `manual_is_variant_and`
ada4a Nov 23, 2025
2a3eb6f
Do not ignore statements before a `break` when simplifying loop (#16379)
Jarcho Jan 12, 2026
d20c5de
Auto merge of #150786 - reddevilmidzy:mgca-array, r=BoxyUwU
bors Jan 12, 2026
5ef494c
clean-up `unnecessary_map_or` and `manual_is_variant_and` (#16386)
Jarcho Jan 12, 2026
3badf70
Mention an extra argument required to check tests
AMDmi3 Dec 8, 2025
d9d034c
Mention an extra argument needed to check tests (#16205)
samueltardieu Jan 12, 2026
5e73d9d
Auto merge of #151003 - matthiaskrgr:rollup-wvnF9sN, r=matthiaskrgr
bors Jan 12, 2026
815407a
clean-up
ada4a Jan 12, 2026
7cdfee9
feat: specify the type
ada4a Jan 12, 2026
49c8614
feat: also lint types that dereference to `CStr`
ada4a Jan 12, 2026
c267b59
feat(strlen_on_c_strings): mention the specific type (`CString` or `C…
samueltardieu Jan 12, 2026
6c4cdfa
Replace complex `matches!(…, … if …)` by `if let` chain
samueltardieu Jan 13, 2026
e256d3e
Replace complex `matches!(…, … if …)` by `if let` chain (#16397)
dswij Jan 14, 2026
d7e5996
Skip elidable_lifetime_names lint for proc-macro generated code
HueCodes Jan 15, 2026
60b3ecf
add `manual_take` lint (#16368)
samueltardieu Jan 15, 2026
676d71a
Defer is_from_proc_macro check and add tests
HueCodes Jan 16, 2026
19e0d79
Mention `cast_signed` in docs of `cast_possible_wrap`
DJMcNab Jan 16, 2026
a66ad93
Mention `cast_signed` in docs of `cast_possible_wrap` (#16407)
samueltardieu Jan 16, 2026
2f3b9ce
feat(strlen_on_c_strings): suggest .count_bytes()
Tigls Jan 13, 2026
5320bdb
Suggest `Cstr::count_bytes` in `strlen_on_c_strings` (#16323)
samueltardieu Jan 16, 2026
73d05dd
Post `needless_continue` diagnostic on the right node (#16265)
dswij Jan 16, 2026
4cb70c8
fix: `unnecessary_sort_by` FN on field access
profetia Jan 16, 2026
03fd408
Apply `unnecessary_sort_by` to Clippy itself
profetia Jan 16, 2026
b7e4315
Do not output an error if standard output is full on --help/--version
samueltardieu Jan 15, 2026
c9bbf95
Allow `unnecessary_sort_by` to lint closures with input patterns
profetia Jan 16, 2026
5937b8b
Apply `unnecessary_sort_by` to Clippy itself
profetia Jan 16, 2026
6802a56
Do not output an error if standard output is full on --help/--version…
llogiq Jan 16, 2026
69e70c8
Fix `unnecessary_sort_by` FN on field access (#16406)
llogiq Jan 16, 2026
196c098
`unnecessary_sort_by`: reduce suggestion diffs
ada4a Jan 16, 2026
bcde8c1
Do not consider binary operators as commutative by default
samueltardieu Jan 16, 2026
dd61de9
Remove empty stderr file from tests
samueltardieu Jan 16, 2026
696f616
Remove known problems from `comparison_chain`
xtqqczze Jan 16, 2026
59b58ec
Remove known problems from `comparison_chain` (#16422)
llogiq Jan 17, 2026
3404c3b
Remove empty stderr file from tests (#16421)
llogiq Jan 17, 2026
29e2b8d
`double_comparisons`: check for expressions such as `x != y && x >= y…
llogiq Jan 17, 2026
4ab5ad4
`clippy_dev`: Parsing revamp part 3/N (#15947)
llogiq Jan 17, 2026
d25a26d
Skip elidable_lifetime_names lint for proc-macro generated code (#16402)
samueltardieu Jan 17, 2026
a5ae164
Fix `main_recursion` tests (#16259)
samueltardieu Jan 18, 2026
fe4bc31
fix(collapsible_span_lint_calls): use `snippet_with_context` for span…
llogiq Jan 18, 2026
c591bc1
Remove all allows for `diagnostic_outside_of_impl` and `untranslatabl…
JonathanBrouwer Jan 9, 2026
bbfe34e
`unnecessary_sort_by`: reduce suggestion diffs (#16417)
Jarcho Jan 19, 2026
4b98bd3
Do not consider binary operators as commutative by default (#16420)
dswij Jan 20, 2026
7533a9a
Add manual checked ops lint
amerikrainian Nov 28, 2025
f2b567f
Add manual_checked_ops lint (#16149)
samueltardieu Jan 20, 2026
e5055d4
Changelog for Clippy 1.93❄️ (#16413)
flip1995 Jan 22, 2026
94fe3dd
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 22, 2026
21e84b5
Bump nightly version -> 2026-01-22
flip1995 Jan 22, 2026
0f9b027
Bump Clippy version -> 0.1.95
flip1995 Jan 22, 2026
5448229
Rustup (#16438)
flip1995 Jan 22, 2026
0e8e621
Merge commit '54482290b5f32e6c6b57cc9e0a17153f432b0036' into clippy-s…
flip1995 Jan 22, 2026
e2d6de7
Update Cargo.lock
flip1995 Jan 22, 2026
2a62479
bootstrap: fix Clippy warning
flip1995 Jan 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"

[[package]]
name = "clippy"
version = "0.1.94"
version = "0.1.95"
dependencies = [
"anstream",
"askama",
Expand All @@ -657,7 +657,7 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.94"
version = "0.1.95"
dependencies = [
"clippy_utils",
"itertools",
Expand All @@ -681,7 +681,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.94"
version = "0.1.95"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.1",
Expand Down Expand Up @@ -713,7 +713,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.94"
version = "0.1.95"
dependencies = [
"arrayvec",
"itertools",
Expand Down Expand Up @@ -1117,7 +1117,7 @@ dependencies = [

[[package]]
name = "declare_clippy_lint"
version = "0.1.94"
version = "0.1.95"

[[package]]
name = "derive-where"
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl CommandProfiler {
})
.collect();

entries.sort_by(|a, b| b.2.cmp(&a.2));
entries.sort_by_key(|e| std::cmp::Reverse(e.2));

let total_bootstrap_duration = start_time.elapsed();

Expand Down
64 changes: 63 additions & 1 deletion src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,66 @@ document.

## Unreleased / Beta / In Rust Nightly

[d9fb15c...master](https://github.com/rust-lang/rust-clippy/compare/d9fb15c...master)
[92b4b68...master](https://github.com/rust-lang/rust-clippy/compare/92b4b68...master)

## Rust 1.93

Current stable, released 2026-01-22

[View all 96 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2025-10-17T15%3A48%3A11Z..2025-11-28T19%3A22%3A54Z+base%3Amaster)

### New Lints

* Added [`doc_paragraphs_missing_punctuation`] to `restriction`
[#15758](https://github.com/rust-lang/rust-clippy/pull/15758)

### Moves and Deprecations

* Renamed [`needless_if`] to [`needless_ifs`]
[#15961](https://github.com/rust-lang/rust-clippy/pull/15961)
* Renamed [`empty_enum`] to [`empty_enums`]
[#15912](https://github.com/rust-lang/rust-clippy/pull/15912)

### Enhancements

* [`result_large_err`] added `large_error_ignored` configuration
[#15697](https://github.com/rust-lang/rust-clippy/pull/15697)
* [`explicit_deref_methods`] don't lint in `impl Deref(Mut)`
[#16113](https://github.com/rust-lang/rust-clippy/pull/16113)
* [`missing_docs_in_private_items`] don't lint items in bodies and automatically derived impls;
better detect when things are accessible from the crate root; lint unnameable items which are
accessible outside the crate
[#14741](https://github.com/rust-lang/rust-clippy/pull/14741)
* [`unnecessary_unwrap`] and [`panicking_unwrap`] lint field accesses
[#15949](https://github.com/rust-lang/rust-clippy/pull/15949)
* [`ok_expect`] add autofix
[#15867](https://github.com/rust-lang/rust-clippy/pull/15867)
* [`let_and_return`] disallow _any_ text between let and return
[#16006](https://github.com/rust-lang/rust-clippy/pull/16006)
* [`needless_collect`] extend to lint more cases
[#14361](https://github.com/rust-lang/rust-clippy/pull/14361)
* [`needless_doctest_main`] and [`test_attr_in_doctest`] now handle whitespace in language tags
[#15967](https://github.com/rust-lang/rust-clippy/pull/15967)
* [`search_is_some`] now fixes code spanning multiple lines
[#15902](https://github.com/rust-lang/rust-clippy/pull/15902)
* [`unnecessary_find_map`] and [`unnecessary_filter_map`] make diagnostic spans more precise
[#15929](https://github.com/rust-lang/rust-clippy/pull/15929)
* [`precedence`] warn about ambiguity when a closure is used as a method call receiver
[#14421](https://github.com/rust-lang/rust-clippy/pull/14421)
* [`match_as_ref`] suggest `as_ref` when the reference needs to be cast; improve diagnostics
[#15934](https://github.com/rust-lang/rust-clippy/pull/15934)
[#15928](https://github.com/rust-lang/rust-clippy/pull/15928)

### False Positive Fixes

* [`single_range_in_vec_init`] fix FP for explicit `Range`
[#16043](https://github.com/rust-lang/rust-clippy/pull/16043)
* [`mod_module_files`] fix false positive for integration tests in workspace crates
[#16048](https://github.com/rust-lang/rust-clippy/pull/16048)
* [`replace_box`] fix FP when the box is moved
[#15984](https://github.com/rust-lang/rust-clippy/pull/15984)
* [`len_zero`] fix FP on unstable methods
[#15894](https://github.com/rust-lang/rust-clippy/pull/15894)

## Rust 1.92

Expand Down Expand Up @@ -6406,6 +6465,7 @@ Released 2018-09-13
[`duplicate_mod`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_mod
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
[`duplicated_attributes`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicated_attributes
[`duration_suboptimal_units`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_suboptimal_units
[`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec
[`eager_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#eager_transmute
[`elidable_lifetime_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names
Expand Down Expand Up @@ -6607,6 +6667,7 @@ Released 2018-09-13
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
[`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits
[`manual_c_str_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals
[`manual_checked_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_checked_ops
[`manual_clamp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
[`manual_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
[`manual_dangling_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_dangling_ptr
Expand Down Expand Up @@ -6652,6 +6713,7 @@ Released 2018-09-13
[`manual_string_new`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_string_new
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
[`manual_take`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_take
[`manual_try_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
[`manual_unwrap_or_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.94"
version = "0.1.95"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
* [`manual_split_once`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once)
* [`manual_str_repeat`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat)
* [`manual_strip`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip)
* [`manual_take`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_take)
* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold)
* [`map_clone`](https://rust-lang.github.io/rust-clippy/master/index.html#map_clone)
* [`map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_config"
version = "0.1.94"
version = "0.1.95"
edition = "2024"
publish = false

Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ define_Conf! {
manual_split_once,
manual_str_repeat,
manual_strip,
manual_take,
manual_try_fold,
map_clone,
map_unwrap_or,
Expand Down
5 changes: 1 addition & 4 deletions src/tools/clippy/clippy_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
unused_lifetimes,
unused_qualifications
)]
#![allow(
clippy::must_use_candidate,
clippy::missing_panics_doc,
)]
#![allow(clippy::must_use_candidate, clippy::missing_panics_doc)]
#![deny(clippy::derive_deserialize_allowing_unknown)]

extern crate rustc_data_structures;
Expand Down
54 changes: 53 additions & 1 deletion src/tools/clippy/clippy_dev/src/deprecate_lint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::parse::{DeprecatedLint, Lint, ParseCx};
use crate::parse::{DeprecatedLint, Lint, ParseCx, RenamedLint};
use crate::update_lints::generate_lint_files;
use crate::utils::{UpdateMode, Version};
use std::ffi::OsStr;
Expand Down Expand Up @@ -61,6 +61,58 @@ pub fn deprecate<'cx>(cx: ParseCx<'cx>, clippy_version: Version, name: &'cx str,
}
}

pub fn uplift<'cx, 'env: 'cx>(cx: ParseCx<'cx>, clippy_version: Version, old_name: &'env str, new_name: &'env str) {
let mut lints = cx.find_lint_decls();
let (deprecated_lints, mut renamed_lints) = cx.read_deprecated_lints();

let Some(lint) = lints.iter().find(|l| l.name == old_name) else {
eprintln!("error: failed to find lint `{old_name}`");
return;
};

let old_name_prefixed = cx.str_buf.with(|buf| {
buf.extend(["clippy::", old_name]);
cx.arena.alloc_str(buf)
});
for lint in &mut renamed_lints {
if lint.new_name == old_name_prefixed {
lint.new_name = new_name;
}
}
match renamed_lints.binary_search_by(|x| x.old_name.cmp(old_name_prefixed)) {
Ok(_) => {
println!("`{old_name}` is already deprecated");
return;
},
Err(idx) => renamed_lints.insert(
idx,
RenamedLint {
old_name: old_name_prefixed,
new_name,
version: cx.str_buf.alloc_display(cx.arena, clippy_version.rust_display()),
},
),
}

let mod_path = {
let mut mod_path = PathBuf::from(format!("clippy_lints/src/{}", lint.module));
if mod_path.is_dir() {
mod_path = mod_path.join("mod");
}

mod_path.set_extension("rs");
mod_path
};

if remove_lint_declaration(old_name, &mod_path, &mut lints).unwrap_or(false) {
generate_lint_files(UpdateMode::Change, &lints, &deprecated_lints, &renamed_lints);
println!("info: `{old_name}` has successfully been uplifted");
println!("note: you must run `cargo uitest` to update the test results");
} else {
eprintln!("error: lint not found");
}
}

fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint<'_>>) -> io::Result<bool> {
fn remove_lint(name: &str, lints: &mut Vec<Lint<'_>>) {
lints.iter().position(|l| l.name == name).map(|pos| lints.remove(pos));
Expand Down
Loading
Loading