Skip to content

Commit d23c334

Browse files
committed
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list
1 parent e0ba2d0 commit d23c334

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ impl clean::FnDecl {
14081408
let amp = if f.alternate() { "&" } else { "&" };
14091409

14101410
write!(f, "(")?;
1411-
if let Some(n) = line_wrapping_indent {
1411+
if let Some(n) = line_wrapping_indent && !self.inputs.values.is_empty() {
14121412
write!(f, "\n{}", Indent(n + 4))?;
14131413
}
14141414
for (i, input) in self.inputs.values.iter().enumerate() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<pre class="rust item-decl"><code>pub fn create(
2+
) -&gt; <a class="struct" href="struct.Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000.html" title="struct decl_line_wrapping_empty_arg_list::Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000">Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000</a></code></pre>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Ensure that we don't add an extra line containing nothing but whitespace in between the two
2+
// parentheses of an empty argument list when line-wrapping a function declaration.
3+
4+
// ignore-tidy-linelength
5+
6+
pub struct Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000;
7+
8+
// @has 'decl_line_wrapping_empty_arg_list/fn.create.html'
9+
// @snapshot decl - '//pre[@class="rust item-decl"]'
10+
pub fn create() -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000 {
11+
loop {}
12+
}

0 commit comments

Comments
 (0)