Skip to content

Rustdoc ignores traits implemented inside of a function #52545

Closed

Description

@sgrif

After #51952 landed, I attempted to make Diesel compatible with recent nightlies by following the advice of wrapping the output in a function rather than a module. However, we are now unable to build our documentation. The compiler complains that every derived trait within Diesel is not implemented. This only occurs when running cargo doc, the crate otherwise compiles fine. I have tested with 1.26.1, stable, and the most recent nightly.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 19, 2018
  2. added this to the 1.29 milestone on Jul 19, 2018
  3. GuillaumeGomez commented on Jul 19, 2018

    @GuillaumeGomez
    Member

    To fix it, I suppose we could "just" remove the "loop" feature of rustdoc but we'd have some huge performance loss...

  4. added a commit that references this issue on Jul 19, 2018
  5. self-assigned this
    on Jul 26, 2018
  6. oli-obk commented on Jul 26, 2018

    @oli-obk
    Contributor

    @GuillaumeGomez can't you do the same trick you did for dead_code and unused_import? Or is this an error?

  7. QuietMisdreavus commented on Jul 26, 2018

    @QuietMisdreavus
    Contributor

    @Mark-Simulacrum Not sure the reasoning behind tagging things as regressions - this bug has been here for all time, it's just that the hygiene change has brought this to light. Rustdoc has never looked inside functions to document things, and the introduction of everybody-loops made that impossible anyway. To fix this, two things need to happen:

    1. everybody-loops needs to be revamped to somehow exclude trait impls from being removed. Alternately, we can stop doing everybody-loops in rustdoc, but I don't think it's just there for performance. IIRC it was introduced to rustdoc when #[doc(cfg)] was, to prevent trying to resolve things on the wrong platform.
    2. Rustdoc needs to start scanning inside functions for impl blocks. I fear this can start recursing arbitrarily deep, though - imagine a function with an impl, that contains a function with another impl, etc. However, i imagine in practice it won't be a problem.

    At some point either rustdoc or everybody-loops needs to filter out types that are only in-scope for that function - rustdoc may already have an easier time at this, though, since it can just treat items declared inside functions to be the equivalent of #[doc(hidden)]. (Meaning that you'd need to use #[doc(no_hidden)] to reveal trait impls inside functions? Seems legit to me.)

  8. Mark-Simulacrum commented on Jul 26, 2018

    @Mark-Simulacrum
    Member

    I tag things as a regression mostly so that we can keep an eye on them; if we believe this isn't one we can of course untag. However, my reasoning in this case was that @sgrif indicated that Diesel changed in behavior, which feels like a regression to me, though I may have misunderstood.

  9. ollie27 commented on Jul 26, 2018

    @ollie27
    Contributor

    This looks like a duplicate of #36922 / #41480.

  10. QuietMisdreavus commented on Jul 26, 2018

    @QuietMisdreavus
    Contributor

    From the issue description, it sounds like #51952 caused some new warnings to appear (i think? i haven't read too far into it), which @sgrif moved to fix. This caused an interaction with a long-standing behavior in rustdoc (always activating everybody-loops), which makes the crate fail to document. There's also this:

    I have tested with 1.26.1, stable, and the most recent nightly.

    Which makes me feel like if anything, it's a stable-to-stable regression.

  11. added and removed on Jul 31, 2018
  12. 9 remaining items

  13. added a commit that references this issue on Aug 3, 2018
  14. added a commit that references this issue on Aug 6, 2018
  15. QuietMisdreavus commented on Aug 7, 2018

    @QuietMisdreavus
    Contributor

    I've opened #53162 to make those trait impls show up in documentation.

  16. added a commit that references this issue on Sep 7, 2018
  17. added 2 commits that reference this issue on Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions