Skip to content

rustdoc: Inlining a foreign public struct with private fields shows the fields as private in the current crate #91440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jyn514 opened this issue Dec 1, 2021 · 4 comments
Labels
A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate A-visibility Area: Visibility / privacy C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 1, 2021

// inner crate
pub struct S {
  pub x: i32,
  y: i32,
}

// outer crate
pub use inner::S;

image

Originally posted by @jyn514 in #91408 (comment)

@jyn514 jyn514 added A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 1, 2021
@camelid camelid added the A-visibility Area: Visibility / privacy label Dec 1, 2021
@BGR360
Copy link
Contributor

BGR360 commented Dec 26, 2021

Can anybody more familiar with rustdoc put an E-{easy,medium,hard} and/or an E-mentor on here?

@jyn514
Copy link
Member Author

jyn514 commented Dec 28, 2021

@BGR360 I honestly don't understand this code very well either, but the way I'd suggest getting started is looking at

if let Some(import_def_id) = import_def_id {
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
item.visibility = cx.tcx.visibility(import_def_id).clean(cx);
- I think part of the issue is that rustdoc treats struct fields as their own item: https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/clean/types/enum.ItemKind.html#variant.StructFieldItem, so it gets confused when structs are re-exported and thinks the visibility of the re-export applies to the field too.

@fmease

This comment was marked as resolved.

@jyn514
Copy link
Member Author

jyn514 commented Oct 19, 2022

@fmease you need to also pass --document-private-items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate A-visibility Area: Visibility / privacy C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants