-
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
Make Clean
take &mut DocContext
#82020
Conversation
This comment has been minimized.
This comment has been minimized.
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
Hmm, maybe r? @camelid? The changes are all fairly simple, there's just a lot of them 😅 sorry for all the work |
This comment has been minimized.
This comment has been minimized.
Clean
take &mut DocContextClean
take &mut DocContext
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.
Left an initial review on some parts (haven't yet reviewed some of the files with massive changes like clean/mod.rs
).
There were several places with statements like let cx = self.cx;
or let tcx = self.cx.tcx
and changes from cx.sess()
to cx.tcx.sess
. I'm assuming these changes are necessary to please the borrow-checker?
src/librustdoc/clean/auto_trait.rs
Outdated
|
||
debug!("get_auto_trait_impls({:?})", ty); | ||
let auto_traits = self.cx.auto_traits.iter().cloned(); | ||
let auto_traits: Vec<_> = self.cx.borrow().auto_traits.iter().cloned().collect(); |
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.
Is this collect
being added because otherwise there were borrowck errors?
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.
Yes, otherwise self.cx
is used both here and inside the filter_map
closure at the same time (auto_traits
borrows from cx
and .clean(cx)
requires unique access to the reference).
Yes.
|
Well, these were certainly necessary (#82020 (comment)):
but these may have been extraneous:
I'll go through the changes again and see if I can revert them. |
src/librustdoc/clean/auto_trait.rs
Outdated
let replaced = p.fold_with(&mut replacer); | ||
let (orig_p, p) = (replaced, replaced.clean(cx)); | ||
|
||
let (orig_p, p) = (p, p.clean(self.cx)); |
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.
This seems like a behavior change.
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 not actually - it's just that the predicate is folded above (in clean_where_predicates
) instead of here. It looks confusing because you're only looking at 2 commits, not the full diff.
Am I right in thinking that this will make getting rid of the |
Much so, yes. That would be a good follow up pr, but I didn't want to do it here because it's already +-300. |
Yeah, I might try doing it after this PR if that's okay with you :) |
This comment has been minimized.
This comment has been minimized.
What do you think of undoing the move to free functions? It's probably better overall to use free functions, but it makes reviewing the diffs a lot harder. I used the |
@camelid I tried switching this to have all associated functions and got a lifetime error I don't understand:
Would you be ok with keeping |
Yikes, that is an intimidating error!
Sure, sounds fine :) |
Even aside from the lifetimes issues, |
⌛ Testing commit 2bc5a0a with merge 4feaa67310cf0a309ec956cfb090eba893203fc9... |
💥 Test timed out |
@bors retry Reported that this keeps timing out, I find it hard to believe it could be related to this change: https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/i686-gnu*.20jobs.20keep.20timing.20out |
☀️ Test successful - checks-actions |
A job failed! Check out the build log: (web) (plain) Click to see the possible cause of the failure (guessed by this bot)
|
Seems like a bug in the toolstate program. cc @rust-lang/infra |
Also, it seems surprising that Miri no longer builds after this PR. The only rustc change shouldn't affect Miri and should be backwards-compatible. |
I left some of them so this change doesn't balloon in size and because removing the RefCell in `DocContext.resolver` would require compiler changes. Thanks to `@jyn514` for making this a lot easier with rust-lang#82020!
Remove many RefCells from DocContext I left some of them so this change doesn't balloon in size and because removing the RefCell in `DocContext.resolver` would require compiler changes. Thanks to `@jyn514` for making this a lot easier with rust-lang#82020! r? `@jyn514`
FnMut
inrustc_trait_selection::find_auto_trait_generics
&mut DocContext
in most ofclean
This combined with #82018 should hopefully help with #82014 by allowing
cx.cache.exported_traits
to be modified inregister_res
. Previously it had to use interior mutability, which required either adding a RefCell tocache.exported_traits
on top of the existingRefCell<Cache>
or mixing reads and writes betweencx.exported_traits
andcx.cache.exported_traits
. I don't currently have that working but I expect it to be reasonably easy to add after this.