Skip to content

Commit 87c4103

Browse files
committed
Update missing-docs lint to check associated type declarations
[breaking-change] Fixes #20648
1 parent e2da5a4 commit 87c4103

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/librustc/lint/builtin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,14 @@ impl LintPass for MissingDoc {
15771577
tm.span, "a type method");
15781578
}
15791579

1580+
fn check_trait_method(&mut self, cx: &Context, it: &ast::TraitItem) {
1581+
if let ast::TraitItem::TypeTraitItem(ref ty) = *it {
1582+
let assoc_ty = &ty.ty_param;
1583+
self.check_missing_docs_attrs(cx, Some(assoc_ty.id), &ty.attrs,
1584+
assoc_ty.span, "an associated type");
1585+
}
1586+
}
1587+
15801588
fn check_struct_field(&mut self, cx: &Context, sf: &ast::StructField) {
15811589
if let ast::NamedField(_, vis) = sf.node.kind {
15821590
if vis == ast::Public || self.in_variant {

src/test/compile-fail/lint-missing-doc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ pub trait D {
6868
fn dummy(&self) { }
6969
}
7070

71+
/// dox
72+
pub trait E {
73+
type AssociatedType; //~ ERROR: missing documentation
74+
type AssociatedTypeDef = Self; //~ ERROR: missing documentation
75+
76+
/// dox
77+
type DocumentedType;
78+
/// dox
79+
type DocumentedTypeDef = Self;
80+
/// dox
81+
fn dummy(&self) {}
82+
}
83+
7184
impl Foo {
7285
pub fn foo() {}
7386
fn bar() {}

0 commit comments

Comments
 (0)