Skip to content

Commit d423703

Browse files
committed
Auto merge of #10443 - dtolnay-contrib:formerids, r=llogiq
Include former name of renamed lints in lints.json I am interested in having a programmatic way to process [`RENAMED_LINTS`](https://github.com/rust-lang/rust-clippy/blob/113c704d225c63c1a0eec29cfa9478b7537e7d73/clippy_lints/src/renamed_lints.rs#L4) for dtolnay/noisy-clippy#15. <details> <summary>lints.json diff</summary> ```diff 60c60,63 < } --- > }, > "former_ids": [ > "almost_complete_letter_range" > ] 300c303,306 < } --- > }, > "former_ids": [ > "option_and_then_some" > ] 330c336,340 < } --- > }, > "former_ids": [ > "block_in_if_condition_expr", > "block_in_if_condition_stmt" > ] 450c460,463 < } --- > }, > "former_ids": [ > "box_vec" > ] 945c958,961 < } --- > }, > "former_ids": [ > "cyclomatic_complexity" > ] 1335c1351,1354 < } --- > }, > "former_ids": [ > "derive_hash_xor_eq" > ] 1365c1384,1387 < } --- > }, > "former_ids": [ > "disallowed_method" > ] 1380c1402,1405 < } --- > }, > "former_ids": [ > "blacklisted_name" > ] 1410c1435,1438 < } --- > }, > "former_ids": [ > "disallowed_type" > ] 1890c1918,1922 < } --- > }, > "former_ids": [ > "option_expect_used", > "result_expect_used" > ] 3150c3182,3185 < } --- > }, > "former_ids": [ > "zero_width_space" > ] 4185c4220,4225 < } --- > }, > "former_ids": [ > "option_map_unwrap_or", > "option_map_unwrap_or_else", > "result_map_unwrap_or_else" > ] 4290c4330,4333 < } --- > }, > "former_ids": [ > "if_let_some_result" > ] 4710c4753,4756 < } --- > }, > "former_ids": [ > "eval_order_dependence" > ] 4755c4801,4804 < } --- > }, > "former_ids": [ > "stutter" > ] 5055c5104,5107 < } --- > }, > "former_ids": [ > "ref_in_deref" > ] 5400c5452,5455 < } --- > }, > "former_ids": [ > "new_without_default_derive" > ] 5820c5875,5878 < } --- > }, > "former_ids": [ > "logic_bug" > ] 6330c6388,6391 < } --- > }, > "former_ids": [ > "to_string_in_display" > ] 6525c6586,6589 < } --- > }, > "former_ids": [ > "const_static_lifetime" > ] 7065c7129,7132 < } --- > }, > "former_ids": [ > "single_char_push_str" > ] 8820c8887,8891 < } --- > }, > "former_ids": [ > "option_unwrap_used", > "result_unwrap_used" > ] 8925c8996,8999 < } --- > }, > "former_ids": [ > "identity_conversion" > ] ``` </details> changelog: Include `"former_ids": […]` for renamed lints in [lints.json](https://rust-lang.github.io/rust-clippy/master/lints.json)
2 parents 113c704 + cc6180c commit d423703

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clippy_lints/src/utils/internal_lints/metadata_collector.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
2626
use rustc_span::symbol::Ident;
2727
use rustc_span::{sym, Loc, Span, Symbol};
2828
use serde::{ser::SerializeStruct, Serialize, Serializer};
29-
use std::collections::BinaryHeap;
29+
use std::collections::{BTreeSet, BinaryHeap};
3030
use std::fmt;
3131
use std::fmt::Write as _;
3232
use std::fs::{self, OpenOptions};
@@ -264,6 +264,9 @@ struct LintMetadata {
264264
/// This field is only used in the output and will only be
265265
/// mapped shortly before the actual output.
266266
applicability: Option<ApplicabilityInfo>,
267+
/// All the past names of lints which have been renamed.
268+
#[serde(skip_serializing_if = "BTreeSet::is_empty")]
269+
former_ids: BTreeSet<String>,
267270
}
268271

269272
impl LintMetadata {
@@ -283,6 +286,7 @@ impl LintMetadata {
283286
version,
284287
docs,
285288
applicability: None,
289+
former_ids: BTreeSet::new(),
286290
}
287291
}
288292
}
@@ -901,6 +905,7 @@ fn collect_renames(lints: &mut Vec<LintMetadata>) {
901905
if name == lint_name;
902906
if let Some(past_name) = k.strip_prefix(CLIPPY_LINT_GROUP_PREFIX);
903907
then {
908+
lint.former_ids.insert(past_name.to_owned());
904909
writeln!(collected, "* `{past_name}`").unwrap();
905910
names.push(past_name.to_string());
906911
}

0 commit comments

Comments
 (0)