@@ -12,29 +12,6 @@ use rustc_session::Session;
12
12
use rustc_span:: { Span , Symbol } ;
13
13
use std:: str:: FromStr ;
14
14
15
- /// Deprecation status of attributes known by Clippy.
16
- pub enum DeprecationStatus {
17
- /// Attribute is deprecated
18
- Deprecated ,
19
- /// Attribute is deprecated and was replaced by the named attribute
20
- Replaced ( & ' static str ) ,
21
- None ,
22
- }
23
-
24
- #[ rustfmt:: skip]
25
- pub const BUILTIN_ATTRIBUTES : & [ ( Symbol , DeprecationStatus ) ] = & [
26
- ( sym:: author, DeprecationStatus :: None ) ,
27
- ( sym:: version, DeprecationStatus :: None ) ,
28
- ( sym:: cognitive_complexity, DeprecationStatus :: None ) ,
29
- ( sym:: cyclomatic_complexity, DeprecationStatus :: Replaced ( "cognitive_complexity" ) ) ,
30
- ( sym:: dump, DeprecationStatus :: None ) ,
31
- ( sym:: msrv, DeprecationStatus :: None ) ,
32
- // The following attributes are for the 3rd party crate authors.
33
- // See book/src/attribs.md
34
- ( sym:: has_significant_drop, DeprecationStatus :: None ) ,
35
- ( sym:: format_args, DeprecationStatus :: None ) ,
36
- ] ;
37
-
38
15
pub struct LimitStack {
39
16
stack : Vec < u64 > ,
40
17
}
@@ -72,36 +49,37 @@ pub fn get_attr<'a, A: AttributeExt + 'a>(
72
49
if let Some ( [ clippy, segment2] ) = attr. ident_path ( ) . as_deref ( )
73
50
&& clippy. name == sym:: clippy
74
51
{
75
- let Some ( ( _, deprecation_status) ) = BUILTIN_ATTRIBUTES
76
- . iter ( )
77
- . find ( |( builtin_name, _) | segment2. name == * builtin_name)
78
- else {
79
- sess. dcx ( ) . span_err ( segment2. span , "usage of unknown attribute" ) ;
80
- return false ;
52
+ let deprecation_status = match segment2. name {
53
+ sym:: cyclomatic_complexity => Some ( "cognitive_complexity" ) ,
54
+ sym:: author
55
+ | sym:: version
56
+ | sym:: cognitive_complexity
57
+ | sym:: dump
58
+ | sym:: msrv
59
+ // The following attributes are for the 3rd party crate authors.
60
+ // See book/src/attribs.md
61
+ | sym:: has_significant_drop
62
+ | sym:: format_args => None ,
63
+ _ => {
64
+ sess. dcx ( ) . span_err ( segment2. span , "usage of unknown attribute" ) ;
65
+ return false ;
66
+ } ,
81
67
} ;
82
68
83
- let mut diag = sess
84
- . dcx ( )
85
- . struct_span_err ( segment2. span , "usage of deprecated attribute" ) ;
86
69
match deprecation_status {
87
- DeprecationStatus :: Deprecated => {
88
- diag. emit ( ) ;
70
+ Some ( new_name) => {
71
+ sess. dcx ( )
72
+ . struct_span_err ( segment2. span , "usage of deprecated attribute" )
73
+ . with_span_suggestion (
74
+ segment2. span ,
75
+ "consider using" ,
76
+ new_name,
77
+ Applicability :: MachineApplicable ,
78
+ )
79
+ . emit ( ) ;
89
80
false
90
81
} ,
91
- DeprecationStatus :: Replaced ( new_name) => {
92
- diag. span_suggestion (
93
- segment2. span ,
94
- "consider using" ,
95
- new_name,
96
- Applicability :: MachineApplicable ,
97
- ) ;
98
- diag. emit ( ) ;
99
- false
100
- } ,
101
- DeprecationStatus :: None => {
102
- diag. cancel ( ) ;
103
- segment2. name == name
104
- } ,
82
+ None => segment2. name == name,
105
83
}
106
84
} else {
107
85
false
0 commit comments