@@ -531,60 +531,65 @@ impl CheckAttrVisitor<'tcx> {
531531 }
532532
533533 fn check_doc_attrs ( & self , attr : & Attribute , hir_id : HirId , target : Target ) -> bool {
534- if let Some ( mi) = attr. meta ( ) {
535- if let Some ( list) = mi. meta_item_list ( ) {
536- for meta in list {
537- if meta. has_name ( sym:: alias) {
538- if !self . check_attr_crate_level ( meta, hir_id, "alias" )
539- || !self . check_doc_alias ( meta, hir_id, target)
534+ if let Some ( list) = attr. meta ( ) . and_then ( |mi| mi. meta_item_list ( ) . map ( |l| l. to_vec ( ) ) ) {
535+ for meta in list {
536+ if let Some ( i_meta) = meta. meta_item ( ) {
537+ match i_meta. name_or_empty ( ) {
538+ sym:: alias
539+ if !self . check_attr_crate_level ( & meta, hir_id, "alias" )
540+ || !self . check_doc_alias ( & meta, hir_id, target) =>
540541 {
541542 return false ;
542543 }
543- } else if meta. has_name ( sym:: keyword) {
544- if !self . check_attr_crate_level ( meta, hir_id, "keyword" )
545- || !self . check_doc_keyword ( meta, hir_id)
544+
545+ sym:: keyword
546+ if !self . check_attr_crate_level ( & meta, hir_id, "keyword" )
547+ || !self . check_doc_keyword ( & meta, hir_id) =>
546548 {
547549 return false ;
548550 }
549- } else if meta . has_name ( sym :: test ) {
550- if CRATE_HIR_ID != hir_id {
551+
552+ sym :: test if CRATE_HIR_ID != hir_id => {
551553 self . tcx . struct_span_lint_hir (
552554 INVALID_DOC_ATTRIBUTES ,
553555 hir_id,
554556 meta. span ( ) ,
555557 |lint| {
556558 lint. build (
557- "`#![doc(test(...)]` is only allowed as a crate level attribute"
559+ "`#![doc(test(...)]` is only allowed \
560+ as a crate level attribute",
558561 )
559562 . emit ( ) ;
560563 } ,
561564 ) ;
562565 return false ;
563566 }
564- } else if let Some ( i_meta) = meta. meta_item ( ) {
565- if ![
566- sym:: cfg,
567- sym:: hidden,
568- sym:: html_favicon_url,
569- sym:: html_logo_url,
570- sym:: html_no_source,
571- sym:: html_playground_url,
572- sym:: html_root_url,
573- sym:: include,
574- sym:: inline,
575- sym:: issue_tracker_base_url,
576- sym:: masked,
577- sym:: no_default_passes, // deprecated
578- sym:: no_inline,
579- sym:: passes, // deprecated
580- sym:: plugins, // removed, but rustdoc warns about it itself
581- sym:: primitive,
582- sym:: spotlight,
583- sym:: test,
584- ]
585- . iter ( )
586- . any ( |m| i_meta. has_name ( * m) )
587- {
567+
568+ // no_default_passes: deprecated
569+ // passes: deprecated
570+ // plugins: removed, but rustdoc warns about it itself
571+ sym:: alias
572+ | sym:: cfg
573+ | sym:: hidden
574+ | sym:: html_favicon_url
575+ | sym:: html_logo_url
576+ | sym:: html_no_source
577+ | sym:: html_playground_url
578+ | sym:: html_root_url
579+ | sym:: include
580+ | sym:: inline
581+ | sym:: issue_tracker_base_url
582+ | sym:: keyword
583+ | sym:: masked
584+ | sym:: no_default_passes
585+ | sym:: no_inline
586+ | sym:: passes
587+ | sym:: plugins
588+ | sym:: primitive
589+ | sym:: spotlight
590+ | sym:: test => { }
591+
592+ _ => {
588593 self . tcx . struct_span_lint_hir (
589594 INVALID_DOC_ATTRIBUTES ,
590595 hir_id,
0 commit comments