Skip to content

2024 edition prelude item docs are not inlined, and cause some duplication and confusion #136102

Closed

Description

@ehuss

#116016 made some changes to how the prelude items are structured which causes some problems with how the documentation is generated:

I would like to propose that after #134272 merges to undo the introduction of the common module, and revert it back to the previous state where rust_2024 re-exports v1 with doc(no_inline). Unfortunately this will break/delete existing pages like https://doc.rust-lang.org/core/prelude/rust_2024/attr.derive.html. I'm personally fine with that.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 26, 2025
  2. traviscross commented on Jan 28, 2025

    @traviscross
    Contributor

    @rustbot labels +I-libs-api-nominated
    cc @rust-lang/libs-api

    What's the situation on being able to give canonical paths to the macros and attribute macros here?:

    https://doc.rust-lang.org/core/prelude/v1/index.html#macros

    While reverting the use of the common module would fix the problem noted here, without giving these canonical paths, we'd still be left with the oddity that the only place that, e.g. derive is documented is under its prelude path:

    https://doc.rust-lang.org/core/prelude/v1/attr.derive.html

  3. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    T-libs-api[DEPRECATED; DO NOT USE]
    T-editionRelevant to the edition team.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Jan 28, 2025
  4. traviscross commented on Jan 28, 2025

    @traviscross
    Contributor

    Worth mentioning, if we did ever need to remove something from an edition prelude that remained in older preludes, another way we might do it, rather than having a common module and removing doc(no_inline), would be to elaborate the v1 imports rather than using the v1::* (or e.g. rust_2021::*) glob import. That would at least make it easy to see what was added in the new prelude. Seeing what was removed would be harder, but that's a problem with the inlining approach as well.

  5. traviscross commented on Feb 11, 2025

    @traviscross
    Contributor

    @rustbot labels -I-libs-api-nominated

    This was discussed in the libs-api call today. Libs-api is OK with the strategy of reverting the common module.

    If we ever did need to remove something from a prelude over an edition, the strategy of elaborating the import also sounded right to people.

    On the matter of giving paths to these macros, the team also felt warmly about that. One matter that was raised was the question of whether this might affect what is brought into scope for users of the no_implicit_prelude attribute. It was theorized that, in this case, todo would still be brought into scope but not derive, and that exporting derive as std::derive would change this and thus we'd need to consider backward compatibility concerns.

    Fortunately, it doesn't seem this is the case. Firstly, the behavior that would have given rise to this is exclusive to Rust 2015. Quoting the Reference:

    In the 2015 edition, the no_implicit_prelude attribute does not affect the macro_use prelude, and all macros exported from the standard library are still included in the macro_use prelude. Starting in the 2018 edition, it will remove the macro_use prelude.

    But, moreover, even without a std::derive path, derive is still part of the macro_use prelude, and so even in Rust 2015 there is no difference. E.g.:

    //@ edition: 2015
    #![no_implicit_prelude]
    
    #[derive()]
    struct S;
    
    fn main() {
        let _ = todo!();
    }

    Playground link

    On the call, the decision of the team was that PRs adding paths to these macros should be nominated for libs-api so that these can be handled via FCP.

  6. 4 remaining items

  7. added a commit that references this issue on Feb 14, 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-edition-2024Area: The 2024 editionC-bugCategory: This is a bug.T-editionRelevant to the edition team.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions