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

~const makes rustdoc show duplicate bounds #104886

Open
GoldsteinE opened this issue Nov 25, 2022 · 5 comments
Open

~const makes rustdoc show duplicate bounds #104886

GoldsteinE opened this issue Nov 25, 2022 · 5 comments
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

@GoldsteinE
Copy link
Contributor

GoldsteinE commented Nov 25, 2022

For example, see documentation for the Ord trait from the standard library:

pub trait Ord: Eq + PartialOrd<Self> {
    fn cmp(&self, other: &Self) -> Ordering;

    fn max(self, other: Self) -> Self { ... }
    fn min(self, other: Self) -> Self { ... }
    fn clamp(self, min: Self, max: Self) -> Self
    where
        Self: PartialOrd<Self>,
        //    ^^^^^^^^^^^^^^^^ - this bound is already specified above
    { ... }
}

This is slightly confusing IMO.

Related to #91187

@GoldsteinE GoldsteinE added the C-bug Category: This is a bug. label Nov 25, 2022
@fmease
Copy link
Member

fmease commented Nov 25, 2022

This happens for both locally and externally defined bindings (it's not a reexports issue).
@rustbot label T-rustdoc
@rustbot claim

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 25, 2022
@fmease
Copy link
Member

fmease commented Nov 25, 2022

If anyone would like to work on this, for the local case one solution is – in clean_maybe_renamed_item in branch ItemKind::Trait – to pass the generics & the bounds of the trait to clean_trait_item and to deduplicate the bounds in respect to the maybe-const generics of the respective associated function.

Actually, this is a can on worms: Rustdoc doesn't dedupe normal bounds either (for local / HIR definitions), e.g.

pub trait Tr { fn f() where Self: Eq, Self: Eq; } // `Self: Eq` not deduped
pub trait Super {}
pub trait Sub: Super { fn f() where Self: Super; } // `Self: Super` not deduped

Unassigning myself since I'm prioritizing a rustdoc PR I've been working on for some time.

@fmease fmease removed their assignment Nov 25, 2022
@GuillaumeGomez
Copy link
Member

I'm taking a look then.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 3, 2022
…cates, r=notriddle

Merge generics and where predicates and prevent duplicates in where predicates

Part of rust-lang#104886 (I didn't include bounds from parent trait yet as I think the PR is already big enough).

Also we'll need to run a perf check.

cc `@fmease` since you worked a bit on this.
r? `@notriddle`
@GoldsteinE
Copy link
Contributor Author

AFAIU ~const doesn’t exist now, so this could be closed?

@GuillaumeGomez
Copy link
Member

The underlying issue is still there so keeping it open (you can see it in #105392).

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

No branches or pull requests

4 participants