Uh oh!
There was an error while loading. Please reload this page.
Unify behaviours for re-exports of #[doc(hidden)] - #109697
Unify behaviours for re-exports of #[doc(hidden)]#109697GuillaumeGomez wants to merge 7 commits into
#[doc(hidden)]#109697Conversation
This comment has been minimized.
This comment has been minimized.
18a298a to
cf5b57eCompareGuillaumeGomez
commented
Mar 28, 2023
Fixed tidy error. |
This comment has been minimized.
This comment has been minimized.
rustbot
commented
Mar 28, 2023
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
GuillaumeGomez
commented
Mar 28, 2023
Two traits that are exported and didn't appear into the documentation before just did with this change. They were referencing to another item which doesn't appear into documentation so I added |
notriddle
commented
Mar 28, 2023
|
GuillaumeGomez
commented
Mar 29, 2023
I'll merge this PR with #109456 then. |
GuillaumeGomez
commented
Mar 29, 2023
Added the documentation so let's start the FCP. @rfcbot fcp merge |
Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This comment has been minimized.
This comment has been minimized.
e6bd3f7 to
efff21aCompareGuillaumeGomez
commented
Mar 29, 2023
Fixed tidy error in the rustdoc book. |
notriddle
commented
Apr 3, 2023
@rfcbot concern document-globs
I don't see this mentioned in the book (which claims that DetailsAssuming I understand this correctly, this means glob imports and explicit imports act differently in the face of doc(hidden), as described in this sample: pubmod outer {mod inner {#[doc(hidden)]structFooBar;structFooBaz;}/// FooBar will be inlined here, because it's explicitly named.pubuse inner::FooBar;/// FooBaz, of course, will also be inlined here.pubuse inner::FooBaz;}/// FooBar *WON'T* be inlined here, because it's #[doc(hidden)]/// However, FooBaz will be inlined here, because it's just private.pubuse outer::inner::*;I get the reasoning behind it, but it's really weird, and needs to be documented. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
efff21a to
907d77fComparebors
commented
Apr 9, 2023
☔ The latest upstream changes (presumably #109500) made this pull request unmergeable. Please resolve the merge conflicts. |
notriddle
commented
Apr 9, 2023
@rfcbot resolve document-globs |
907d77f to
ff65872Comparebors
commented
Apr 18, 2023
☔ The latest upstream changes (presumably #110481) made this pull request unmergeable. Please resolve the merge conflicts. |
6cc24fe to
84ce917CompareGuillaumeGomez
commented
Apr 18, 2023
Fixed merge conflict. |
edf4ee3 to
e1b3f41CompareThe situation in mod m {pubstructFoo;pubtypeBar = Foo;#[doc(hidden)]pubconstBar:Foo = Foo;}pubuse m::Bar;
It doesn't in my tests. This is what we would ideally have in gimli: /// Little endian byte order.pubstructLittleEndian;/// The native endianity for the target platform.#[cfg(target_endian = "little")]pubuseLittleEndianasNativeEndian;but when I test that, the documentation on the use statement is ignored. |
GuillaumeGomez
commented
May 17, 2023
Ah right, I forgot about const/type alias case. As for the documentation for re-exports, it's only used when the re-exported item is inlined (whether by using |
obi1kenobi
commented
May 17, 2023
This is also a concern from other angles, like semver. I don't think it can be forbidden directly due to backcompat and other reasons, but I've proposed that rustc lint it at the very least: Having the same names multiple times in the same namespace can have surprising downstream impacts, like causing adding an import a to be major breaking change. I wrote up some of these cases on my blog: https://predr.ag/blog/breaking-semver-in-rust-by-adding-private-type-or-import/ |
GuillaumeGomez
commented
May 18, 2023
A new edition is coming up next year so we could turn it into an error. |
Manishearth
commented
May 22, 2023
If we want to edition it we need to add a way of explicitly saying "no, I meant to reexport it publicly here" since the migration path needs to be designed. Just lint allows do not cut it for edition migrations. I recommend designing that mechanism, making it a lint, and having an edition migration for it that makes it hidden by default. We can then make it a hard error in the next edition, and eventually remove the error and switch the behavior if we want. |
notriddle
commented
May 22, 2023
Here's a few other things that seems kinda weird, that probably shouldn't work this way: #![crate_name = "foo"]mod alpha {#[doc(hidden)]pubstructAlpha;}mod beta {pubusecrate::alpha::*;}// This is what it currently does.// Is it what we want?// @has foo/struct.Alpha.htmlpubuse beta::Alpha;This seems like a bug. The reason is that it implies that this should happen, which is definitely not what diesel wants: #![crate_name = "foo"]mod alpha {pubstructAlpha;pubtypeBeta = Alpha;#[doc(hidden)]#[allow(nonstandard_style)]pubconstBeta:Beta = Alpha;}mod beta {pubusecrate::alpha::*;}// This is definitely correct.// @has foo/struct.Alpha.html// This is also correct.// @has foo/type.Beta.html// This probably isn't what we want. But it's the same thing as the first example!// @has foo/constant.Beta.htmlpubuse beta::{Alpha,Beta}; |
GuillaumeGomez
commented
May 23, 2023
It seems like more discussions are required. I think we could go by this simple rule: if any item has mod foo {/// apubstructBar;}mod bar {/// b#[doc(hidden)]pubusecrate::foo::Bar;}pubusecrate::bar::Bar;Since the first re-export is doc hidden, should only this re-export be hidden (and therefore its associated documentation "b" too) or should the re-export and the re-exported item be both hidden? I'd tend to only remove the re-export and its documentation and still make |
obi1kenobi
commented
May 23, 2023
We have to be careful with inlining mod foo {/// apubstructBar;}mod bar {/// b#[doc(hidden)]pubusecrate::foo::Bar;}// shadow the re-export below// but only in the values namespaceconstBar:usize = 0;pubusecrate::bar::Bar;The rustdoc generated for your example code and the one from mine must be different, or else we'll have the same problem as #111338 and https://predr.ag/blog/breaking-semver-in-rust-by-adding-private-type-or-import/ Treating the top-level I hate jumping in to point out concerns without having a constructive suggestion on how to do better, but I genuinely don't see a good way out of this right now. |
GuillaumeGomez
commented
May 23, 2023
JSON output handles things differently compared to the HTML output. And in the end, |
notriddle
commented
May 23, 2023
Yeah. Making I propose closing this PR and opening a new one to document the new decision (and fix any weird inconsistencies): |
GuillaumeGomez
commented
May 23, 2023
👍 Closing then and thanks everyone for the feedback! |
obi1kenobi
commented
May 23, 2023
I'm not familiar with the HTML output, and I just realized my earlier code example is slightly broken. Here's an attempt at clarifying what I meant with respect to the JSON output (checked in the playground this time). In the code below, we cannot replace mod upstream {mod foo {/// apubstructBar;}mod bar {/// b#[doc(hidden)]pubusesuper::foo::*;// shadow the re-export below// but only in the values namespaceconstBar:usize = 0;}// This line causes compilation to fail:// pub use bar::Bar;//// But replacing it with this seemingly-equivalent line// makes the problem go away -- so it isn't actually equivalent:pubuse foo::Bar;}// imagine this is a downstream cratemod downstream {fnmake_bar() -> crate::upstream::Bar{crate::upstream::Bar}} |
GuillaumeGomez
commented
May 23, 2023
I should have precised but this behaviour enforcement/clarification is only for the HTML output. I'll precise it when I'll open the new PR so it's more clear. The JSON output is handling re-exports differently since its format allows it. |
obi1kenobi
commented
May 23, 2023
Ah yes that makes sense now! |
…n-macros, r=notriddle Fix re-export of doc hidden macro not showing up It's part of the follow-up of rust-lang#109697. Re-exports of doc hidden macros should be visible. It was the only kind of re-export of doc hidden item that didn't show up. r? `@notriddle`
…ddle Add chapter in rustdoc book for re-exports and add a regression test for `#[doc(hidden)]` behaviour Fixesrust-lang#109449. Fixesrust-lang#53417. After the discussion in rust-lang#109697, I made a few PRs to fix a few corner cases: * rust-lang#112178 * rust-lang#112108 * rust-lang#111997 With this I think I covered all cases. Only thing missing at this point was a chapter covering re-exports in the rustdoc book. r? `@notriddle`
Fixes#109449.
Fixes#53417.
I also took the comments from zulip about
#[doc(no_inline)]and glob re-exports more globally.So now, for non-glob re-exports,
#[doc(hidden)]items are treated the same as private items: they are inlined.For glob re-exports,
#[doc(hidden)]items are not inlined (contrary to private items).If there
#[doc(no_inline)]on a glob re-export, the glob re-export definition will displayed and the referenced items won't be inlined.cc @petrochenkov
r? @notriddle