Skip to content

Get rid of doc(primitive) #98248

Not planned
Not planned
@jyn514

Description

@jyn514
Member

I was chatting with @compiler-errors on twitter about #87073. In retrospect I think the whole thing was overcomplicated and we can get the equivalent behavior much more simply by treating documentation on the re-exports in core::primitive as docs for the primitive items themselves, just like for normal re-exports.

This does mean we have to do something like

pub use core::primitive::usize;
pub use core::primitive::isize;
// ...

in std::primitive rather than just use core::primitive::*;. But that seems pretty simple compared to all the current special casing.

The last thing to deal with here is overwriting the docs instead of appending - I think that would need a new nightly rustdoc feature, but it would be pretty simple to implement, basically just an if condition in try_inline for this line:

both.extend_from_slice(old_attrs);

So, an overview of all that:

  1. Treat docs on re-exports of primitives as docs for the primitive themselves. This should probably be behind a feature gate.
  2. Add a way to overwrite docs instead of appending in rustdoc, rather than special casing primitives only. This is probably useful just on its own, but should still be feature gated at first.
  3. Remove all the mod bool hackery in std and rustdoc; add docs to the re-exports in core::primitive.

@rust-lang/rustdoc I don't plan to work on this, but does it make sense / sound like a good idea?

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Jun 19, 2022
GuillaumeGomez

GuillaumeGomez commented on Jun 19, 2022

@GuillaumeGomez
Member

I think this would simplify things a lot. I didn't think it's a great idea and I'm all for it!

GuillaumeGomez

GuillaumeGomez commented on Jun 19, 2022

@GuillaumeGomez
Member

Just one thing I wonder: will this documentation remain available in core too? I think we can reexport primitives in core for their documentation to be displayed but better be sure.

jyn514

jyn514 commented on Jun 19, 2022

@jyn514
MemberAuthor
GuillaumeGomez

GuillaumeGomez commented on Jun 19, 2022

@GuillaumeGomez
Member

Perfect! Then there is really nothing preventing us from doing it.

Stupremee

Stupremee commented on Jun 20, 2022

@Stupremee
Member

How would you handle primitives that aren't re-exported from core::primitive, like fn, slice, etc.?

jyn514

jyn514 commented on Jun 20, 2022

@jyn514
MemberAuthor

Oh, that's a good point :( maybe this wouldn't work

jyn514

jyn514 commented on Aug 1, 2022

@jyn514
MemberAuthor

going to close this, don't have ideas on how to make non-path primitives work :(

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

    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

        Participants

        @GuillaumeGomez@jyn514@Stupremee

        Issue actions

          Get rid of doc(primitive) · Issue #98248 · rust-lang/rust