Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc should versionsort types in trait implementations #67046

Open
joshtriplett opened this issue Dec 5, 2019 · 3 comments
Open

rustdoc should versionsort types in trait implementations #67046

joshtriplett opened this issue Dec 5, 2019 · 3 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@joshtriplett
Copy link
Member

In reading the documentation for std::num::Wrapping, I noticed (in the left sidebar) a list of trait implementations for Wrapping of various numeric types, which appeared in this order:

  • Wrapping<i128>
  • Wrapping<i16>
  • Wrapping<i32>
  • Wrapping<i64>
  • Wrapping<i8>
  • Wrapping<isize>

This seems to sort numbers as strings, rather than by numeric value.

I would propose that everywhere rustdoc sorts identifiers of any kind, it should always use the versionsort algorithm, which sorts numbers by numeric value rather than as strings.

The commit at rust-lang/rustfmt#3764 contains an implementation of the versionsort comparison algorithm. I would suggest putting that (and its tests) into a common implementation for rustdoc and other future callers like rustfmt.

@joshtriplett joshtriplett added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 5, 2019
@jonas-schievink jonas-schievink added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Dec 6, 2019
@tanriol
Copy link
Contributor

tanriol commented Dec 25, 2019

@joshtriplett By common implementation do you mean something like "create a versionsort crate" or something different? I want to get back to that PR in a week or two and finally get it in.

@MichaelBurge
Copy link
Contributor

I notice that the impl<T> Default for [T; N] are out-of-order on this page:
https://doc.rust-lang.org/std/primitive.array.html

For example, I see the implementation for 1, then 15, then 0, then 4. It seems like that might be covered by this same issue.

@kennytm
Copy link
Member

kennytm commented Apr 20, 2020

@MichaelBurge the array issue is #40905/#42963, irrelevant to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants