Skip to content

private-intra-doc-links incorrectly shows error for public type alias to private wrapper type #132952

Open
@Manishearth

Description

@Manishearth
pub struct WholeNumber(u32);

pub use bar::Integer;
mod foo {
    // This is private
    pub struct Signed<T>(pub T);
}

mod bar {
    /// If you want to do things, try [`Integer::do_thing()`]
    pub type Integer = crate::foo::Signed<crate::WholeNumber>;

    impl Integer {
        pub fn do_thing() {}
    }
}

Shows

warning: public documentation for `Integer` links to private item `Integer::do_thing`
  --> src/lib.rs:10:41
   |
10 |     /// If you want to do things, try [`Integer::do_thing()`]
   |                                         ^^^^^^^^^^^^^^^^^^^ this item is private
   |
   = note: this link will resolve properly if you pass `--document-private-items`
   = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default

under cargo doc.

This is (a) incorrect: Integer::do_thing() is public and accessible even if Signed isn't and (b) misleading: the problem is not the publicness of do_thing() but rather the fact that Signed is inaccessible. The diagnostic is confusing and doesn't help fix the problem.

I think this should probably be considered a false positive, but either way, the diagnostic ought to be be clearer about what needs to be fixed here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-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