Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3332,6 +3332,16 @@ fn render_attributes(w: &mut Buffer, it: &clean::Item, top: bool) {
None
}
})
// This whole `map` is to correctly print the "cut" strings in attributes arguments like:
//
// #[x = "string with \
// backline"]
.map(|a| {
a.split("\\\n").fold(String::new(), |mut acc, a| {
acc.push_str(a.trim_start());
acc
})
})
.join("\n");

if !attrs.is_empty() {
Expand Down
14 changes: 14 additions & 0 deletions src/test/rustdoc/attributes-backline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![crate_name = "foo"]

// @has 'foo/struct.Fly.html'
// @has - '//h4[@id="method.drosophilae"]//span[@class="docblock attributes"]' ''
// @has - '//h4[@id="method.drosophilae"]//span[@class="docblock attributes"]' \
// 'Just a sentence with a backline in the middle'
// @!has - '//h4[@id="method.drosophilae"]//span[@class="doblock attributes"]' '\\'
pub struct Fly;

impl Fly {
#[must_use = "Just a sentence with a backline in \
the middle"]
pub fn drosophilae(&self) {}
}