Skip to content

Rustdoc renders Vec's new allocator type parameter even when set to the default #80379

Closed

Description

@sfackler

For example, the docs for this type use Vec<String, Global> rather than just Vec<String>: https://docs.rs/tokio-postgres/0.7.0/tokio_postgres/types/enum.Kind.html. The definition of the type does not specify the allocator parameter if that matters.

The same is not true for e.g. HashMap's hasher type parameter, so I'm not sure what's different in this case.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Dec 26, 2020
  2. jyn514 commented on Dec 26, 2020

    @jyn514
    Member

    The difference is that this is a cross-crate re-export. MCVE:

    // crate1
    use std::collections::*;
    
    pub enum Types {
      Map(HashMap<usize, usize>),
      List(Vec<usize>),
      Pointer(Box<usize>),
    }
    
    // crate2
    pub use crate1::Types;

    image

  3. added
    A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crate
    on Dec 26, 2020
  4. jyn514 commented on Dec 26, 2020

    @jyn514
    Member

    This is a bug at least back to 1.22.0.

  5. jyn514 commented on Dec 26, 2020

    @jyn514
    Member

    In the inner crate, the params never get passes to render in the first place:

    DEBUG rustdoc::html::format fmt_type(t=ResolvedPath { path: Path { global: false, res: Def(Struct, DefId(4:4837 ~ alloc[4799]::vec::Vec)), segments: [PathSegment { name: "Vec", args: AngleBracketed { args: [Type(Primitive(Usize))], bindings: [] } }] }, param_names: None, did: DefId(4:4837 ~ alloc[4799]::vec::Vec), is_generic: false }
    

    but in the outer one they do show up:

    DEBUG rustdoc::html::format fmt_type(t=ResolvedPath { path: Path { global: false, res: Err, segments: [PathSegment { name: "Vec", args: AngleBracketed { args: [Type(Primitive(Usize)), Type(ResolvedPath { path: Path { global: false, res: Err, segments: [PathSegment { name: "Global", args: AngleBracketed { args: [], bindings: [] } }] }, param_names: None, did: DefId(5:5465 ~ alloc[4799]::alloc::Global), is_generic: false })], bindings: [] } }] }, param_names: None, did: DefId(5:4837 ~ alloc[4799]::vec::Vec), is_generic: false }
    

    I expect this has to do with some difference between HIR and metadata loading.

  6. jyn514 commented on Dec 26, 2020

    @jyn514
    Member

    I thought this might be related to inlining, but using doc(inline) within the same crate works fine:
    image

  7. jyn514 commented on Dec 26, 2020

    @jyn514
    Member

    The issue is that metadata types, unlike HIR types, go through external_path:

    let path = external_path(cx, cx.tcx.item_name(did), None, false, vec![], substs);

    and external_path doesn't pay any attention to the type defaults:
    let args: Vec<_> = substs

    So rustdoc needs to know which of the generic arguments were added by the user and which are just defaults.

  8. added a commit that references this issue on Jan 4, 2021
  9. camelid commented on Oct 10, 2021

    @camelid
    Member

    I came across another instance of this recently (#89712), but with a twist. The type that was re-exported also contained a type alias, which was expanded in the re-exported version. Is that the same bug or slightly different?

  10. fmease commented on Jan 19, 2023

    @fmease
    Member

    @rustbot claim

  11. jyn514 commented on Jan 19, 2023

    @jyn514
    Member

    I came across another instance of this recently (#89712), but with a twist. The type that was re-exported also contained a type alias, which was expanded in the re-exported version. Is that the same bug or slightly different?

    I suspect they're both caused by using metadata loading instead of HIR, if that's what you're asking, but the fix for the two will likely look different.

  12. added a commit that references this issue on Sep 22, 2023
    6bc50e2
  13. added a commit that references this issue on Sep 30, 2023
    fcd65ef
  14. added a commit that references this issue on Oct 30, 2023
    dbdc31c
  15. added 2 commits that reference this issue on Oct 30, 2023
    adce189
    b9dce53
  16. added a commit that references this issue on Oct 30, 2023
    e382c88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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