@@ -31,6 +31,27 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<String> {
3131 std:: iter:: once ( crate_name) . chain ( relative) . collect ( )
3232}
3333
34+ fn check_doc_alias_attrs (
35+ attrs : & [ ast:: Attribute ] ,
36+ item_kind : & str ,
37+ diagnostic : & :: rustc_errors:: Handler ,
38+ ) {
39+ for attr in attrs {
40+ if let Some ( attr) = attr. meta ( ) {
41+ if let Some ( list) = attr. meta_item_list ( ) {
42+ for meta in list {
43+ if meta. check_name ( sym:: alias) {
44+ diagnostic. span_err (
45+ meta. span ( ) ,
46+ & format ! ( "`#[doc(alias = \" ...\" )]` isn't allowed on {}" , item_kind) ,
47+ ) ;
48+ }
49+ }
50+ }
51+ }
52+ }
53+ }
54+
3455// Also, is there some reason that this doesn't use the 'visit'
3556// framework from syntax?.
3657
@@ -387,6 +408,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
387408
388409 match item. kind {
389410 hir:: ItemKind :: ForeignMod ( ref fm) => {
411+ check_doc_alias_attrs ( & item. attrs , "extern block" , self . cx . sess ( ) . diagnostic ( ) ) ;
390412 for item in fm. items {
391413 self . visit_foreign_item ( item, None , om) ;
392414 }
@@ -561,6 +583,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
561583 self_ty,
562584 ref items,
563585 } => {
586+ check_doc_alias_attrs (
587+ & item. attrs ,
588+ "implementation block" ,
589+ self . cx . sess ( ) . diagnostic ( ) ,
590+ ) ;
564591 // Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
565592 // them up regardless of where they're located.
566593 if !self . inlining && of_trait. is_none ( ) {
0 commit comments