diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 5aab4199d43b1..0d547a6a0d92d 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 0000000000000..3dea7099b4be3
--- /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 0000000000000..fe7282144dd8b
--- /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
+