@@ -31,6 +31,27 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<String> {
31
31
std:: iter:: once ( crate_name) . chain ( relative) . collect ( )
32
32
}
33
33
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
+
34
55
// Also, is there some reason that this doesn't use the 'visit'
35
56
// framework from syntax?.
36
57
@@ -387,6 +408,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
387
408
388
409
match item. kind {
389
410
hir:: ItemKind :: ForeignMod ( ref fm) => {
411
+ check_doc_alias_attrs ( & item. attrs , "extern block" , self . cx . sess ( ) . diagnostic ( ) ) ;
390
412
for item in fm. items {
391
413
self . visit_foreign_item ( item, None , om) ;
392
414
}
@@ -561,6 +583,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
561
583
self_ty,
562
584
ref items,
563
585
} => {
586
+ check_doc_alias_attrs (
587
+ & item. attrs ,
588
+ "implementation block" ,
589
+ self . cx . sess ( ) . diagnostic ( ) ,
590
+ ) ;
564
591
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
565
592
// them up regardless of where they're located.
566
593
if !self . inlining && of_trait. is_none ( ) {
0 commit comments