Skip to content

Stabilization of the documentation scope in rustc #163896

Description

@Urgau

Stabilization of the documentation scope in rustc

rustdoc is in the process of stabilizing --remap-path-scope in rustdoc in #163895. (We stabilized --remap-path-scope in rustc earlier this year in #147611).

Summary

In addition to the other stable scopes (diagnostics, debuginfo, object, ...), rustdoc has an additional scope: documentation, it's used to define if paths should be remapped in the documentation.

In order to simplify interoperability between rustc and rustdoc, the scope is being proposed to be accepted by rustc.

The scope is never checked to be active by rustc, but it still encoded in rmeta. This is so rustdoc can check if the documentation scope is active for a RealFilename when getting the filepath of a RealFilename coming from a dependency.

Implementation

Major parts

Coverage in rustc

Activity

  1. added
    T-compiler
    F-trim-paths
    on Oct 6, 2026
  2. added
    needs-triage
    on Oct 6, 2026
  3. removed
    needs-triage
    on Oct 6, 2026
  4. Urgau commented on Oct 6, 2026

    @Urgau
    MemberAuthor

    @rfcbot merge compiler

  5. rust-rfcbot commented on Oct 6, 2026

    @rust-rfcbot
    Collaborator

    @Urgau has proposed to merge this. The next step is review by the rest of the tagged team members:

    No concerns currently listed.

    Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

    See this document for info about what commands tagged team members can give me.

  6. added
    proposed-final-comment-period
    disposition-merge
    on Oct 6, 2026
  7. oli-obk commented on Oct 7, 2026

    @oli-obk
    Contributor

    In order to simplify interoperability between rustc and rustdoc, the scope is being proposed to be accepted by rustc.

    why is it necessary for rustc to accept this flag? simply forwarding all rustdoc flags to rustc without filtering?

  8. Urgau commented on Oct 7, 2026

    @Urgau
    MemberAuthor

    The flag (--remap-path-scope) is stable in rustc, that's not something new or something that's changing.

    The flag has multiple options that can be passed to it, we called them scopes. All the scopes currently stable do something in rustc.

    What's changing is it rustdoc is stabilizing the flag on their side, but to avoid using a misleading scope, like diagnostics for the generated documentation html files by rustdoc, we created a new scope in rustc/rustdoc: documentation.

    It's this new scope, and only this new scope, that will do nothing in rustc it-self.

    As for why rustc should accept it, it's both to simply interoperability, it's easier for users if rustc and rustdoc accept the same options.

    But there also is a more practical use, rustdoc uses the same rmeta from the dependencies and those may contain paths that rustdoc may want to print the remapped path (not sure if we have a stable case in rustdoc for that though).

  9. oli-obk commented on Oct 7, 2026

    @oli-obk
    Contributor

    As for why rustc should accept it, it's both to simply interoperability, it's easier for users if rustc and rustdoc accept the same options.

    I thought rustdoc already had options that rustc doesn't accept. But even if not, where is such "interop" (do you mean drop-in replacement?) useful or already in use?

    But there also is a more practical use, rustdoc uses the same rmeta from the dependencies and those may contain paths that rustdoc may want to print the remapped path (not sure if we have a stable case in rustdoc for that though).

    How does that relate to the flags? If rustc built the rmeta, it didn't get remapped, so rustdoc needs to do sth here anyway

  10. Urgau commented on Oct 7, 2026

    @Urgau
    MemberAuthor

    As for why rustc should accept it, it's both to simply interoperability, it's easier for users if rustc and rustdoc accept the same options.

    I thought rustdoc already had options that rustc doesn't accept. But even if not, where is such "interop" (do you mean drop-in replacement?) useful or already in use?

    rustdoc has flags that rustc doesn't have, but I don't think rustdoc has any rustdoc specific options in a shared flag.

    Rust-for-linux is not currently using --remap-path-scope in rustdoc but they do consider the flag to be "common". Just like --remap-path-prefix is.

    https://github.com/torvalds/linux/blob/602042bf29f6efde39cfb5fdd9289bf4854bc0c5/rust/Makefile#L176

    But there also is a more practical use, rustdoc uses the same rmeta from the dependencies and those may contain paths that rustdoc may want to print the remapped path (not sure if we have a stable case in rustdoc for that though).

    How does that relate to the flags? If rustc built the rmeta, it didn't get remapped, so rustdoc needs to do sth here anyway

    The scopes are attached to each individual RealFilename in the rmeta at https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/struct.RealFileName.html. It's done this way so that the current scopes do not affect those from the dependencies. We had an unsoundness when we used the scopes from the current session.

  11. oli-obk commented on Oct 7, 2026

    @oli-obk
    Contributor

    The scopes are attached to each individual RealFilename in the rmeta at https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/struct.RealFileName.html. It's done this way so that the current scopes do not affect those from the dependencies. We had an unsoundness when we used the scopes from the current session.

    Right, but are the rmeta created by rustdoc or by rustc? Because if thr latter, and a no-op there, then why would rustdoc benefit from it being specified as documentation vs not being specified at all?

  12. Urgau commented on Oct 7, 2026

    @Urgau
    MemberAuthor

    The later, rustc is the one creating the rmeta.

    and a no-op there

    When it said that is does nothing I meant that rustc doesn't condition on it (ie. rustc never checks if the documentation scope is active for a RealFilename, only rustdoc does that), but rustc still encodes it in rmeta, otherwise rustdoc couldn't exploit it.

    Sorry for the confusion. Improved the wording in the top comment.

  13. Urgau commented on Oct 14, 2026

    @Urgau
    MemberAuthor

    For information, #164279 moves the documentation scope under the object alias scope. It currently covers the macro, debuginfo and coverage scopes, and would include the documentation scope as well.

    Rational in #164279 (comment), but tl;dr is that it better reflects how the scope is actually used (for things that end up written to disk, which the object scope is meant to represent) and simplify things for Cargo.

  14. 1 remaining item

  15. added
    final-comment-period
    and removed
    proposed-final-comment-period
    on Nov 17, 2026
  16. rust-rfcbot commented on Nov 17, 2026

    @rust-rfcbot
    Collaborator

    🔔 This is now entering its final comment period, as per the review above. 🔔

  17. added
    finished-final-comment-period
    S-waiting-on-review
    to-announce
    and removed
    final-comment-period
    on Nov 27, 2026
  18. rust-rfcbot commented on Nov 27, 2026

    @rust-rfcbot
    Collaborator

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

  19. added a commit that references this issue on Nov 27, 2026
  20. added a commit that references this issue on Nov 27, 2026
  21. added a commit that references this issue on Nov 27, 2026
  22. added a commit that references this issue on Nov 27, 2026
  23. added a commit that references this issue on Nov 27, 2026
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

    F-trim-pathsS-waiting-on-reviewT-compilerdisposition-mergefinished-final-comment-periodto-announce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions