Skip to content
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 docscrape memoization #10524

Closed
wants to merge 2 commits into from
Closed

Fix docscrape memoization #10524

wants to merge 2 commits into from

Conversation

lqd
Copy link
Member

@lqd lqd commented Mar 30, 2022

This PR fixes a memoization issue in docscraped units when profile overrides are involved.

Split off from #10493 at @ehuss' request.
Fixes #10500.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 30, 2022
@@ -717,14 +717,15 @@ fn compute_deps_doc(
unit_for.root_compile_kind(),
);
deps_of(scrape_unit, state, unit_for)?;
ret.push(new_unit_dep(
ret.push(new_unit_dep_with_profile(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In trying to better understand when someone chooses to use new_unit_dep instead of new_unit_dep_with_profile, I was lost until I found a comment for the only direct use of new_unit_dep_with_profile.

Maybe this deserves a similar comment
(granted, I know you aren't the one who made the change so unsure if you feel confident in doing so)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if you feel confident in doing so

not particularly ^^

so if you, Eric, or @willcrichton have ideas on what you'd like to see here, I could add that -- but I wouldn't be able to come up with an explanation other than what I believe is happening (but I know little about docscraping and cargo, and could be wrong): recording the profile of these "fake" unit dependencies is important to memoization here, otherwise checking later if the actual units were built will not be found in that map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything should use new_unit_dep except for the one place it is done for build scripts because build scripts need different profiles for build-overrides.

This change doesn't appear correct to me. The line just above (let unit_for = …) that shadows unit_for does not seem like the right approach. It is generating an incorrect unit_for with the wrong settings, and that is why the rest of the units end up with the wrong profile. Commenting out that line seems to get all tests to pass.

Perhaps @willcrichton can say why it is creating a new unit_for instead of inheriting the one from the doc unit.

Copy link
Contributor

@willcrichton willcrichton Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok after some inspection / experimentation, I believe that @ehuss is right and my code was incorrect. The original intention was to fix an issue that I just realized had a deeper root cause I was able to identify and fix (that proc macros should never actually be scraped). I will put up my own PR so @lqd doesn't have to do more work on my behalf.

See #10533.

@lqd
Copy link
Member Author

lqd commented Apr 2, 2022

I'll close this PR in favor of Will's #10533 then.

@lqd lqd closed this Apr 2, 2022
@lqd lqd deleted the docscrape-fix branch April 2, 2022 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-Z rustdoc-scrape-examples panics with some profile overrides
5 participants