@@ -394,8 +394,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
394394                } 
395395            } 
396396
397-             let  builtin = attr. ident ( ) . and_then ( |ident| BUILTIN_ATTRIBUTE_MAP . get ( & ident. name ) ) ; 
398- 
399397            if  hir_id != CRATE_HIR_ID  { 
400398                match  attr { 
401399                    Attribute :: Parsed ( _)  => {  /* Already validated. */  } 
@@ -441,8 +439,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
441439                } 
442440            } 
443441
444-             if  let  Some ( BuiltinAttribute  {  duplicates,  .. } )  = builtin { 
445-                 check_duplicates ( self . tcx ,  attr,  hir_id,  * duplicates,  & mut  seen) ; 
442+             if  let  Attribute :: Unparsed ( unparsed_attr)  = attr
443+                 && let  Some ( BuiltinAttribute  {  duplicates,  .. } )  =
444+                     attr. ident ( ) . and_then ( |ident| BUILTIN_ATTRIBUTE_MAP . get ( & ident. name ) ) 
445+             { 
446+                 check_duplicates ( 
447+                     self . tcx , 
448+                     unparsed_attr. span , 
449+                     attr, 
450+                     hir_id, 
451+                     * duplicates, 
452+                     & mut  seen, 
453+                 ) ; 
446454            } 
447455
448456            self . check_unused_attribute ( hir_id,  attr,  style) 
@@ -2483,6 +2491,7 @@ pub(crate) fn provide(providers: &mut Providers) {
24832491// FIXME(jdonszelmann): remove, check during parsing 
24842492fn  check_duplicates ( 
24852493    tcx :  TyCtxt < ' _ > , 
2494+     attr_span :  Span , 
24862495    attr :  & Attribute , 
24872496    hir_id :  HirId , 
24882497    duplicates :  AttributeDuplicates , 
@@ -2499,10 +2508,10 @@ fn check_duplicates(
24992508            match  seen. entry ( attr_name)  { 
25002509                Entry :: Occupied ( mut  entry)  => { 
25012510                    let  ( this,  other)  = if  matches ! ( duplicates,  FutureWarnPreceding )  { 
2502-                         let  to_remove = entry. insert ( attr . span ( ) ) ; 
2503-                         ( to_remove,  attr . span ( ) ) 
2511+                         let  to_remove = entry. insert ( attr_span ) ; 
2512+                         ( to_remove,  attr_span ) 
25042513                    }  else  { 
2505-                         ( attr . span ( ) ,  * entry. get ( ) ) 
2514+                         ( attr_span ,  * entry. get ( ) ) 
25062515                    } ; 
25072516                    tcx. emit_node_span_lint ( 
25082517                        UNUSED_ATTRIBUTES , 
@@ -2519,22 +2528,22 @@ fn check_duplicates(
25192528                    ) ; 
25202529                } 
25212530                Entry :: Vacant ( entry)  => { 
2522-                     entry. insert ( attr . span ( ) ) ; 
2531+                     entry. insert ( attr_span ) ; 
25232532                } 
25242533            } 
25252534        } 
25262535        ErrorFollowing  | ErrorPreceding  => match  seen. entry ( attr_name)  { 
25272536            Entry :: Occupied ( mut  entry)  => { 
25282537                let  ( this,  other)  = if  matches ! ( duplicates,  ErrorPreceding )  { 
2529-                     let  to_remove = entry. insert ( attr . span ( ) ) ; 
2530-                     ( to_remove,  attr . span ( ) ) 
2538+                     let  to_remove = entry. insert ( attr_span ) ; 
2539+                     ( to_remove,  attr_span ) 
25312540                }  else  { 
2532-                     ( attr . span ( ) ,  * entry. get ( ) ) 
2541+                     ( attr_span ,  * entry. get ( ) ) 
25332542                } ; 
25342543                tcx. dcx ( ) . emit_err ( errors:: UnusedMultiple  {  this,  other,  name :  attr_name } ) ; 
25352544            } 
25362545            Entry :: Vacant ( entry)  => { 
2537-                 entry. insert ( attr . span ( ) ) ; 
2546+                 entry. insert ( attr_span ) ; 
25382547            } 
25392548        } , 
25402549    } 
0 commit comments