From 78698dd0fbdf7772fca2b203ae262de00e268f37 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Apr 2022 13:40:43 +0200 Subject: [PATCH 1/2] Fix display of attributes in rustdoc --- src/librustdoc/html/render/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 93b33b0d60912..42d818e20a8ee 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 { .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 } From 995513c92986713a3a8260d8944e5ed82755347b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Apr 2022 13:41:12 +0200 Subject: [PATCH 2/2] Add test for attribute display in rustdoc --- src/test/rustdoc/attribute-rendering.rs | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/test/rustdoc/attribute-rendering.rs diff --git a/src/test/rustdoc/attribute-rendering.rs b/src/test/rustdoc/attribute-rendering.rs new file mode 100644 index 0000000000000..6777871846e2d --- /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() {}