-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rustdoc-Json: Don't remove impls for items imported from private modules #100325
Conversation
src/librustdoc/passes/stripper.rs
Outdated
// Because json doesn't inline imports from private modules, we need to mark | ||
// the imported item as retained so it's impls won't be stripped. | ||
if let Some(did) = imp.source.did { | ||
self.retained.insert(did.into()); |
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.
does this need to special-case the JSON backend? are we sure this doesn't break anything for the HTML backend?
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 don't think so, as HTML shouldn't have imports to items that arn't retained at this point, due to the strip-priv-imports
pass. It also passes all rustdoc html/ui/gui/js tests, but I'm not sure how comprehensive these are.
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.
It's mostly testing that something exists. It's hard to confirm in prevision for something that doesn't and shouldn't exist.
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'd feel more at ease if you added a check for the JSON format. You already have this information in self.is_json_output
.
7bbb0d4
to
40fe3b2
Compare
src/librustdoc/passes/stripper.rs
Outdated
// Because json doesn't inline imports from private modules, we need to mark | ||
// the imported item as retained so it's impls won't be stripped.i | ||
// | ||
// FIXME: Is it nessessary to check for json output here: See |
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.
Nitpicking:
// FIXME: Is it nessessary to check for json output here: See | |
// FIXME: Is it necessary to check for json output here: See |
Fixes a bug where impl of items that were imported from a private module would be striped Fixes rust-lang#100252 Fixes rust-lang#100242
// | ||
// FIXME: Is it nessessary to check for json output here: See | ||
// https://github.com/rust-lang/rust/pull/100325#discussion_r941495215 | ||
if let Some(did) = imp.source.did && self.is_json_output { |
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 didn't know you could do that. :o
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.
Not on stable yet, but let_chains
are dope!
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.
Indeed!
40fe3b2
to
44b489f
Compare
Looks good to me, thanks! I'll r+ once CI pass. |
@bors r+ |
…uillaumeGomez Rustdoc-Json: Don't remove impls for items imported from private modules After rust-lang#99287, items in private modules may still be in the json output, if a public import accesses them. To reflect this, items that are imported need to be marked as retained in the `Stripper` pass, so their impls arn't removed by `ImplStripper`. [More context on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Populating.20cache.2Eimpls), thanks to @ jyn514 for helping debug this. `@rustbot` modify labels: +A-rustdoc-json +T-rustdoc r? `@GuillaumeGomez` Fixes rust-lang#100252 Fixes rust-lang#100242
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#100031 (improve "try ignoring the field" diagnostic) - rust-lang#100325 (Rustdoc-Json: Don't remove impls for items imported from private modules) - rust-lang#100377 (Replace - with _ in fluent slugs to improve developer workflows) - rust-lang#100458 (Adjust span of fn argument declaration) - rust-lang#100514 (Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls) - rust-lang#100528 (Support 1st group of RISC-V Bitmanip backend target features) - rust-lang#100559 (Parser simplifications) - rust-lang#100568 (Fix STD build for ESP-IDF) - rust-lang#100582 ([rustdoc] Fix handling of stripped enum variant in JSON output format) - rust-lang#100586 (Reland changes replacing num_cpus with available_parallelism ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
After #99287, items in private modules may still be in the json output, if a public import accesses them. To reflect this, items that are imported need to be marked as retained in the
Stripper
pass, so their impls arn't removed byImplStripper
.More context on zulip, thanks to @ jyn514 for helping debug this.
@rustbot modify labels: +A-rustdoc-json +T-rustdoc
r? @GuillaumeGomez
Fixes #100252
Fixes #100242