about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-08 22:16:13 +0000
committerbors <bors@rust-lang.org>2019-01-08 22:16:13 +0000
commit167ceff01ec2f01f677fa6351646255d3dacbb98 (patch)
treefa3a3ea838d5da3d10393bff6e8eeec35e428bc8 /src
parentd22fa2d87d03d19fdb1359faab9ec5e74eff26b3 (diff)
parent0b272e740051192344c36f0444d9ef28f2ab31fe (diff)
downloadrust-167ceff01ec2f01f677fa6351646255d3dacbb98.tar.gz
rust-167ceff01ec2f01f677fa6351646255d3dacbb98.zip
Auto merge of #56407 - GuillaumeGomez:missing-docs-reexported-macros, r=varkor
check missing docs for reexported macros as well

Fixes #56334.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/lib.rs2
-rw-r--r--src/librustc_lint/builtin.rs49
-rw-r--r--src/libstd/macros.rs1
m---------src/stdsimd0
-rw-r--r--src/test/rustdoc-ui/deny-missing-docs-crate.rs13
-rw-r--r--src/test/rustdoc-ui/deny-missing-docs-crate.stderr22
-rw-r--r--src/test/rustdoc-ui/deny-missing-docs-macro.rs18
-rw-r--r--src/test/rustdoc-ui/deny-missing-docs-macro.stderr14
8 files changed, 99 insertions, 20 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 19bf4ab15bf..b2cafc4cede 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -122,6 +122,8 @@
 #![feature(reverse_bits)]
 #![feature(non_exhaustive)]
 #![feature(structural_match)]
+#![feature(abi_unadjusted)]
+#![cfg_attr(not(stage0), feature(adx_target_feature))]
 
 #[prelude_import]
 #[allow(unused)]
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index a555b779097..5678f30dabc 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -297,6 +297,26 @@ pub struct MissingDoc {
     private_traits: FxHashSet<ast::NodeId>,
 }
 
+fn has_doc(attr: &ast::Attribute) -> bool {
+    if !attr.check_name("doc") {
+        return false;
+    }
+
+    if attr.is_value_str() {
+        return true;
+    }
+
+    if let Some(list) = attr.meta_item_list() {
+        for meta in list {
+            if meta.check_name("include") || meta.check_name("hidden") {
+                return true;
+            }
+        }
+    }
+
+    false
+}
+
 impl MissingDoc {
     pub fn new() -> MissingDoc {
         MissingDoc {
@@ -335,26 +355,6 @@ impl MissingDoc {
             }
         }
 
-        fn has_doc(attr: &ast::Attribute) -> bool {
-            if !attr.check_name("doc") {
-                return false;
-            }
-
-            if attr.is_value_str() {
-                return true;
-            }
-
-            if let Some(list) = attr.meta_item_list() {
-                for meta in list {
-                    if meta.check_name("include") {
-                        return true;
-                    }
-                }
-            }
-
-            false
-        }
-
         let has_doc = attrs.iter().any(|a| has_doc(a));
         if !has_doc {
             cx.span_lint(MISSING_DOCS,
@@ -389,6 +389,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
 
     fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
         self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate");
+
+        for macro_def in &krate.exported_macros {
+            let has_doc = macro_def.attrs.iter().any(|a| has_doc(a));
+            if !has_doc {
+                cx.span_lint(MISSING_DOCS,
+                             cx.tcx.sess.source_map().def_span(macro_def.span),
+                             "missing documentation for macro");
+            }
+        }
     }
 
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index c92365df03a..b87257188df 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -322,6 +322,7 @@ macro_rules! dbg {
     }
 }
 
+/// A macro to await on an async call.
 #[macro_export]
 #[unstable(feature = "await_macro", issue = "50547")]
 #[allow_internal_unstable]
diff --git a/src/stdsimd b/src/stdsimd
-Subproject ddb30221d7985e813b4214d14c2a560ed6ee099
+Subproject 269d0ba959f70e9b692e528311c78b8f9601d4a
diff --git a/src/test/rustdoc-ui/deny-missing-docs-crate.rs b/src/test/rustdoc-ui/deny-missing-docs-crate.rs
new file mode 100644
index 00000000000..910c99314e4
--- /dev/null
+++ b/src/test/rustdoc-ui/deny-missing-docs-crate.rs
@@ -0,0 +1,13 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(missing_docs)] //~ ERROR
+
+pub struct Foo; //~ ERROR
diff --git a/src/test/rustdoc-ui/deny-missing-docs-crate.stderr b/src/test/rustdoc-ui/deny-missing-docs-crate.stderr
new file mode 100644
index 00000000000..7f0590e0b22
--- /dev/null
+++ b/src/test/rustdoc-ui/deny-missing-docs-crate.stderr
@@ -0,0 +1,22 @@
+error: missing documentation for crate
+  --> $DIR/deny-missing-docs-crate.rs:11:1
+   |
+LL | / #![deny(missing_docs)] //~ ERROR
+LL | |
+LL | | pub struct Foo; //~ ERROR
+   | |_______________^
+   |
+note: lint level defined here
+  --> $DIR/deny-missing-docs-crate.rs:11:9
+   |
+LL | #![deny(missing_docs)] //~ ERROR
+   |         ^^^^^^^^^^^^
+
+error: missing documentation for a struct
+  --> $DIR/deny-missing-docs-crate.rs:13:1
+   |
+LL | pub struct Foo; //~ ERROR
+   | ^^^^^^^^^^^^^^^
+
+error: Compilation failed, aborting rustdoc
+
diff --git a/src/test/rustdoc-ui/deny-missing-docs-macro.rs b/src/test/rustdoc-ui/deny-missing-docs-macro.rs
new file mode 100644
index 00000000000..a12fe17e0cb
--- /dev/null
+++ b/src/test/rustdoc-ui/deny-missing-docs-macro.rs
@@ -0,0 +1,18 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! foo
+
+#![deny(missing_docs)]
+
+#[macro_export]
+macro_rules! foo { //~ ERROR
+    () => {}
+}
diff --git a/src/test/rustdoc-ui/deny-missing-docs-macro.stderr b/src/test/rustdoc-ui/deny-missing-docs-macro.stderr
new file mode 100644
index 00000000000..686a45030e6
--- /dev/null
+++ b/src/test/rustdoc-ui/deny-missing-docs-macro.stderr
@@ -0,0 +1,14 @@
+error: missing documentation for macro
+  --> $DIR/deny-missing-docs-macro.rs:16:1
+   |
+LL | macro_rules! foo { //~ ERROR
+   | ^^^^^^^^^^^^^^^^
+   |
+note: lint level defined here
+  --> $DIR/deny-missing-docs-macro.rs:13:9
+   |
+LL | #![deny(missing_docs)]
+   |         ^^^^^^^^^^^^
+
+error: Compilation failed, aborting rustdoc
+