-
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
Get rid of fake DefId
s in rustdoc
#84707
Conversation
f63da48
to
b5293a5
Compare
This comment has been minimized.
This comment has been minimized.
Wow, thank you for working on this! |
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.
Only got about halfway through the changes - the bit about contains_key also applies to lots of other changes.
src/librustdoc/formats/cache.rs
Outdated
@@ -35,18 +35,18 @@ crate struct Cache { | |||
/// | |||
/// The values of the map are a list of implementations and documentation | |||
/// found on that implementation. | |||
crate impls: FxHashMap<DefId, Vec<Impl>>, | |||
crate impls: FxHashMap<RealDefId, Vec<Impl>>, |
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.
Can't these be fake for blanket impls?
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.
pub trait A {}
pub trait B {}
impl<T: B> A for T {}
I don't know, but this documents just fine
src/librustdoc/formats/cache.rs
Outdated
if !self.cache.paths.contains_key(&item.def_id) | ||
|| self.cache.access_levels.is_public(item.def_id) | ||
if !self.cache.paths.contains_key(&item.def_id.expect_real()) | ||
|| self.cache.access_levels.is_public(item.def_id.expect_real()) |
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 isn't the same behavior - before contains_key would return false for fakes. I have a feeling this will ICE.
src/librustdoc/formats/cache.rs
Outdated
{ | ||
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_())); | ||
self.cache.paths.insert( | ||
item.def_id.expect_real(), |
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 have a feeling this will ICE.
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.
Should paths
also accept fake ids, or should we just check if it's real and only then insert it?
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.
Given that this didn't ICE documenting libstd, I'm ok with just leaving it as-is.
src/librustdoc/html/format.rs
Outdated
@@ -442,7 +442,7 @@ impl clean::GenericArgs { | |||
} | |||
} | |||
|
|||
crate fn href(did: DefId, cx: &Context<'_>) -> Option<(String, ItemType, Vec<String>)> { | |||
crate fn href(did: RealDefId, cx: &Context<'_>) -> Option<(String, ItemType, Vec<String>)> { |
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, it seems odd to me this would be real - can't rustdoc generate links to impls? Or is that only intra-doc links?
@Stupremee I didn't realize when reviewing that the test suite was passing - that's probably a better indicator of what's correct than my guessing. Can you document the standard library and make sure there's no panics? And then rebase this? |
|
6621591
to
5a3f9c4
Compare
Everything should be ready now 🎉 |
@bors rollup=never This should make it easier to bisect if we get ICE reports. |
☔ The latest upstream changes (presumably #84840) made this pull request unmergeable. Please resolve the merge conflicts. |
327262e
to
d3274e3
Compare
Should be ready to merge now. Would be good to merge soon so there are not too many conflicts coming and not too many PRs that need to be rebased on this one. r? @jyn514 |
I'd like to figure out #84707 (comment) first, I don't like merging code when I don't understand how it works. @Manishearth @GuillaumeGomez @Aaron1011 maybe one of you have ideas? |
r=me with Guillaume's comment addressed, this already showing I don't have a good intuition for which ids are fake and which aren't 😆 so it's super helpful! |
In the future someone could even do a follow up PR and try to minimize the amount of fake DefId's. I might even do that now when renaming everything. |
That's fair. To be clear, "the renaming" is creating a FakeDefId wrapper and using it everywhere, right? As I said I'm against having |
Yes. Thats what I pushed right now. Use |
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 to me now, thanks!
We'll now be waiting for the follow-up PRs. ;) @bors: r=jyn514,GuillaumeGomez |
📌 Commit b6120bf has been approved by |
☀️ Test successful - checks-actions |
…efids, r=jyn514,GuillaumeGomez Minimize amount of fake `DefId`s used in rustdoc Follow up from rust-lang#84707, which minimizes the amount of fake defids to the smallest amount possible. Every `FakeDefId` that is now used in the rustdoc library must be preserved and can not be replaced with a normal `DefId`.
…efids, r=jyn514,GuillaumeGomez Minimize amount of fake `DefId`s used in rustdoc Follow up from rust-lang#84707, which minimizes the amount of fake defids to the smallest amount possible. Every `FakeDefId` that is now used in the rustdoc library must be preserved and can not be replaced with a normal `DefId`.
…efids, r=jyn514,GuillaumeGomez Minimize amount of fake `DefId`s used in rustdoc Follow up from rust-lang#84707, which minimizes the amount of fake defids to the smallest amount possible. Every `FakeDefId` that is now used in the rustdoc library must be preserved and can not be replaced with a normal `DefId`.
…lang#82465. (update: placated tidy) (update: rebased post PR rust-lang#84707 ) merge me
…lang#82465. (update: placated tidy) (update: rebased post PR rust-lang#84707 ) merge me
…mid, r=jyn514 rustdoc: Replace `FakeDefId` with new `ItemId` type Follow up from rust-lang#84707 `@Manishearth` [suggested](rust-lang#84707 (comment)) that there should be a new `ItemId` type that can distinguish between auto traits, normal ids, and blanket impls instead of using `FakeDefId`s. This type is introduced by this PR. There are still some `FIXME`s left, because I was unsure what the best solution for them would be. Especially the naming in general now is a bit weird right now and needs to be cleaned up. Now there are no "fake" ids so the `is_fake` method on `Item` does not really make sense and maybe the methods on `ItemId` should be renamed too? Also, we need to represent the new item ids in the JSON backend somehow.
Right now there are many errors left, but I wanted to show the current state since all that is left to do is fixing the errors.
Resolves #83183
r? @jyn514