mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add an error in case the doc alias is the same as the item it's aliasing
This commit is contained in:
parent
887398ff68
commit
c4c010f534
@ -310,7 +310,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||
.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 @@ impl CheckAttrVisitor<'tcx> {
|
||||
.emit();
|
||||
return false;
|
||||
}
|
||||
let item_name = self.tcx.hir().name(hir_id);
|
||||
if item_name.to_string() == 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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user