-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove masked_crates
from clean::Crate
#82960
Conversation
Previously, `masked_crates` existed both on `Cache` and on `clean::Crate`. During cache population, the `clean::Crate` version was `take`n and moved to `Cache`. This change removes the version on `clean::Crate` and instead directly mutates `Cache.masked_crates` to initialize it. This has the advantage of avoiding duplication and avoiding unnecessary allocation, as well as making the flow of information through rustdoc less confusing. The one downside I see is that `clean::utils::krate()` now uses the side effect of mutating `DocContext.cache` instead of returning the data directly, but it already mutated the `Cache` for other things (e.g., `deref_trait_did`) so it's not really new behavior. Also, `clean::utils::krate()` is only called once (and is meant to only be called once since it performs expensive and potentially destructive operations) so the mutation shouldn't be an issue.
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
r=me with CI passing. Good catch, thanks :) |
@bors r=jyn514 rollup |
📌 Commit b7d91b0 has been approved by |
@bors rollup=maybe This could theoretically affect perf - I don't think it's worth marking it as rollup=never, but I don't think it needs to always be in a rollup. |
☀️ Test successful - checks-actions |
Previously,
masked_crates
existed both onCache
and onclean::Crate
. During cache population, theclean::Crate
version wastake
n and moved toCache
.This change removes the version on
clean::Crate
and instead directlymutates
Cache.masked_crates
to initialize it. This has the advantageof avoiding duplication and avoiding unnecessary allocation, as well as
making the flow of information through rustdoc less confusing.
The one downside I see is that
clean::utils::krate()
now uses the sideeffect of mutating
DocContext.cache
instead of returning the datadirectly, but it already mutated the
Cache
for other things (e.g.,deref_trait_did
) so it's not really new behavior. Also,clean::utils::krate()
is only called once (and is meant to only becalled once since it performs expensive and potentially destructive
operations) so the mutation shouldn't be an issue.
Follow-up to #82018 (comment).
cc @jyn514