about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-09-06 12:20:36 +0200
committerUrgau <urgau@numericable.fr>2024-09-06 12:20:36 +0200
commit7dd1be1d0d2911b16aa1347efa47e7c43c507ade (patch)
treefa2b745a24e69246a6e80c96b439064ca3f16387
parenteb33b43bab08223fa6b46abacc1e95e859fe375d (diff)
downloadrust-7dd1be1d0d2911b16aa1347efa47e7c43c507ade.tar.gz
rust-7dd1be1d0d2911b16aa1347efa47e7c43c507ade.zip
Also emit `missing_docs` lint with `--test` to fulfill expectations
-rw-r--r--compiler/rustc_lint/src/builtin.rs6
-rw-r--r--tests/ui/lint/lint-missing-doc-expect.rs13
2 files changed, 13 insertions, 6 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index d8482567bbe..5cb51953674 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -426,12 +426,6 @@ impl MissingDoc {
         article: &'static str,
         desc: &'static str,
     ) {
-        // If we're building a test harness, then warning about
-        // documentation is probably not really relevant right now.
-        if cx.sess().opts.test {
-            return;
-        }
-
         // Only check publicly-visible items, using the result from the privacy pass.
         // It's an option so the crate root can also use this function (it doesn't
         // have a `NodeId`).
diff --git a/tests/ui/lint/lint-missing-doc-expect.rs b/tests/ui/lint/lint-missing-doc-expect.rs
new file mode 100644
index 00000000000..991f65003dc
--- /dev/null
+++ b/tests/ui/lint/lint-missing-doc-expect.rs
@@ -0,0 +1,13 @@
+// Make sure that `#[expect(missing_docs)]` is always correctly fulfilled.
+
+//@ check-pass
+//@ revisions: lib bin test
+//@ [lib]compile-flags: --crate-type lib
+//@ [bin]compile-flags: --crate-type bin
+//@ [test]compile-flags: --test
+
+#[expect(missing_docs)]
+pub fn foo() {}
+
+#[cfg(bin)]
+fn main() {}