]> git.lizzy.rs Git - rust.git/commitdiff
Put back attributes check pass in rustdoc
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 1 Aug 2020 14:22:20 +0000 (16:22 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 11 Aug 2020 21:21:06 +0000 (23:21 +0200)
src/librustdoc/core.rs
src/test/rustdoc-ui/check-doc-alias-attr.rs [new file with mode: 0644]
src/test/rustdoc-ui/check-doc-alias-attr.stderr [new file with mode: 0644]

index b13acaae1bf234048cfd2858a33a01312808486d..f7c6a18a0e896a8b5237d9e2193a10858699d78e 100644 (file)
@@ -470,6 +470,10 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
                 sess.time("missing_docs", || {
                     rustc_lint::check_crate(tcx, rustc_lint::builtin::MissingDoc::new);
                 });
+                for &module in tcx.hir().krate().modules.keys() {
+                    let local_def_id = tcx.hir().local_def_id(module);
+                    tcx.ensure().check_mod_attrs(local_def_id);
+                }
 
                 let access_levels = tcx.privacy_access_levels(LOCAL_CRATE);
                 // Convert from a HirId set to a DefId set since we don't always have easy access
diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.rs b/src/test/rustdoc-ui/check-doc-alias-attr.rs
new file mode 100644 (file)
index 0000000..b02cc1a
--- /dev/null
@@ -0,0 +1,10 @@
+#![crate_type = "lib"]
+#![feature(doc_alias)]
+
+#[doc(alias = "foo")] // ok!
+pub struct Bar;
+
+#[doc(alias)] //~ ERROR
+#[doc(alias = 0)] //~ ERROR
+#[doc(alias("bar"))] //~ ERROR
+pub struct Foo;
diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.stderr b/src/test/rustdoc-ui/check-doc-alias-attr.stderr
new file mode 100644 (file)
index 0000000..268230a
--- /dev/null
@@ -0,0 +1,20 @@
+error: doc alias attribute expects a string: #[doc(alias = "0")]
+  --> $DIR/check-doc-alias-attr.rs:7:7
+   |
+LL | #[doc(alias)]
+   |       ^^^^^
+
+error: doc alias attribute expects a string: #[doc(alias = "0")]
+  --> $DIR/check-doc-alias-attr.rs:8:7
+   |
+LL | #[doc(alias = 0)]
+   |       ^^^^^^^^^
+
+error: doc alias attribute expects a string: #[doc(alias = "0")]
+  --> $DIR/check-doc-alias-attr.rs:9:7
+   |
+LL | #[doc(alias("bar"))]
+   |       ^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+