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

PartialOrd docs for generic tuples show the where clauses in a seemingly random order #88809

Closed
jruderman opened this issue Sep 10, 2021 · 2 comments · Fixed by #89098
Closed
Assignees
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

On https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html:

The docs for PartialOrd on tuples show the where clauses in a weird order, obscuring the fact that the last element of the tuple is allowed to be unsized.

impl<A, B, C, D, E> PartialOrd<(A, B, C, D, E)> for (A, B, C, D, E) where
    C: PartialOrd<C> + PartialEq<C>,
    E: PartialOrd<E> + PartialEq<E> + ?Sized,
    B: PartialOrd<B> + PartialEq<B>,
    A: PartialOrd<A> + PartialEq<A>,
    D: PartialOrd<D> + PartialEq<D>, 
@jruderman jruderman added the C-bug Category: This is a bug. label Sep 10, 2021
@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 17, 2021
@GuillaumeGomez GuillaumeGomez self-assigned this Sep 19, 2021
@GuillaumeGomez
Copy link
Member

Found the issue: it's because we use a BTreeMap using Symbol as key. Problem being that Symbol is making integer based comparison and not string based, hence the current result. Trying to write a test now.

@camelid
Copy link
Member

camelid commented Sep 22, 2021

Note that this bug is specific to cross-crate re-exports; the same documentation in core renders correctly. There also seems to be another "bug" related to cross-crate re-exports and where clauses: In the core docs, the impl looks like this (which is how it's actually written in the source):

image

But in the std docs, the impl looks like this, with all of the bounds expressed as where clauses:

image

I think the re-exported version is actually better, because it's easier to read, but they should at least be consistent.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 29, 2021
…r=camelid

Fix generics where bounds order

Fixes rust-lang#88809.

Like said on the above issue, the issue is that we were expecting `Symbol` comparisons to be string-based but they are integer-based (because `Symbol` is an integer), messing up the bounds order. To fix it, I simply stored into a `FxIndexMap` instead.

r? `@jyn514`
@bors bors closed this as completed in 7c23ff2 Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

3 participants