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: Implementations on Foreign Types are not sorted in sidebar #78694

Open
camelid opened this issue Nov 3, 2020 · 3 comments
Open

rustdoc: Implementations on Foreign Types are not sorted in sidebar #78694

camelid opened this issue Nov 3, 2020 · 3 comments
Labels
A-traits Area: Trait system C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Nov 3, 2020

See in the docs for the num crate:

image

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-traits Area: Trait system C-bug Category: This is a bug. labels Nov 3, 2020
@camelid camelid changed the title rustdoc: Implementations on Foreign Types are out-of-order in sidebar rustdoc: Implementations on Foreign Types are not sorted in sidebar Nov 3, 2020
@njasm
Copy link
Contributor

njasm commented Mar 20, 2021

I had a quick peek and it looks like the code is in fact already sorting that list, but due to the nature of the sorting algorithm plus the types in the list its a bit unfortunate and that's why we get the Wrapping<T> at the first spot.

If I'm understanding the issue reported correctly we would be able to fix it by first lower-casing the types before compare them and only for sorting

the current code is here:

if !res.is_empty() {
res.sort();
buf.push_str(

and something along the lines would work:

res.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase()));

But not sure if it's desirable to do it this way, what you think?

playground example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=682d5ee377353bfa87d62951e59e550f

@camelid
Copy link
Member Author

camelid commented Mar 20, 2021

Hmm, I think Wrapping<T> being first is part of what made me think it was a bug, but also that u64 comes before u8. I guess u64 coming first makes sense because it starts with u6 which is "less than" u8, but intuitively it feels weird because I think of u8 as being smaller.

@njasm
Copy link
Contributor

njasm commented Mar 20, 2021

yap, completely understandable, had the same feeling when saw your print-screen :)
Nonetheless I'm happy to submit a PR if it's decided that we should do something here. (don't know if wanna ping someone else for some input)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. 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

3 participants