about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIvan Petkov <ivanppetkov@gmail.com>2015-02-23 11:07:37 -0800
committerIvan Petkov <ivanppetkov@gmail.com>2015-02-23 11:07:37 -0800
commit717a91d6651598994834d056c69e6c4bf2b74b9f (patch)
tree24ff34e30e31684f57b4f6ef426d47ee9091b77e
parentdab394c2db5d62dce64ac13af35bb2f18357c9d8 (diff)
downloadrust-717a91d6651598994834d056c69e6c4bf2b74b9f.tar.gz
rust-717a91d6651598994834d056c69e6c4bf2b74b9f.zip
Update missing-docs lint to check associated type declarations
[breaking-change]

Fixes #20648
-rw-r--r--src/librustc/lint/builtin.rs8
-rw-r--r--src/test/compile-fail/lint-missing-doc.rs13
2 files changed, 21 insertions, 0 deletions
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() {}