-
Notifications
You must be signed in to change notification settings - Fork 13.6k
rustdoc: never link to unnamable items #143849
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: never link to unnamable items #143849
Conversation
This comment has been minimized.
This comment has been minimized.
fb01811
to
950634d
Compare
rustbot has assigned @GuillaumeGomez. Use |
type Ty = Bar; | ||
} | ||
pub struct Bar; | ||
}; |
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.
Do we need to have this as a dependency for this test? Can't it be done within the current crate?
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.
Also, what happens if the const is named X
?
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.
The bug only happens during cross-crate re-exports. Otherwise a separate failsafe kicks in.
I was under the impression that the _
was a delibraerately injected placeholder, but maybe it is just the constant name, if so we'll need a more principled approach.
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.
Ok, yeah, you're right, my assumptions were wrong. Just looking at the path isn't enough.
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.
Need to check what kind of item (block more precisely) the parent is. If it's not a module, then it's likely wrong.
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.
any idea what datastructure would retain that info in the cross-crate case? I'm somewhat struggling to understand how we even reconstruct path info and such from an rlib.
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.
Path doesn't matter here, you need to check what is its parent.
This comment has been minimized.
This comment has been minimized.
ef5c252
to
0952022
Compare
/// Checks if the given defid refers to an item that is unnamable, such as one defined in a const block. | ||
fn is_unnamable(tcx: TyCtxt<'_>, did: DefId) -> bool { | ||
let mut cur_did = did; | ||
while let Some(parent) = tcx.opt_parent(cur_did) { |
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 think this code is wrong: we can link to an impl associated item even if the impl is in a const/function block.
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.
right, i think impls should break with a return false
and only modules should continue up...
well technically we can only link to an impl item if the thing being impl'd on is nameable, but i'm not sure if that's something observable.
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.
Just discovered that we can have modules in any blocks. Dark magic. XD
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.
Also, if the item is not public, it'll be stripped so should be fine. (for impl block as parents)
0952022
to
aab9c69
Compare
aab9c69
to
05a62c8
Compare
Thanks for the fix! @bors r+ rollup |
Rollup of 7 pull requests Successful merges: - #143849 (rustdoc: never link to unnamable items) - #144683 (Simplify library dependencies on `compiler-builtins`) - #144691 (Extend `is_case_difference` to handle digit-letter confusables) - #144700 (rustdoc-json: Move `#[macro_export]` from `Other` to it's own variant) - #144751 (Add correct dynamic_lib_extension for aix) - #144757 (Ping Muscraft when emitter change) - #144759 (triagebot: Label `compiler-builtins` T-libs) r? `@ghost` `@rustbot` modify labels: rollup
Ping from triage: Looks like this PR introduced a regression in #144768. Based on detailed results, the regression is in the Is this regression expected or justified? |
I expected a regression, but not this big. I'll revert the PR for now and we can iterate over the performance improvement. |
Ok. It doesn't seem that big to require a revert to me, so just to make sure I didn't add confusion here: 10%-20% change Here's the perf run: https://perf.rust-lang.org/compare.html?start=6c02dd4eae83befde07dc4782395e2005055e9fa&end=e3ee7f7aea5b45af3b42b5e4713da43876a65ac9&stat=instructions:u |
Ah I see. Didn't check the report yet so spoke too quickly. Still, we will need to bring down the numbers. :) |
Obvious ideas optimizations:
the former is much easier to implement, but the perf improvement would go away if we ever make normalizing docs the default. the latter should actually be a substantial improvement, but is slightly trickier to implement. I'll see what i can do. |
That's a good start already. I also thought about caching this query with compiler queries. |
I suppose caching would improve things if an item is being linked to from multiple locations, but i do think it would be more ideal to try to simply disable normalization when it would cause a situation like this. |
I meant that in addition to your ideas. I'd like your suggestions to be implemented first, and then we'll see if we need to go further. I'll let you implement your ideas and then we can check perf results on them. |
Making it a query would also cache it across incremental builds, right? that might be worth it. |
fixes #143222