Rollup merge of #98806 - GuillaumeGomez:decl-trailing-whitespace, r=notriddle
Fix long declaration trailing whitespace Fixes https://github.com/rust-lang/rust/issues/98803. Interestingly enough, it even simplifies the code a bit. r? `@notriddle`
This commit is contained in:
commit
f236b6853a
4 changed files with 42 additions and 9 deletions
|
@ -1283,10 +1283,6 @@ impl clean::FnDecl {
|
|||
let mut args = Buffer::html();
|
||||
let mut args_plain = Buffer::new();
|
||||
for (i, input) in self.inputs.values.iter().enumerate() {
|
||||
if i == 0 {
|
||||
args.push_str("<br>");
|
||||
}
|
||||
|
||||
if let Some(selfty) = input.to_self() {
|
||||
match selfty {
|
||||
clean::SelfValue => {
|
||||
|
@ -1312,8 +1308,7 @@ impl clean::FnDecl {
|
|||
}
|
||||
} else {
|
||||
if i > 0 {
|
||||
args.push_str(" <br>");
|
||||
args_plain.push_str(" ");
|
||||
args.push_str("<br>");
|
||||
}
|
||||
if input.is_const {
|
||||
args.push_str("const ");
|
||||
|
@ -1360,13 +1355,14 @@ impl clean::FnDecl {
|
|||
let full_pad = format!("<br>{}", " ".repeat(indent + 4));
|
||||
let close_pad = format!("<br>{}", " ".repeat(indent));
|
||||
format!(
|
||||
"({args}{close}){arrow}",
|
||||
"({pad}{args}{close}){arrow}",
|
||||
pad = if self.inputs.values.is_empty() { "" } else { &full_pad },
|
||||
args = args.replace("<br>", &full_pad),
|
||||
close = close_pad,
|
||||
arrow = arrow
|
||||
)
|
||||
} else {
|
||||
format!("({args}){arrow}", args = args.replace("<br>", ""), arrow = arrow)
|
||||
format!("({args}){arrow}", args = args.replace("<br>", " "), arrow = arrow)
|
||||
};
|
||||
|
||||
if f.alternate() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// @has assoc_types/trait.Index.html
|
||||
pub trait Index<I: ?Sized> {
|
||||
// @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized'
|
||||
// @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized'
|
||||
type Output: ?Sized;
|
||||
// @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \
|
||||
// "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<code>pub trait Write {
|
||||
fn <a href="#tymethod.poll_write" class="fnname">poll_write</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        buf: &mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]<br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fnname">poll_flush</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fnname">poll_close</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
|
||||
fn <a href="#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        bufs: &[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]<br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>> { ... }
|
||||
}</code>
|
30
src/test/rustdoc/decl-trailing-whitespace.rs
Normal file
30
src/test/rustdoc/decl-trailing-whitespace.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Regression test for <https://github.com/rust-lang/rust/issues/98803>.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
pub struct Error;
|
||||
|
||||
// @has 'foo/trait.Write.html'
|
||||
|
||||
pub trait Write {
|
||||
// @snapshot 'declaration' - '//*[@class="docblock item-decl"]//code'
|
||||
fn poll_write(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
buf: &mut [usize]
|
||||
) -> Option<Result<usize, Error>>;
|
||||
fn poll_flush(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>
|
||||
) -> Option<Result<(), Error>>;
|
||||
fn poll_close(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
) -> Option<Result<(), Error>>;
|
||||
|
||||
fn poll_write_vectored(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
bufs: &[usize]
|
||||
) -> Option<Result<usize, Error>> {}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue