File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,33 @@ impl Attributes {
481481 } )
482482 }
483483
484+ /// Enforce the format of attributes inside `#[doc(...)]`.
485+ pub fn check_doc_attributes (
486+ diagnostic : & :: rustc_errors:: Handler ,
487+ mi : & ast:: MetaItem ,
488+ ) -> Option < ( String , String ) > {
489+ mi. meta_item_list ( ) . and_then ( |list| {
490+ for meta in list {
491+ if meta. check_name ( sym:: alias) {
492+ if !meta. is_value_str ( )
493+ || meta
494+ . value_str ( )
495+ . map ( |s| s. to_string ( ) )
496+ . unwrap_or_else ( String :: new)
497+ . is_empty ( )
498+ {
499+ diagnostic. span_err (
500+ meta. span ( ) ,
501+ "doc alias attribute expects a string: #[doc(alias = \" 0\" )]" ,
502+ ) ;
503+ }
504+ }
505+ }
506+
507+ None
508+ } )
509+ }
510+
484511 pub fn has_doc_flag ( & self , flag : Symbol ) -> bool {
485512 for attr in & self . other_attrs {
486513 if !attr. check_name ( sym:: doc) {
@@ -524,6 +551,7 @@ impl Attributes {
524551 } else {
525552 if attr. check_name ( sym:: doc) {
526553 if let Some ( mi) = attr. meta ( ) {
554+ Attributes :: check_doc_attributes ( & diagnostic, & mi) ;
527555 if let Some ( cfg_mi) = Attributes :: extract_cfg ( & mi) {
528556 // Extracted #[doc(cfg(...))]
529557 match Cfg :: parse ( cfg_mi) {
You can’t perform that action at this time.
0 commit comments