]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_passes/src/check_attr.rs
Auto merge of #80790 - JohnTitor:rollup-js1noez, r=JohnTitor
[rust.git] / compiler / rustc_passes / src / check_attr.rs
index aeaa862f5fd631e1c544f1504b4541d784cc6f53..a6a61ffc5dae509e52e67f2705266452be1401ba 100644 (file)
@@ -310,7 +310,7 @@ fn check_doc_alias(&self, meta: &NestedMetaItem, hir_id: HirId, target: Target)
                 .sess
                 .struct_span_err(
                     meta.name_value_literal_span().unwrap_or_else(|| meta.span()),
-                    &format!("{:?} character isn't allowed in `#[doc(alias = \"...\")]`", c,),
+                    &format!("{:?} character isn't allowed in `#[doc(alias = \"...\")]`", c),
                 )
                 .emit();
             return false;
@@ -358,6 +358,17 @@ fn check_doc_alias(&self, meta: &NestedMetaItem, hir_id: HirId, target: Target)
                 .emit();
             return false;
         }
+        let item_name = self.tcx.hir().name(hir_id);
+        if &*item_name.as_str() == doc_alias {
+            self.tcx
+                .sess
+                .struct_span_err(
+                    meta.span(),
+                    &format!("`#[doc(alias = \"...\")]` is the same as the item's name"),
+                )
+                .emit();
+            return false;
+        }
         true
     }