Skip to content

List of trait implementations should be version-sorted #135098

Open
@joshtriplett

Description

@joshtriplett

Code

// tests/ui/suggestions/issue-71394-no-from-impl.rs

Current output

error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied
  --> $DIR/issue-71394-no-from-impl.rs:8:25
   |
LL |     let _: &[i8] = data.into();
   |                         ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]`
   |
   = help: the following other types implement trait `From<T>`:
             `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`
             `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>`
             `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>`
             `[T; 1]` implements `From<(T,)>`
             `[T; 2]` implements `From<(T, T)>`
             `[T; 3]` implements `From<(T, T, T)>`
[...]

Desired output

error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied
  --> $DIR/issue-71394-no-from-impl.rs:8:25
   |
LL |     let _: &[i8] = data.into();
   |                         ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]`
   |
   = help: the following other types implement trait `From<T>`:
             `[T; 1]` implements `From<(T,)>`
             `[T; 2]` implements `From<(T, T)>`
             `[T; 3]` implements `From<(T, T, T)>`
[...]
             `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`
             `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>`
             `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>`
[...]

Rationale and extra context

The existing sorting displays 10, 11, 12, before it displays 1, 2, 3. Lower numbers should be sorted before higher numbers. In addition to sorting in a more semantically correct fashion, this would also present the user with less complex possibilities first.

Other cases

Rust Version

Git commit 7349f6b50359fd1f11738765b8deec5ee02d8710

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler 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