rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.85k stars 12.66k forks source link

rustdoc should versionsort types in trait implementations #67046

Open joshtriplett opened 4 years ago

joshtriplett commented 4 years ago

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:

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 https://github.com/rust-lang/rustfmt/pull/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.

tanriol commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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