Skip to content

Re-exported types have confusingly different documentation #44306

Description

@dtolnay

Re-exported types seem to have more confusing documentation than the original type. I noticed this while reviewing rayon::Configuration which is re-exported from rayon-core.


original/src/lib.rs

pub trait T {}
pub struct S;

impl S {
    pub fn f<F>(_: F, _: Box<T>) -> Self
        where F: Fn()
    {
        unimplemented!()
    }
}

This is documented basically like what I wrote, which is what I would expect:

selection_063


src/lib.rs

extern crate original;
pub use original::S;

This is documented with a couple changes, all of which are technically correct but unexpected.

  • The Box<T> is now Box<T + 'static>.
  • The return type has changed from Self to S.
  • The where clause gives an explicit -> (). fixed as of 1.50
  • The parameter name placeholders are gone (which I prefer, but it is a difference).

selection_062

I am using rustc 1.22.0-nightly (f861b6e 2017-09-01).

@GuillaumeGomez

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Sep 4, 2017
  2. GuillaumeGomez commented on Sep 4, 2017

    @GuillaumeGomez
    Member

    Dark magic! 😆

    I'll take a look later.

  3. chordowl commented on Sep 4, 2017

    @chordowl
    Contributor
  4. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
    on Sep 17, 2017
  5. camelid commented on Oct 12, 2020

    @camelid
    Member

    I think this is a cross-crate reexports issue, so labeling as such.

  6. jyn514 commented on Dec 16, 2020

    @jyn514
    Member

    Triage as of rustdoc 1.50.0-nightly (0f6f2d6 2020-12-06): This bug has gone away:

    The where clause gives an explicit -> ().

    The rest are still changed from the inner crate.

    Inner: image
    Outer: image

  7. jyn514 commented on Dec 16, 2020

    @jyn514
    Member

    I expect this is an inconsistency between how clean treats HIR and rustc_middle::ty somewhere (the difference being that ty works off serialized metadata).

  8. removed
    T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
    on Jan 18, 2022
  9. fmease commented on Oct 27, 2022

    @fmease
    Member

    Temporarily assigning myself to this issue since I am working on fixing several issues related to the handling of cross-crate trait object types in rustdoc and other minor cross-crate things. I won't fix everything mentioned in this issue however, hence this is only a temporary assignment until the PR is open.

    @rustbot claim
    @rustbot label -C-enhancement +C-bug

  10. added
    C-bugCategory: This is a bug.
    and removed
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Oct 27, 2022
  11. added a commit that references this issue on Nov 6, 2022
  12. 4 remaining items

  13. added a commit that references this issue on Sep 22, 2023
  14. added a commit that references this issue on Sep 30, 2023
  15. added a commit that references this issue on Oct 30, 2023
  16. added 2 commits that reference this issue on Oct 30, 2023
  17. fmease commented on Oct 30, 2023

    @fmease
    Member

    Update: Thanks to #103885, #107637 & #112463, the output is finally very close to acceptable (source vs. rendered):

    - pub fn f<F>(_: F, _: Box<dyn T>) -> Self
    - where F: Fn()
    + pub fn f<F>(_: F, _: Box<dyn T>) -> S
    + where
    +     F: Fn(),

    The remaining issue concerns Self types in cross-crate scenarios. I'm not gonna work on a PR for that in the foreseeable future but at some point I will probably submit a PR for it. I predict it to be a bit nasty performance-wise since it requires performing type unification on every Ty inside an impl.

  18. added a commit that references this issue on Oct 30, 2023
  19. removed their assignment
    on Dec 18, 2023
  20. added 3 commits that reference this issue on Apr 17, 2025
  21. added a commit that references this issue on Apr 18, 2025
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

    A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.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