@@ -20,10 +20,11 @@ pub fn get_builtin_attr<'a, A: AttributeExt + 'a>(
2020 name : Symbol ,
2121) -> impl Iterator < Item = & ' a A > {
2222 attrs. iter ( ) . filter ( move |attr| {
23- if let Some ( [ clippy, segment2] ) = attr. ident_path ( ) . as_deref ( )
24- && clippy. name == sym:: clippy
23+ if let [ clippy, segment2] = & * attr. path ( )
24+ && * clippy == sym:: clippy
2525 {
26- let new_name = match segment2. name {
26+ let path_span = attr. path_span ( ) . expect ( "Clippy attributes are unparsed and have a span" ) ;
27+ let new_name = match * segment2 {
2728 sym:: cyclomatic_complexity => Some ( "cognitive_complexity" ) ,
2829 sym:: author
2930 | sym:: version
@@ -35,25 +36,25 @@ pub fn get_builtin_attr<'a, A: AttributeExt + 'a>(
3536 | sym:: has_significant_drop
3637 | sym:: format_args => None ,
3738 _ => {
38- sess. dcx ( ) . span_err ( segment2 . span , "usage of unknown attribute" ) ;
39+ sess. dcx ( ) . span_err ( path_span , "usage of unknown attribute" ) ;
3940 return false ;
4041 } ,
4142 } ;
4243
4344 match new_name {
4445 Some ( new_name) => {
4546 sess. dcx ( )
46- . struct_span_err ( segment2 . span , "usage of deprecated attribute" )
47+ . struct_span_err ( path_span , "usage of deprecated attribute" )
4748 . with_span_suggestion (
48- segment2 . span ,
49+ path_span ,
4950 "consider using" ,
50- new_name,
51+ format ! ( "clippy::{}" , new_name) ,
5152 Applicability :: MachineApplicable ,
5253 )
5354 . emit ( ) ;
5455 false
5556 } ,
56- None => segment2. name == name,
57+ None => * segment2 == name,
5758 }
5859 } else {
5960 false
0 commit comments