diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 3c06bae177c..66799adef2a 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -1577,6 +1577,14 @@ impl LintPass for MissingDoc { tm.span, "a type method"); } + fn check_trait_method(&mut self, cx: &Context, it: &ast::TraitItem) { + if let ast::TraitItem::TypeTraitItem(ref ty) = *it { + let assoc_ty = &ty.ty_param; + self.check_missing_docs_attrs(cx, Some(assoc_ty.id), &ty.attrs, + assoc_ty.span, "an associated type"); + } + } + fn check_struct_field(&mut self, cx: &Context, sf: &ast::StructField) { if let ast::NamedField(_, vis) = sf.node.kind { if vis == ast::Public || self.in_variant { diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs index 73a58741bbb..f5ce85ab325 100644 --- a/src/test/compile-fail/lint-missing-doc.rs +++ b/src/test/compile-fail/lint-missing-doc.rs @@ -68,6 +68,19 @@ pub trait D { fn dummy(&self) { } } +/// dox +pub trait E { + type AssociatedType; //~ ERROR: missing documentation + type AssociatedTypeDef = Self; //~ ERROR: missing documentation + + /// dox + type DocumentedType; + /// dox + type DocumentedTypeDef = Self; + /// dox + fn dummy(&self) {} +} + impl Foo { pub fn foo() {} fn bar() {}