about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-03-25 20:34:48 -0400
committerGitHub <noreply@github.com>2025-03-25 20:34:48 -0400
commitfc8fc051b6ae165ef0959ed40e197e42bcf05b75 (patch)
tree072ea36ee9070ddcdf73aae2d25533867f80f4f1
parent0d61b83f59b2cc44c9098bba575ae968c9d3a1ca (diff)
parent90c541d637c0857c6d5b1c3bf835e2f02f7175a9 (diff)
downloadrust-fc8fc051b6ae165ef0959ed40e197e42bcf05b75.tar.gz
rust-fc8fc051b6ae165ef0959ed40e197e42bcf05b75.zip
Rollup merge of #138877 - TaKO8Ki:enable-per-target-ignores-for-doctests, r=notriddle
Ignore doctests only in specified targets

Quick fix for #138863

FIxes  #138863

cc `@yotamofek` `@notriddle`
-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
+