Skip to content

rustdoc should versionsort types in trait implementations #67046

Open
@joshtriplett

Description

@joshtriplett

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions