File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,33 @@ impl Attributes {
481
481
} )
482
482
}
483
483
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
+
484
511
pub fn has_doc_flag ( & self , flag : Symbol ) -> bool {
485
512
for attr in & self . other_attrs {
486
513
if !attr. check_name ( sym:: doc) {
@@ -524,6 +551,7 @@ impl Attributes {
524
551
} else {
525
552
if attr. check_name ( sym:: doc) {
526
553
if let Some ( mi) = attr. meta ( ) {
554
+ Attributes :: check_doc_attributes ( & diagnostic, & mi) ;
527
555
if let Some ( cfg_mi) = Attributes :: extract_cfg ( & mi) {
528
556
// Extracted #[doc(cfg(...))]
529
557
match Cfg :: parse ( cfg_mi) {
You can’t perform that action at this time.
0 commit comments