about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-03 23:21:43 +0200
committerGitHub <noreply@github.com>2022-04-03 23:21:43 +0200
commit5925c8ee7987fdd0c07c1d1bd179c6b2f466e9fb (patch)
tree168c5b0859efef703e78104f1b41b93a5df85043
parent19a90c70180d5ba9d825b66773ce0980d7804a36 (diff)
parent995513c92986713a3a8260d8944e5ed82755347b (diff)
downloadrust-5925c8ee7987fdd0c07c1d1bd179c6b2f466e9fb.tar.gz
rust-5925c8ee7987fdd0c07c1d1bd179c6b2f466e9fb.zip
Rollup merge of #95613 - GuillaumeGomez:fix-rustdoc-attr-display, r=notriddle
Fix rustdoc attribute display

Fixes #81482.

r? `@notriddle`
-rw-r--r--src/librustdoc/html/render/mod.rs7
-rw-r--r--src/test/rustdoc/attribute-rendering.rs7
2 files changed, 13 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 0cfe12abcd1..ac07547de70 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1002,7 +1002,12 @@ fn attributes(it: &clean::Item) -> Vec<String> {
         .iter()
         .filter_map(|attr| {
             if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
-                Some(pprust::attribute_to_string(attr).replace('\n', "").replace("  ", " "))
+                Some(
+                    pprust::attribute_to_string(attr)
+                        .replace("\\\n", "")
+                        .replace('\n', "")
+                        .replace("  ", " "),
+                )
             } else {
                 None
             }
diff --git a/src/test/rustdoc/attribute-rendering.rs b/src/test/rustdoc/attribute-rendering.rs
new file mode 100644
index 00000000000..6777871846e
--- /dev/null
+++ b/src/test/rustdoc/attribute-rendering.rs
@@ -0,0 +1,7 @@
+#![crate_name = "foo"]
+
+// @has 'foo/fn.f.html'
+// @has - //*[@'class="docblock item-decl"]' '#[export_name = "f"] pub fn f()'
+#[export_name = "\
+f"]
+pub fn f() {}