-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[EXPERIMENT] rustdoc: Cleanup external_traits
#90365
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
Changes from all commits
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 |
---|---|---|
|
@@ -85,15 +85,6 @@ crate trait DocFolder: Sized { | |
|
||
fn fold_crate(&mut self, mut c: Crate) -> Crate { | ||
c.module = self.fold_item(c.module).unwrap(); | ||
|
||
{ | ||
let external_traits = { std::mem::take(&mut *c.external_traits.borrow_mut()) }; | ||
for (k, mut v) in external_traits { | ||
v.trait_.items = | ||
v.trait_.items.into_iter().filter_map(|i| self.fold_item(i)).collect(); | ||
c.external_traits.borrow_mut().insert(k, v); | ||
} | ||
} | ||
Comment on lines
-89
to
-96
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 think this is the only part of the change that could break something. Locally, 2 tests failed, but with strange 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. Removing this altogether does not seem right, you're no longer running any passes on associated trait items at all. Try keeping the same logic from before but just removing the borrow_mut(). 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. Ok, I'll try that. If it works, it'll at least be incremental progress over the current situation :) 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. Wait, just removing the 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. Do you have access to a DocContext from within this method? If not, you can change DocFolder to add a method returning a reference to it. 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. Ah, I see what you mean. That's an interesting idea, I'll see if that's possible. |
||
c | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,13 +138,12 @@ impl Cache { | |
/// in `krate` due to the data being moved into the `Cache`. | ||
crate fn populate( | ||
&mut self, | ||
mut krate: clean::Crate, | ||
tcx: TyCtxt<'_>, | ||
mut krate: clean::Crate, | ||
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. nit: there's no need to reorder these parameters 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. Yeah, though generally we pass 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 haven't spotted much of a pattern for this; I would rather keep the old order to reduce churn. 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. Ok, I'll change it back then. |
||
render_options: &RenderOptions, | ||
) -> clean::Crate { | ||
// Crawl the crate to build various caches used for the output | ||
debug!(?self.crate_version); | ||
self.traits = krate.external_traits.take(); | ||
let RenderOptions { extern_html_root_takes_precedence, output: dst, .. } = render_options; | ||
|
||
// Cache where all our extern crates are located | ||
|
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.
Hmm, this implies
ctxt.cache
andctxt.external_traits
don't need to be separate fields, right? Could we store them in the cache to start so it's less stateful? Right now this depends on the field being assigned just beforepopulate
and nowhere else for correctness.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'll try that.