-
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] If re-export is private, get the next item until a public one is found or expose the private item directly #113374
[rustdoc] If re-export is private, get the next item until a public one is found or expose the private item directly #113374
Conversation
I haven't looked too much at the implementation yet but do you think it'd be worthwhile to kick off a perf run since it looks like in the worst case this is running a nested loop with a nesting level of up to 4 (!) whenever it cleans a hir qpath. |
Good point! @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 573a7f4ee75cbd7640143e6687d9d06cec1d7062 with merge cfeb9c6f60982932992f2550ba9b986fcc4e9ef7... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (cfeb9c6f60982932992f2550ba9b986fcc4e9ef7): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 658.838s -> 658.176s (-0.10%) |
Seems like the regression isn't too big. At least way less than what I originally feared. |
Yay, seems like it! Or our benchmark & stress test suite is not big enough :P I'm gonna go over the changes tonight or tomorrow hopefully if I find the time. I wonder if there is any rustc API in |
The problem here is trying to retrieve the
It's a possibility indeed! :)
Thanks! |
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 there no facility to accomplish this already in the compiler? I know it suggests paths to import, which means it should try to avoid giving inaccessible ones.
If not, here's a suggestion for fixing (and more thoroughly testing) this function.
I didn't find them at least. Doesn't mean they don't exist, but I missed them if they do. |
I applied your suggestions @notriddle, thanks a lot! |
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.
Looks good. Awaiting fmease’s feedback
a813891
to
662530d
Compare
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.
Let's say I'm not super familiar with this area of the code (fetching things from HIR and how re-exports are represented) but it looks reasonable.
for child in | ||
cx.tcx.module_children_local(parent_def_id).iter().filter(move |c| c.ident == ident) | ||
{ | ||
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = child.res { |
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.
Of course, we could at some point support Ctor
but that's low priority. This would only be reachable with const generics (and const items if/once we render their body). E.g. Container<{ Alias }>
with use Type::Ctor as Alias
.
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.
For now it's something we exclude everywhere in rustdoc when looking for reexports. We can indeed add support for it later on.
src/librustdoc/clean/mod.rs
Outdated
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { | ||
continue; | ||
} | ||
if !cx.tcx.is_doc_hidden(use_def_id) && |
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 doesn't respect --document-private-items
and --document-hidden-items
. Not sure what the desired behavior would be though. Do we want to keep showing the private or hidden alias when such a flag is passed? Not blocking.
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 was planning to actually fix it in a follow-up (all set-up in my calendar and everything :D).
662530d
to
1d1951b
Compare
Updated the function name. |
0f35e59
to
6861f33
Compare
Added the handling for |
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.
Technically speaking, edition:2015
isn't necessary because it's the default in tests but I like that it's there since it makes it explicit to the reader.
It makes me a bit uneasy that we straight up interpret kw::PathRoot
as kw::Crate
in any old edition instead of checking parent.ident.span.is_rust_2015()
first (if that's actually how you properly check this), although I'm not sure if it can cause any problems right now. For example in Rust 2018+, ::dep
always refers to a crate but it's unclear to me if in such case fn first_non_private
is actually reached (e.g. I've quickly tried pub use ::dep as alias;
but that didn't lead to first_non_private
being called).
Edit: I think we are good to go. Thanks for working on it and for considering my feedback! :)
Edit: (Typo in commit message: Correctly handly super
and ::
)
6861f33
to
4a1e06b
Compare
To use @notriddle's, I needed to the remove the cache since I need a mutable access to @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 2461d0c with merge 5224c258f207a3f5b4c32980f776a9317118ef1e... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (5224c258f207a3f5b4c32980f776a9317118ef1e): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 652.287s -> 652.99s (0.11%) |
So to sum things up:
I think the current result is good enough. What do you think @notriddle ? |
They all seem close enough to me. |
Yep, hence why I suggest to keep the current implementation (the one you suggested) without |
@bors r=notriddle,fmease |
@bors rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (9339f44): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 654.151s -> 654.227s (0.01%) |
@GuillaumeGomez This looks very much like a real regression (the spike in the graph below is the change caused by this PR): Looks like we might be spending much more time in |
It's exactly as showed by the perf results. We considered the perf regression to be acceptable in regard to the fix. |
Marking as triaged then @rustbot label: +perf-regression-triaged |
(it already was marked as |
Fixes #81141.
If we have:
Then
Something
will be replaced byPrivate
.r? @notriddle