summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-16 17:59:07 +0100
committerJosh Stone <jistone@redhat.com>2025-01-02 14:28:32 -0800
commitdc1a9f275c0caaf8c080c7cc6f9809a44db4ac2a (patch)
tree1571ebd1de048ec2bfd943803d88f1a1646a6486
parent32ee5bc6a33092f4b642631e425ddbeeec96fb08 (diff)
downloadrust-dc1a9f275c0caaf8c080c7cc6f9809a44db4ac2a.tar.gz
rust-dc1a9f275c0caaf8c080c7cc6f9809a44db4ac2a.zip
Remove unneeded handling of backlines in doctest attributes
(cherry picked from commit c367cc3ef5648d5695fdb795cc66edbff88b4ce9)
-rw-r--r--src/librustdoc/doctest/make.rs2
-rw-r--r--tests/rustdoc-ui/doctest/comment-in-attr-134221-2.rs15
-rw-r--r--tests/rustdoc-ui/doctest/comment-in-attr-134221-2.stdout31
3 files changed, 46 insertions, 2 deletions
diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs
index 66549afe5a1..a188bc8ebd9 100644
--- a/src/librustdoc/doctest/make.rs
+++ b/src/librustdoc/doctest/make.rs
@@ -537,8 +537,6 @@ fn handle_attr(mod_attr_pending: &mut String, source_info: &mut SourceInfo, edit
         push_to.push('\n');
         // If it's complete, then we can clear the pending content.
         mod_attr_pending.clear();
-    } else if mod_attr_pending.ends_with('\\') {
-        mod_attr_pending.push('n');
     } else {
         mod_attr_pending.push_str("\n");
     }
diff --git a/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.rs b/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.rs
new file mode 100644
index 00000000000..8cdd665ff69
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.rs
@@ -0,0 +1,15 @@
+//@ compile-flags:--test --test-args --test-threads=1
+//@ failure-status: 101
+//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
+//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
+//@ normalize-stdout-test: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL"
+
+//! ```
+#![doc = "#![all\
+ow(unused)]"]
+//! ```
+//!
+//! ```
+#![doc = r#"#![all\
+ow(unused)]"#]
+//! ```
diff --git a/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.stdout b/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.stdout
new file mode 100644
index 00000000000..0baff3df144
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/comment-in-attr-134221-2.stdout
@@ -0,0 +1,31 @@
+
+running 2 tests
+test $DIR/comment-in-attr-134221-2.rs - (line 11) ... FAILED
+test $DIR/comment-in-attr-134221-2.rs - (line 7) ... ok
+
+failures:
+
+---- $DIR/comment-in-attr-134221-2.rs - (line 11) stdout ----
+error: unknown start of token: \
+  --> $DIR/comment-in-attr-134221-2.rs:$LINE:$COL
+   |
+LL | #![all\
+   |       ^
+
+error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `ow`
+  --> $DIR/comment-in-attr-134221-2.rs:$LINE:$COL
+   |
+LL | #![all\
+   |       - expected one of `(`, `::`, `=`, `[`, `]`, or `{`
+LL | ow(unused)]
+   | ^^ unexpected token
+
+error: aborting due to 2 previous errors
+
+Couldn't compile the test.
+
+failures:
+    $DIR/comment-in-attr-134221-2.rs - (line 11)
+
+test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
+