Skip to content

Commit 32995d8

Browse files
authored
Rollup merge of #113013 - fmease:rustdoc-decl-line-wrapping-slim-arg-list, r=camelid
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list Fixes bevyengine/bevy#8898 (comment): ![Screenshot 2023-06-24 at 23-42-53 any_with_component in bevy_ecs schedule common_conditions - Rust](https://github.com/rust-lang/rust/assets/14913065/4646eba6-b186-4d78-96d9-aad716a4ef5d) It now prints as shown below (which conforms to the style guide): ```rs pub fn any_with_component<T: Component>( ) -> impl FnMut(Query<'_, '_, (), With<T>>) -> bool + Clone ``` The bug was introduced in #109011.
2 parents aa8a885 + d23c334 commit 32995d8

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 { "&amp;" };
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)