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

List of trait implementations should be version-sorted #135098

Open
joshtriplett opened this issue Jan 4, 2025 · 0 comments
Open

List of trait implementations should be version-sorted #135098

joshtriplett opened this issue Jan 4, 2025 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@joshtriplett
Copy link
Member

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

@joshtriplett joshtriplett added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 4, 2025
@fmease fmease added the D-papercut Diagnostics: An error or lint that needs small tweaks. label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants