@@ -69,8 +69,9 @@ pub struct LintStore {
69
69
70
70
/// Map of registered lint groups to what lints they expand to. The first
71
71
/// bool is true if the lint group was added by a plugin. The optional string
72
- /// is used to store the new names of deprecated lint group names.
73
- lint_groups : FxHashMap < & ' static str , ( Vec < LintId > , bool , Option < & ' static str > ) > ,
72
+ /// is used to store the new names of deprecated lint group names and is paired
73
+ /// with `true` if the deprecation is silent.
74
+ lint_groups : FxHashMap < & ' static str , ( Vec < LintId > , bool , Option < ( & ' static str , bool ) > ) > ,
74
75
75
76
/// Extra info for future incompatibility lints, describing the
76
77
/// issue or RFC that caused the incompatibility.
@@ -160,9 +161,9 @@ impl LintStore {
160
161
}
161
162
162
163
pub fn get_lint_groups < ' t > ( & ' t self ) -> Vec < ( & ' static str , Vec < LintId > , bool ) > {
163
- self . lint_groups . iter ( ) . map ( | ( k , v ) | ( * k ,
164
- v . 0 . clone ( ) ,
165
- v. 1 ) ) . collect ( )
164
+ self . lint_groups . iter ( )
165
+ . filter ( | ( _ , ( _ , _ , d ) ) | d . is_none ( ) ) // Don't display deprecated lint groups.
166
+ . map ( | ( k , v ) | ( * k , v . 0 . clone ( ) , v. 1 ) ) . collect ( )
166
167
}
167
168
168
169
pub fn register_early_pass ( & mut self ,
@@ -245,6 +246,14 @@ impl LintStore {
245
246
self . future_incompatible . get ( & id)
246
247
}
247
248
249
+ pub fn register_group_alias (
250
+ & mut self ,
251
+ lint_name : & ' static str ,
252
+ alias : & ' static str ,
253
+ ) {
254
+ self . lint_groups . insert ( alias, ( vec ! [ ] , false , Some ( ( lint_name, true ) ) ) ) ;
255
+ }
256
+
248
257
pub fn register_group (
249
258
& mut self ,
250
259
sess : Option < & Session > ,
@@ -259,7 +268,7 @@ impl LintStore {
259
268
. is_none ( ) ;
260
269
if let Some ( deprecated) = deprecated_name {
261
270
self . lint_groups
262
- . insert ( deprecated, ( vec ! [ ] , from_plugin, Some ( name) ) ) ;
271
+ . insert ( deprecated, ( vec ! [ ] , from_plugin, Some ( ( name, false ) ) ) ) ;
263
272
}
264
273
265
274
if !new {
@@ -392,12 +401,16 @@ impl LintStore {
392
401
None => self . check_tool_name_for_backwards_compat ( & complete_name, "clippy" ) ,
393
402
Some ( ids) => {
394
403
// Check if the lint group name is deprecated
395
- if let Some ( new_name) = ids. 2 {
404
+ if let Some ( ( new_name, silent ) ) = ids. 2 {
396
405
let lint_ids = self . lint_groups . get ( new_name) . unwrap ( ) ;
397
- return CheckLintNameResult :: Tool ( Err ( (
398
- Some ( & lint_ids. 0 ) ,
399
- new_name. to_string ( ) ,
400
- ) ) ) ;
406
+ return if silent {
407
+ CheckLintNameResult :: Ok ( & lint_ids. 0 )
408
+ } else {
409
+ CheckLintNameResult :: Tool ( Err ( (
410
+ Some ( & lint_ids. 0 ) ,
411
+ new_name. to_string ( ) ,
412
+ ) ) )
413
+ } ;
401
414
}
402
415
CheckLintNameResult :: Ok ( & ids. 0 )
403
416
}
@@ -417,13 +430,17 @@ impl LintStore {
417
430
// Now we are sure, that this lint exists nowhere
418
431
None => CheckLintNameResult :: NoLint ,
419
432
Some ( ids) => {
420
- // Reaching this would be weird, but lets cover this case anyway
421
- if let Some ( new_name) = ids. 2 {
433
+ // Reaching this would be weird, but let's cover this case anyway
434
+ if let Some ( ( new_name, silent ) ) = ids. 2 {
422
435
let lint_ids = self . lint_groups . get ( new_name) . unwrap ( ) ;
423
- return CheckLintNameResult :: Tool ( Err ( (
424
- Some ( & lint_ids. 0 ) ,
425
- new_name. to_string ( ) ,
426
- ) ) ) ;
436
+ return if silent {
437
+ CheckLintNameResult :: Tool ( Err ( ( Some ( & lint_ids. 0 ) , complete_name) ) )
438
+ } else {
439
+ CheckLintNameResult :: Tool ( Err ( (
440
+ Some ( & lint_ids. 0 ) ,
441
+ new_name. to_string ( ) ,
442
+ ) ) )
443
+ } ;
427
444
}
428
445
CheckLintNameResult :: Tool ( Err ( ( Some ( & ids. 0 ) , complete_name) ) )
429
446
}
0 commit comments