rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list

This commit is contained in:
León Orell Valerian Liehr 2023-06-24 23:39:35 +02:00
parent e0ba2d038d
commit d23c334707
No known key found for this signature in database
GPG Key ID: D17A07215F68E713
3 changed files with 15 additions and 1 deletions

View File

@ -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() {

View File

@ -0,0 +1,2 @@
<pre class="rust item-decl"><code>pub fn create(
) -&gt; <a class="struct" href="struct.Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000.html" title="struct decl_line_wrapping_empty_arg_list::Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000">Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000</a></code></pre>

View File

@ -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 {}
}