diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2023-06-24 23:39:35 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2023-06-24 23:39:35 +0200 |
| commit | d23c334707408057915a706351ac32b2db09d8c3 (patch) | |
| tree | 1359d70a41c8c40a060ae94a556afb718d762e4d | |
| parent | e0ba2d038db3afa968e13075b1d6eabd24339708 (diff) | |
| download | rust-d23c334707408057915a706351ac32b2db09d8c3.tar.gz rust-d23c334707408057915a706351ac32b2db09d8c3.zip | |
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list
| -rw-r--r-- | src/librustdoc/html/format.rs | 2 | ||||
| -rw-r--r-- | tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html | 2 | ||||
| -rw-r--r-- | tests/rustdoc/decl-line-wrapping-empty-arg-list.rs | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index b710311c858..b4aba2993c7 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1408,7 +1408,7 @@ impl clean::FnDecl { let amp = if f.alternate() { "&" } else { "&" }; write!(f, "(")?; - if let Some(n) = line_wrapping_indent { + if let Some(n) = line_wrapping_indent && !self.inputs.values.is_empty() { write!(f, "\n{}", Indent(n + 4))?; } for (i, input) in self.inputs.values.iter().enumerate() { diff --git a/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html b/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html new file mode 100644 index 00000000000..29c08c5bd5d --- /dev/null +++ b/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html @@ -0,0 +1,2 @@ +<pre class="rust item-decl"><code>pub fn create( +) -> <a class="struct" href="struct.Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000.html" title="struct decl_line_wrapping_empty_arg_list::Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000">Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000</a></code></pre> \ No newline at end of file diff --git a/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs new file mode 100644 index 00000000000..4cfb87496b4 --- /dev/null +++ b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs @@ -0,0 +1,12 @@ +// Ensure that we don't add an extra line containing nothing but whitespace in between the two +// parentheses of an empty argument list when line-wrapping a function declaration. + +// ignore-tidy-linelength + +pub struct Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000; + +// @has 'decl_line_wrapping_empty_arg_list/fn.create.html' +// @snapshot decl - '//pre[@class="rust item-decl"]' +pub fn create() -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000 { + loop {} +} |
