Skip to content

Commit 1d90bec

Browse files
authored
Unrolled build for rust-lang#125946
Rollup merge of rust-lang#125946 - Sergi-Ferrez:master, r=notriddle,fmease Include trailing commas in wrapped function declarations [RustDoc] Fixes rust-lang#125901.
2 parents 23e040a + 744dc8c commit 1d90bec

7 files changed

+18
-16
lines changed

src/librustdoc/html/format.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1438,13 +1438,9 @@ impl clean::FnDecl {
14381438
{
14391439
write!(f, "\n{}", Indent(n + 4))?;
14401440
}
1441+
1442+
let last_input_index = self.inputs.values.len().checked_sub(1);
14411443
for (i, input) in self.inputs.values.iter().enumerate() {
1442-
if i > 0 {
1443-
match line_wrapping_indent {
1444-
None => write!(f, ", ")?,
1445-
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
1446-
};
1447-
}
14481444
if let Some(selfty) = input.to_self() {
14491445
match selfty {
14501446
clean::SelfValue => {
@@ -1477,18 +1473,25 @@ impl clean::FnDecl {
14771473
write!(f, "{}: ", input.name)?;
14781474
input.type_.print(cx).fmt(f)?;
14791475
}
1476+
match (line_wrapping_indent, last_input_index) {
1477+
(_, None) => (),
1478+
(None, Some(last_i)) if i != last_i => write!(f, ", ")?,
1479+
(None, Some(_)) => (),
1480+
(Some(n), Some(last_i)) if i != last_i => write!(f, ",\n{}", Indent(n + 4))?,
1481+
(Some(_), Some(_)) => write!(f, ",\n")?,
1482+
}
14801483
}
14811484

14821485
if self.c_variadic {
14831486
match line_wrapping_indent {
14841487
None => write!(f, ", ...")?,
1485-
Some(n) => write!(f, "\n{}...", Indent(n + 4))?,
1488+
Some(n) => write!(f, "{}...\n", Indent(n + 4))?,
14861489
};
14871490
}
14881491

14891492
match line_wrapping_indent {
14901493
None => write!(f, ")")?,
1491-
Some(n) => write!(f, "\n{})", Indent(n))?,
1494+
Some(n) => write!(f, "{})", Indent(n))?,
14921495
};
14931496

14941497
self.print_output(cx).fmt(f)

tests/rustdoc/async-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct AsyncFdReadyGuard<'a, T> { x: &'a T }
7979

8080
impl Foo {
8181
// @has async_fn/struct.Foo.html
82-
// @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar ) -> impl Iterator<Item = &usize>'
82+
// @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator<Item = &usize>'
8383
pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> {
8484
[0].iter()
8585
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
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>
1+
<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>

tests/rustdoc/decl-trailing-whitespace.declaration.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fn <a href="#tymethod.poll_write" class="fn">poll_write</a>(
44
self,
55
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
6-
buf: &amp;mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]
6+
buf: &amp;mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>],
77
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
88
<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fn">poll_flush</a>(self, cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
99
<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fn">poll_close</a>(self, cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
@@ -12,6 +12,6 @@
1212
fn <a href="#method.poll_write_vectored" class="fn">poll_write_vectored</a>(
1313
self,
1414
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
15-
bufs: &amp;[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]
15+
bufs: &amp;[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>],
1616
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt; { ... }
1717
}</code>

tests/rustdoc/inline_cross/impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use impl_trait_aux::func;
1111
// @has impl_trait/fn.func2.html
1212
// @has - '//pre[@class="rust item-decl"]' "func2<T>("
1313
// @has - '//pre[@class="rust item-decl"]' "_x: impl Deref<Target = Option<T>> + Iterator<Item = T>,"
14-
// @has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8> )"
14+
// @has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8>, )"
1515
// @!has - '//pre[@class="rust item-decl"]' 'where'
1616
pub use impl_trait_aux::func2;
1717

tests/rustdoc/line-breaks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ops::Add;
66
// @matches foo/fn.function_with_a_really_long_name.html '//*[@class="rust item-decl"]//code' "\
77
// function_with_a_really_long_name\(\n\
88
// \ parameter_one: i32,\n\
9-
// \ parameter_two: i32\n\
9+
// \ parameter_two: i32,\n\
1010
// \) -> Option<i32>$"
1111
pub fn function_with_a_really_long_name(parameter_one: i32, parameter_two: i32) -> Option<i32> {
1212
Some(parameter_one + parameter_two)

tests/rustdoc/reexports-priv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub mod outer {
9898
pub use reexports::foo;
9999
// @has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()'
100100
pub(crate) use reexports::foo_crate;
101-
// @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super( )'
101+
// @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()'
102102
pub(super) use::reexports::foo_super;
103103
// @!has 'foo/outer/inner/fn.foo_self.html'
104104
pub(self) use reexports::foo_self;

0 commit comments

Comments
 (0)