@@ -393,8 +393,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
393393 }
394394 }
395395
396- let builtin = attr. ident ( ) . and_then ( |ident| BUILTIN_ATTRIBUTE_MAP . get ( & ident. name ) ) ;
397-
398396 if hir_id != CRATE_HIR_ID {
399397 match attr {
400398 Attribute :: Parsed ( _) => { /* Already validated. */ }
@@ -440,8 +438,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
440438 }
441439 }
442440
443- if let Some ( BuiltinAttribute { duplicates, .. } ) = builtin {
444- check_duplicates ( self . tcx , attr, hir_id, * duplicates, & mut seen) ;
441+ if let Attribute :: Unparsed ( unparsed_attr) = attr
442+ && let Some ( BuiltinAttribute { duplicates, .. } ) =
443+ attr. ident ( ) . and_then ( |ident| BUILTIN_ATTRIBUTE_MAP . get ( & ident. name ) )
444+ {
445+ check_duplicates (
446+ self . tcx ,
447+ unparsed_attr. span ,
448+ attr,
449+ hir_id,
450+ * duplicates,
451+ & mut seen,
452+ ) ;
445453 }
446454
447455 self . check_unused_attribute ( hir_id, attr, style)
@@ -2481,6 +2489,7 @@ pub(crate) fn provide(providers: &mut Providers) {
24812489// FIXME(jdonszelmann): remove, check during parsing
24822490fn check_duplicates (
24832491 tcx : TyCtxt < ' _ > ,
2492+ attr_span : Span ,
24842493 attr : & Attribute ,
24852494 hir_id : HirId ,
24862495 duplicates : AttributeDuplicates ,
@@ -2497,10 +2506,10 @@ fn check_duplicates(
24972506 match seen. entry ( attr_name) {
24982507 Entry :: Occupied ( mut entry) => {
24992508 let ( this, other) = if matches ! ( duplicates, FutureWarnPreceding ) {
2500- let to_remove = entry. insert ( attr . span ( ) ) ;
2501- ( to_remove, attr . span ( ) )
2509+ let to_remove = entry. insert ( attr_span ) ;
2510+ ( to_remove, attr_span )
25022511 } else {
2503- ( attr . span ( ) , * entry. get ( ) )
2512+ ( attr_span , * entry. get ( ) )
25042513 } ;
25052514 tcx. emit_node_span_lint (
25062515 UNUSED_ATTRIBUTES ,
@@ -2517,22 +2526,22 @@ fn check_duplicates(
25172526 ) ;
25182527 }
25192528 Entry :: Vacant ( entry) => {
2520- entry. insert ( attr . span ( ) ) ;
2529+ entry. insert ( attr_span ) ;
25212530 }
25222531 }
25232532 }
25242533 ErrorFollowing | ErrorPreceding => match seen. entry ( attr_name) {
25252534 Entry :: Occupied ( mut entry) => {
25262535 let ( this, other) = if matches ! ( duplicates, ErrorPreceding ) {
2527- let to_remove = entry. insert ( attr . span ( ) ) ;
2528- ( to_remove, attr . span ( ) )
2536+ let to_remove = entry. insert ( attr_span ) ;
2537+ ( to_remove, attr_span )
25292538 } else {
2530- ( attr . span ( ) , * entry. get ( ) )
2539+ ( attr_span , * entry. get ( ) )
25312540 } ;
25322541 tcx. dcx ( ) . emit_err ( errors:: UnusedMultiple { this, other, name : attr_name } ) ;
25332542 }
25342543 Entry :: Vacant ( entry) => {
2535- entry. insert ( attr . span ( ) ) ;
2544+ entry. insert ( attr_span ) ;
25362545 }
25372546 } ,
25382547 }
0 commit comments