Skip to content

Add basic splat support to rustdoc - #160882

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bushrat011899:rustdoc_splat_ellipsis
Aug 12, 2026
Merged

Add basic splat support to rustdoc#160882
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bushrat011899:rustdoc_splat_ellipsis

Conversation

@bushrat011899

@bushrat011899 bushrat011899 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tracking Issue: #153629

Description

While experimenting on variadic min/max, it was noted that the rustdoc output for a splatted function is less than ideal. Consider the below:

pub fn smallest<T: Ord>(#[rustc_splat] vals: impl TupleReduce<Item = T>) -> T {
    // ...
}

Currently, this is rendered in rustdoc as-is, obfuscating the variadic nature of the function:

image

Solution

I've updated the clean Parameter type to include whether it is splatted, and overridden the display of that parameter to replace the name with an ellipsis, similar to how fake variadic implementations are displayed.

image

Notes

  • No AI tooling of any kind was used during the creation of this PR.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, lolbinarycat, notriddle

@bushrat011899

Copy link
Copy Markdown
Contributor Author

@rustbot label F-splat

@rustbot rustbot added the F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 label Aug 10, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member

Please add a regression test in tests/rustdoc-html to ensure the "..." is correctly generated.

@bushrat011899
bushrat011899 force-pushed the rustdoc_splat_ellipsis branch from c649afa to 015e677 Compare August 11, 2026 09:31
@bushrat011899

Copy link
Copy Markdown
Contributor Author

Please add a regression test in tests/rustdoc-html to ensure the "..." is correctly generated.

Done! Sorry I should've included that initially, haven't contributed to rustdoc before! I swapped the with args to confirm the test fails as well.

Comment thread tests/rustdoc-html/splat-variadic-ellipsis.rs
@notriddle

Copy link
Copy Markdown
Contributor

r? @GuillaumeGomez

@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Requested reviewer is already assigned to this pull request.

Please choose another assignee.

Simply replace the parameter name and `#[rustc_splat]` attribute with an ellipsis. This preserves the type information of the splat while still documenting the variadic nature of the function.
@GuillaumeGomez

Copy link
Copy Markdown
Member

Looks good to me, thanks! r=me once CI pass.

@bors delegate+

@rust-bors

rust-bors Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

✌️ @bushrat011899, you can now approve this pull request!

If @GuillaumeGomez told you to "r=me" after making some further change, then please make that change and post @bors r=GuillaumeGomez.

View changes since this delegation.

@bushrat011899

Copy link
Copy Markdown
Contributor Author

@bors r=GuillaumeGomez

@rust-bors

rust-bors Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 413fdca has been approved by GuillaumeGomez

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 12, 2026
Rollup of 14 pull requests

Successful merges:

 - #160620 (Do not pass `-no-pie` on Windows)
 - #160731 (Arc: Remove unnecessary fmt::Display use for overflow assertion)
 - #160854 (Add -Zwasm-proc-macros flag)
 - #160868 (std: Adjust cfgs again for TLS on WASI)
 - #160882 (Add basic `splat` support to `rustdoc`)
 - #160894 (Allow running an arbitrary number of try jobs per PR)
 - #160790 (rustc-book: update sys-v abi link)
 - #160878 (Add rust_analyzer to check-cfg names)
 - #160909 (tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency)
 - #160920 (No longer mention the removed generic)
 - #160921 (rustdoc: Fix invalid CSS classes generated for notable items)
 - #160924 (split up `rustc_session`)
 - #160934 (Ensure TLS accesses don't call the global allocator through panic)
 - #160937 (Store the names of `Fn` trait parameters in the AST, fix rustfmt bug)
@rust-bors
rust-bors Bot merged commit 7718d14 into rust-lang:main Aug 12, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 12, 2026
rust-timer added a commit that referenced this pull request Aug 12, 2026
Rollup merge of #160882 - bushrat011899:rustdoc_splat_ellipsis, r=GuillaumeGomez

Add basic `splat` support to `rustdoc`

Tracking Issue: #153629

# Description

While experimenting on variadic `min`/`max`, it was [noted](rust-lang/libs-team#848 (comment)) that the `rustdoc` output for a splatted function is less than ideal. Consider the below:

```rust
pub fn smallest<T: Ord>(#[rustc_splat] vals: impl TupleReduce<Item = T>) -> T {
    // ...
}
```

Currently, this is rendered in `rustdoc` as-is, obfuscating the variadic nature of the function:

<img width="819" height="211" alt="image" src="https://github.com/user-attachments/assets/68569fe6-7285-49f8-aae9-ddad0b10649c" />

## Solution

I've updated the clean `Parameter` type to include whether it is splatted, and overridden the display of that parameter to replace the name with an ellipsis, similar to how fake variadic implementations are displayed.

<img width="820" height="211" alt="image" src="https://github.com/user-attachments/assets/58a27245-cc38-44e6-908a-f67991bcdb64" />

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants