Skip to content

[rustdoc] Implementors section of Sync (and other similar traits) should separate implementors and !implementors #51129

Closed

Description

@alex

image

The !Sync implementations and the Sync implementations really ought to be separated apart, otherwise it makes it harder to skim.

https://doc.rust-lang.org/stable/std/marker/trait.Sync.html#implementors

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Jun 14, 2018
  2. QuietMisdreavus commented on Jun 14, 2018

    @QuietMisdreavus
    Contributor

    Would it work out if the impls were just sorted apart, rather than giving an entirely new section heading to "negative impls"? That might be easier to implement.

  3. alex commented on Jun 14, 2018

    @alex
    MemberAuthor

    @QuietMisdreavus yes, just sorted seperately would be A+

  4. QuietMisdreavus commented on Jun 14, 2018

    @QuietMisdreavus
    Contributor

    Excellent!

    Some mentoring instructions:

    The code that displays all these impls is right here:

    let (local, foreign) = implementors.iter()
    .partition::<Vec<_>, _>(|i| i.inner_impl().for_.def_id()
    .map_or(true, |d| cache.paths.contains_key(&d)));
    let (synthetic, concrete) = local.iter()
    .partition::<Vec<_>, _>(|i| i.inner_impl().synthetic);
    if !foreign.is_empty() {
    write!(w, "
    <h2 id='foreign-impls' class='small-section-header'>
    Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
    </h2>
    ")?;
    for implementor in foreign {
    let assoc_link = AssocItemLink::GotoSource(
    implementor.impl_item.def_id, &implementor.inner_impl().provided_trait_methods
    );
    render_impl(w, cx, &implementor, assoc_link,
    RenderMode::Normal, implementor.impl_item.stable_since(), false)?;
    }
    }
    write!(w, "{}", impl_header)?;
    for implementor in concrete {
    render_implementor(cx, implementor, w, &implementor_dups)?;
    }
    write!(w, "</ul>")?;
    if t.auto {
    write!(w, "{}", synthetic_impl_header)?;
    for implementor in synthetic {
    synthetic_types.extend(
    collect_paths_for_type(implementor.inner_impl().for_.clone())
    );
    render_implementor(cx, implementor, w, &implementor_dups)?;
    }
    write!(w, "</ul>")?;
    }

    All the collections it's partitioning at the start of that contain render::Impl structs, and you can see whether it's a !impl by checking the "polarity" of the clean::Impl it contains. You can check implementor.impl_item().polarity and compare it against Some(clean::ImplPolarity::Negative), and sort these collections before iterating (or partition them farther, heh) to print one before the other. Given the nature of Send and Sync, i think it would be better to print the negative impls before the positive ones.

  5. added
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    on Jun 14, 2018
  6. SLaabsDev commented on Jun 22, 2018

    @SLaabsDev

    I can start on this one

  7. QuietMisdreavus commented on Jun 23, 2018

    @QuietMisdreavus
    Contributor

    @SLaabsDev Thanks! Were the instructions i gave a good start? If you need any help, please ask me!

  8. SLaabsDev commented on Jun 26, 2018

    @SLaabsDev

    @QuietMisdreavus Yes, the instructions were very helpful! I have it to a point where it is sorting with negative implementors showing first. One question I have is outside of the polarity does the order of implementors need to be preserved?

  9. QuietMisdreavus commented on Jul 3, 2018

    @QuietMisdreavus
    Contributor

    @SLaabsDev That's probably best addressed by all of @rust-lang/docs but what i would say is "don't worry about it", since we currently don't do a very good job of keeping that ordering in the first place. This could be a good place to enforce a good ordering, but you don't have to do that in your PR. (If you asking to choose between sort and sort_unstable, go ahead and pick sort just so we don't disrupt the current ordering too much.)

  10. self-assigned this
    on Nov 26, 2020
  11. changed the title [-][docs] Implementors section of Sync (and other similar traits) should separate implementors and !implementors[/-] [+][rustdoc] Implementors section of Sync (and other similar traits) should separate implementors and !implementors[/+] on Nov 26, 2020
  12. removed their assignment
    on Jun 29, 2021
  13. hkBst commented on Feb 7, 2025

    @hkBst
    Member

    Any update here?

  14. GuillaumeGomez commented on Feb 7, 2025

    @GuillaumeGomez
    Member

    Still in progress.

  15. GuillaumeGomez commented on Jun 11, 2025

    @GuillaumeGomez
    Member

    Opened #142380.

  16. alex commented on Jun 11, 2025

    @alex
    MemberAuthor

    Thanks for looking at this after all these years!

  17. GuillaumeGomez commented on Jun 11, 2025

    @GuillaumeGomez
    Member

    If you're patient enough, everything (hopefully) will be done at some point. 😆

  18. added a commit that references this issue on Dec 11, 2025
    78dddc4
  19. added a commit that references this issue on Dec 11, 2025
    e408376
  20. added a commit that references this issue on Dec 11, 2025
    52cadc0
  21. added a commit that references this issue on Dec 12, 2025
    79f3d89
  22. added a commit that references this issue on Dec 13, 2025
    50608f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions