@@ -14,10 +14,8 @@ use std::str::FromStr;
14
14
15
15
/// Deprecation status of attributes known by Clippy.
16
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 ) ,
17
+ /// Attribute is deprecated and was possibly replaced by the named attribute
18
+ Deprecated ( Option < & ' static str > ) ,
21
19
None ,
22
20
}
23
21
@@ -26,7 +24,7 @@ pub const BUILTIN_ATTRIBUTES: &[(Symbol, DeprecationStatus)] = &[
26
24
( sym:: author, DeprecationStatus :: None ) ,
27
25
( sym:: version, DeprecationStatus :: None ) ,
28
26
( sym:: cognitive_complexity, DeprecationStatus :: None ) ,
29
- ( sym:: cyclomatic_complexity, DeprecationStatus :: Replaced ( "cognitive_complexity" ) ) ,
27
+ ( sym:: cyclomatic_complexity, DeprecationStatus :: Deprecated ( Some ( "cognitive_complexity" ) ) ) ,
30
28
( sym:: dump, DeprecationStatus :: None ) ,
31
29
( sym:: msrv, DeprecationStatus :: None ) ,
32
30
// The following attributes are for the 3rd party crate authors.
@@ -81,28 +79,23 @@ pub fn get_attr<'a, A: AttributeExt + 'a>(
81
79
return false ;
82
80
} ;
83
81
84
- let mut diag = sess
85
- . dcx ( )
86
- . struct_span_err ( segment2. span , "usage of deprecated attribute" ) ;
87
82
match deprecation_status {
88
- DeprecationStatus :: Deprecated => {
83
+ DeprecationStatus :: Deprecated ( new_name) => {
84
+ let mut diag = sess
85
+ . dcx ( )
86
+ . struct_span_err ( segment2. span , "usage of deprecated attribute" ) ;
87
+ if let Some ( new_name) = new_name {
88
+ diag. span_suggestion (
89
+ segment2. span ,
90
+ "consider using" ,
91
+ new_name,
92
+ Applicability :: MachineApplicable ,
93
+ ) ;
94
+ }
89
95
diag. emit ( ) ;
90
96
false
91
97
} ,
92
- DeprecationStatus :: Replaced ( new_name) => {
93
- diag. span_suggestion (
94
- segment2. span ,
95
- "consider using" ,
96
- new_name,
97
- Applicability :: MachineApplicable ,
98
- ) ;
99
- diag. emit ( ) ;
100
- false
101
- } ,
102
- DeprecationStatus :: None => {
103
- diag. cancel ( ) ;
104
- segment2. name == name
105
- } ,
98
+ DeprecationStatus :: None => segment2. name == name,
106
99
}
107
100
} else {
108
101
false
0 commit comments