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

docs for Traits get duplicated because of different types #24558

Open
mdinger opened this issue Apr 18, 2015 · 4 comments
Open

docs for Traits get duplicated because of different types #24558

mdinger opened this issue Apr 18, 2015 · 4 comments
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) A-traits Area: Trait system C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@mdinger
Copy link
Contributor

mdinger commented Apr 18, 2015

f32 for example essentially supports traits like Add which have multiple copies which aren't duplicates but seem repetitive because they are essentially very similar:

Currently:

impl Add<f32> for f32
    type Output = f32

    fn add(self, other: f32) -> f32

impl<'a> Add<f32> for &'a f32
    type Output = f32::Output

    fn add(self, other: f32) -> f32::Output

impl<'a> Add<&'a f32> for f32
    type Output = f32::Output

    fn add(self, other: &'a f32) -> f32::Output

impl<'a, 'b> Add<&'a f32> for &'b f32
    type Output = f32::Output

    fn add(self, other: &'a f32) -> f32::Output

It would be very nice if these could be combined so the repetition is less drastic. I've only come up with 2 options so far but maybe there are more.

Option A:

This is tricky to improve because all are different. One course would be to collapse all but the last by default which would make it look like the following block. This would also aid #21660 . This makes all the types clear but only shows one method because all the methods will be the same.

+impl Add<f32> for f32
+impl<'a> Add<f32> for &'a f32
+impl<'a> Add<&'a f32> for f32
-impl<'a, 'b> Add<&'a f32> for &'b f32
    type Output = f32::Output

    fn add(self, other: &'a f32) -> f32::Output

Option B:

Use some type of shorthand to include all options (like globbing). This should expand to specifics if desired I suppose.

impl<.*> Add<.* f32> for .* f32
    type Output = f32.*

    fn add(self, other: .* f32) -> f32::Output

Option A looks the most practical. I'm trying to think of a better way to include only one but still allow the specifics to be examined but haven't come up with any better ideas.

@mdinger
Copy link
Contributor Author

mdinger commented Apr 18, 2015

This may interfere with #24558 if it was ever implemented though it may be a better idea.

cc @gankro

@Gankra
Copy link
Contributor

Gankra commented Apr 18, 2015

cc @alexcrichton

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 18, 2015
@steveklabnik steveklabnik changed the title Traits get duplicated because of different types docs for Traits get duplicated because of different types Apr 18, 2015
@steveklabnik
Copy link
Member

Triage: no changes. I'm slightly wary of reducing this duplication, because well, they are in fact different types, but option A doesn't seem too bad...

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-bug Category: This is a bug. labels Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: i feel the same as my last comment.

@ehuss ehuss removed the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label Jan 18, 2022
@fmease fmease added A-traits Area: Trait system A-rustdoc-ui Area: rustdoc UI (generated HTML) labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) A-traits Area: Trait system C-feature-request Category: A feature request, i.e: not implemented / a PR. 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

6 participants