Are publicly re-exported items from a doc(hidden)
module considered public API?
#117845
Labels
A-rustdoc-json
Area: Rustdoc JSON backend
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
Let's look at this example from the doc comment in #117810:
To me, this seems like a public re-export of an intended-to-be-public item. In other words, when I see this code, I expect its
doc(hidden)
semantics to be that it is the module that is hidden, but non-hidden ways to access its contents are public API and "fair game." In my interpretation, if the programmer intended that to not be the case, they could have hidden the re-export (orpub struct Bar
itself).If
pub struct Bar
is always considered hidden regardless of re-exports (whether themselves hidden or not), I think that has strange implications for what is and is not public API. In that interpretation, the re-export is public API but the item it points to is not public API ... which is just confusing. It seems like it says "I make it part of the public API that this non-public-API type reserves a name in the public API" and nothing else. That's just strange! What public API operations are allowed over that re-export item? It feels to me like the answer is that the item is "neither here nor there" with respect to being public API or not.It also seems to risk opening a terrible can of worms with further edge cases:
For these reasons, I think a better interpretation of whether an item is
doc(hidden)
is one based on reachability: if you can reach the item without going through anydoc(hidden)
items (the item itself + any modules and re-exports), it is not hidden. If all paths require going through at least one hidden item, the item is hidden. This is also how visibility works as well — the pub-in-priv trick wouldn't work otherwise — so I think it makes a lot of sense fordoc(hidden)
to work that way too.Originally posted by @obi1kenobi in #117810 (comment)
The text was updated successfully, but these errors were encountered: