Add basic splat support to rustdoc - #160882
Conversation
|
rustbot has assigned @GuillaumeGomez. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rustbot label F-splat |
|
Please add a regression test in |
c649afa to
015e677
Compare
Done! Sorry I should've included that initially, haven't contributed to |
|
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.
015e677 to
413fdca
Compare
|
Looks good to me, thanks! r=me once CI pass. @bors delegate+ |
|
✌️ @bushrat011899, you can now approve this pull request! If @GuillaumeGomez told you to " |
|
@bors r=GuillaumeGomez |
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)
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.
Tracking Issue: #153629
Description
While experimenting on variadic
min/max, it was noted that therustdocoutput for a splatted function is less than ideal. Consider the below:Currently, this is rendered in
rustdocas-is, obfuscating the variadic nature of the function:Solution
I've updated the clean
Parametertype 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.Notes