about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2025-03-24 13:56:45 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2025-03-25 15:39:41 +0900
commit90c541d637c0857c6d5b1c3bf835e2f02f7175a9 (patch)
tree166d674083809af5cfbd37a375ebef35ee122c53
parentf08d5c01e69436891ff1c181385d0e078a8482ec (diff)
downloadrust-90c541d637c0857c6d5b1c3bf835e2f02f7175a9.tar.gz
rust-90c541d637c0857c6d5b1c3bf835e2f02f7175a9.zip
ignore doctests only in specified targets
add necessary lines

fix ui test error
-rw-r--r--src/librustdoc/html/markdown.rs9
-rw-r--r--tests/rustdoc-ui/doctest/per-target-ignores.rs14
-rw-r--r--tests/rustdoc-ui/doctest/per-target-ignores.stdout6
3 files changed, 25 insertions, 4 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 5aab4199d43..0d547a6a0d9 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -1201,11 +1201,12 @@ impl LangString {
                         seen_rust_tags = !seen_other_tags;
                     }
                     LangStringToken::LangToken(x)
-                        if let Some(ignore) = x.strip_prefix("ignore-")
-                            && enable_per_target_ignores =>
+                        if let Some(ignore) = x.strip_prefix("ignore-") =>
                     {
-                        ignores.push(ignore.to_owned());
-                        seen_rust_tags = !seen_other_tags;
+                        if enable_per_target_ignores {
+                            ignores.push(ignore.to_owned());
+                            seen_rust_tags = !seen_other_tags;
+                        }
                     }
                     LangStringToken::LangToken("rust") => {
                         data.rust = true;
diff --git a/tests/rustdoc-ui/doctest/per-target-ignores.rs b/tests/rustdoc-ui/doctest/per-target-ignores.rs
new file mode 100644
index 00000000000..3dea7099b4b
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/per-target-ignores.rs
@@ -0,0 +1,14 @@
+//@ only-aarch64
+//@ compile-flags:--test
+//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
+//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
+//@ check-pass
+
+///```ignore-x86_64
+/// assert!(cfg!(not(target_arch = "x86_64")));
+///```
+pub fn foo() -> u8 {
+    4
+}
+
+fn main() {}
diff --git a/tests/rustdoc-ui/doctest/per-target-ignores.stdout b/tests/rustdoc-ui/doctest/per-target-ignores.stdout
new file mode 100644
index 00000000000..fe7282144dd
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/per-target-ignores.stdout
@@ -0,0 +1,6 @@
+
+running 1 test
+test $DIR/per-target-ignores.rs - foo (line 7) ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
+