about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-10-01 17:08:01 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-10-01 17:08:01 +0200
commitb073ddcce51aafde86e888d27c640f6d506e0d9d (patch)
tree2e1edb92c44de9e57d753d1017d00ff50be53ed0 /tests
parentcdbe8e5d281dfecaa3621dc32b1507b4901aef58 (diff)
downloadrust-b073ddcce51aafde86e888d27c640f6d506e0d9d.tar.gz
rust-b073ddcce51aafde86e888d27c640f6d506e0d9d.zip
Add regression tests for #130681
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-ui/doctest/dead-code-2024.rs15
-rw-r--r--tests/rustdoc-ui/doctest/dead-code-2024.stdout29
-rw-r--r--tests/rustdoc-ui/doctest/dead-code.rs15
-rw-r--r--tests/rustdoc-ui/doctest/dead-code.stdout29
4 files changed, 88 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/dead-code-2024.rs b/tests/rustdoc-ui/doctest/dead-code-2024.rs
new file mode 100644
index 00000000000..4c77112e61a
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/dead-code-2024.rs
@@ -0,0 +1,15 @@
+// This test ensures that the 2024 edition merged doctest will not use `#[allow(unused)]`.
+
+//@ compile-flags:--test -Zunstable-options --edition 2024
+//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
+//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
+//@ failure-status: 101
+
+#![doc(test(attr(allow(unused_variables), deny(warnings))))]
+
+/// Example
+///
+/// ```rust,no_run
+/// trait T { fn f(); }
+/// ```
+pub fn f() {}
diff --git a/tests/rustdoc-ui/doctest/dead-code-2024.stdout b/tests/rustdoc-ui/doctest/dead-code-2024.stdout
new file mode 100644
index 00000000000..69dd4e2ede1
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/dead-code-2024.stdout
@@ -0,0 +1,29 @@
+
+running 1 test
+test $DIR/dead-code-2024.rs - f (line 12) - compile ... FAILED
+
+failures:
+
+---- $DIR/dead-code-2024.rs - f (line 12) stdout ----
+error: trait `T` is never used
+  --> $DIR/dead-code-2024.rs:13:7
+   |
+LL | trait T { fn f(); }
+   |       ^
+   |
+note: the lint level is defined here
+  --> $DIR/dead-code-2024.rs:11:9
+   |
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
+   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`
+
+error: aborting due to 1 previous error
+
+Couldn't compile the test.
+
+failures:
+    $DIR/dead-code-2024.rs - f (line 12)
+
+test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
+
diff --git a/tests/rustdoc-ui/doctest/dead-code.rs b/tests/rustdoc-ui/doctest/dead-code.rs
new file mode 100644
index 00000000000..cb9b4c28f6c
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/dead-code.rs
@@ -0,0 +1,15 @@
+// This test ensures that the doctest will not use `#[allow(unused)]`.
+
+//@ compile-flags:--test
+//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
+//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
+//@ failure-status: 101
+
+#![doc(test(attr(allow(unused_variables), deny(warnings))))]
+
+/// Example
+///
+/// ```rust,no_run
+/// trait T { fn f(); }
+/// ```
+pub fn f() {}
diff --git a/tests/rustdoc-ui/doctest/dead-code.stdout b/tests/rustdoc-ui/doctest/dead-code.stdout
new file mode 100644
index 00000000000..38d15d5c1bc
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/dead-code.stdout
@@ -0,0 +1,29 @@
+
+running 1 test
+test $DIR/dead-code.rs - f (line 12) - compile ... FAILED
+
+failures:
+
+---- $DIR/dead-code.rs - f (line 12) stdout ----
+error: trait `T` is never used
+  --> $DIR/dead-code.rs:13:7
+   |
+LL | trait T { fn f(); }
+   |       ^
+   |
+note: the lint level is defined here
+  --> $DIR/dead-code.rs:11:9
+   |
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
+   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`
+
+error: aborting due to 1 previous error
+
+Couldn't compile the test.
+
+failures:
+    $DIR/dead-code.rs - f (line 12)
+
+test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
+