Add check for doc alias on associated const in trait impls
This commit is contained in:
parent
6c44bcc4ff
commit
6e43ff5cea
1 changed files with 11 additions and 1 deletions
|
@ -250,13 +250,23 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Target::AssocConst => {
|
||||||
|
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
||||||
|
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
|
||||||
|
// We can't link to trait impl's consts.
|
||||||
|
let err = "associated constant in trait implementation block";
|
||||||
|
match containing_item.kind {
|
||||||
|
ItemKind::Impl { of_trait: Some(_), .. } => Some(err),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
} {
|
} {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
meta.span(),
|
meta.span(),
|
||||||
&format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err,),
|
&format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err),
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue