1
Fork 0

Add check for doc alias on associated const in trait impls

This commit is contained in:
Guillaume Gomez 2020-08-24 20:20:03 +02:00
parent 6c44bcc4ff
commit 6e43ff5cea

View file

@ -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();
} }