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
1 changed files with 12 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue