8
8
//! a simple mistake)
9
9
10
10
use crate :: utils:: internal_lints:: { extract_clippy_version_value, is_lint_ref_type} ;
11
+ use crate :: renamed_lints:: RENAMED_LINTS ;
11
12
12
13
use clippy_utils:: diagnostics:: span_lint;
13
14
use clippy_utils:: ty:: { match_type, walk_ptrs_ty_depth} ;
@@ -200,7 +201,10 @@ impl Drop for MetadataCollector {
200
201
let mut lints = std:: mem:: take ( & mut self . lints ) . into_sorted_vec ( ) ;
201
202
lints
202
203
. iter_mut ( )
203
- . for_each ( |x| x. applicability = Some ( applicability_info. remove ( & x. id ) . unwrap_or_default ( ) ) ) ;
204
+ . for_each ( |x| {
205
+ x. applicability = Some ( applicability_info. remove ( & x. id ) . unwrap_or_default ( ) ) ;
206
+ x. past_names = collect_renames ( & x. id ) ;
207
+ } ) ;
204
208
205
209
// Outputting
206
210
if Path :: new ( OUTPUT_FILE ) . exists ( ) {
@@ -222,6 +226,7 @@ struct LintMetadata {
222
226
/// This field is only used in the output and will only be
223
227
/// mapped shortly before the actual output.
224
228
applicability : Option < ApplicabilityInfo > ,
229
+ past_names : Option < Vec < String > > ,
225
230
}
226
231
227
232
impl LintMetadata {
@@ -241,6 +246,7 @@ impl LintMetadata {
241
246
version,
242
247
docs,
243
248
applicability : None ,
249
+ past_names : None ,
244
250
}
245
251
}
246
252
}
@@ -643,6 +649,27 @@ fn is_deprecated_lint(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
643
649
false
644
650
}
645
651
652
+ fn collect_renames ( lint_name : & str ) -> Option < Vec < String > > {
653
+ let collected = RENAMED_LINTS . iter ( ) . filter_map ( |( k, v) | {
654
+ if_chain ! {
655
+ if let Some ( name) = v. strip_prefix( CLIPPY_LINT_GROUP_PREFIX ) ;
656
+ if name == lint_name;
657
+ if let Some ( past_name) = k. strip_prefix( CLIPPY_LINT_GROUP_PREFIX ) ;
658
+ then {
659
+ Some ( past_name. to_string( ) )
660
+ } else {
661
+ None
662
+ }
663
+ }
664
+ } ) . collect :: < Vec < _ > > ( ) ;
665
+
666
+ if collected. is_empty ( ) {
667
+ None
668
+ } else {
669
+ Some ( collected)
670
+ }
671
+ }
672
+
646
673
// ==================================================================
647
674
// Lint emission
648
675
// ==================================================================
0 commit comments