-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix dangling ID when pub use
ing item which is Doc(hidden) or inherits it in rustdoc JSON output
#117810
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
Fix dangling ID when pub use
ing item which is Doc(hidden) or inherits it in rustdoc JSON output
#117810
Changes from all commits
98643de
53d54bd
e6c1db7
2e1fcd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/117718>. | ||
// Ensures that the various "doc(hidden)" reexport cases are correctly handled. | ||
|
||
pub mod submodule { | ||
#[doc(hidden)] | ||
pub struct Hidden {} | ||
} | ||
|
||
#[doc(hidden)] | ||
mod x { | ||
pub struct Y {} | ||
} | ||
|
||
// @has "$.index[*].inner[?(@.import.name=='UsedHidden')].import.source" '"submodule::Hidden"' | ||
// @has "$.index[*].inner[?(@.import.name=='UsedHidden')].import.id" "null" | ||
pub use submodule::Hidden as UsedHidden; | ||
// @has "$.index[*].inner[?(@.import.name=='Z')].import.source" '"x::Y"' | ||
// @has "$.index[*].inner[?(@.import.name=='Z')].import.id" 'null' | ||
pub use x::Y as Z; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ mod repeat_n { | |
pub struct RepeatN {} | ||
} | ||
|
||
/// not here | ||
/// is here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the right behavior. If the underlying item isn't part of the public API than I don't think the import of it should be either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import is publicly accessible so I don't see why not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pub use repeat_n::RepeatN; | ||
|
||
// @count "$.index[*][?(@.name=='pub_use_doc_hidden')].inner.items[*]" 0 | ||
// @has "$.index[*][?(@.docs == 'is here')]" | ||
// @!has "$.index[*][?(@.docs == 'not here')]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/pub.20re-export.20of.20item.20from.20.60doc.28hidden.29.60.20module/near/401627083, this import should be a part of the output, and so the ID should be present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the same logic as for reexport of item inside private module. We discussed that after this PR, we want to inline such items and I think in the meantime, this is the right course of action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reexporting an item defined in a private module, the import will have the ID of the underlying item. We should do the same thing here.
Please no. Inlining was a massive source of bugs for rustdoc-json, and removing it was a great improvement. I'm strongly opposed to bringing it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having an ID pointing to an item that is not available means that the current bug fixed by this PR will remain.