Skip to content
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 DefIds in rustdoc #84707

Merged
merged 1 commit into from
May 4, 2021

Conversation

Stupremee
Copy link
Member

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 29, 2021
@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 29, 2021
@Stupremee Stupremee force-pushed the remove-fake-defids-in-rustdoc branch from f63da48 to b5293a5 Compare April 29, 2021 19:38
@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member

camelid commented Apr 29, 2021

Wow, thank you for working on this! expect_real was a good idea :)

src/librustdoc/clean/types.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/types.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/types.rs Show resolved Hide resolved
src/librustdoc/clean/types.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/types.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/utils.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/collect_trait_impls.rs Outdated Show resolved Hide resolved
@Stupremee Stupremee marked this pull request as ready for review May 1, 2021 12:05
@Stupremee Stupremee added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 1, 2021
Copy link
Member

@jyn514 jyn514 left a 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/clean/inline.rs Outdated Show resolved Hide resolved
src/librustdoc/core.rs Outdated Show resolved Hide resolved
@@ -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>>,
Copy link
Member

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?

Copy link
Member Author

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

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())
Copy link
Member

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.

{
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
self.cache.paths.insert(
item.def_id.expect_real(),
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

@@ -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>)> {
Copy link
Member

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?

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2021
@jyn514
Copy link
Member

jyn514 commented May 1, 2021

@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?

@Stupremee
Copy link
Member Author

std documents just fine. I will rebase now

@Stupremee Stupremee force-pushed the remove-fake-defids-in-rustdoc branch from 6621591 to 5a3f9c4 Compare May 1, 2021 15:41
@Stupremee
Copy link
Member Author

Everything should be ready now 🎉

@camelid
Copy link
Member

camelid commented May 1, 2021

@bors rollup=never

This should make it easier to bisect if we get ICE reports.

@bors
Copy link
Contributor

bors commented May 3, 2021

☔ The latest upstream changes (presumably #84840) made this pull request unmergeable. Please resolve the merge conflicts.

@Stupremee Stupremee force-pushed the remove-fake-defids-in-rustdoc branch from 327262e to d3274e3 Compare May 4, 2021 12:46
@Stupremee
Copy link
Member Author

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

@jyn514
Copy link
Member

jyn514 commented May 4, 2021

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?

@jyn514
Copy link
Member

jyn514 commented May 4, 2021

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!

@Stupremee
Copy link
Member Author

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.

@Manishearth
Copy link
Member

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 DefId mean something different in rustdoc

@Stupremee
Copy link
Member Author

Yes. Thats what I pushed right now. Use FakeDefId whereever required and in some more places, and use DefId for ids that are guaranteed to be real

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a 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!

@GuillaumeGomez
Copy link
Member

We'll now be waiting for the follow-up PRs. ;)

@bors: r=jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented May 4, 2021

📌 Commit b6120bf has been approved by jyn514,GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 4, 2021
@bors
Copy link
Contributor

bors commented May 4, 2021

⌛ Testing commit b6120bf with merge ae8b84b...

@bors
Copy link
Contributor

bors commented May 4, 2021

☀️ Test successful - checks-actions
Approved by: jyn514,GuillaumeGomez
Pushing ae8b84b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 4, 2021
@bors bors merged commit ae8b84b into rust-lang:master May 4, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 4, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 9, 2021
…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`.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 15, 2021
…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`.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 15, 2021
…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`.
pnkfelix added a commit to pnkfelix/rust that referenced this pull request Jun 10, 2021
…lang#82465.

(update: placated tidy)
(update: rebased post PR rust-lang#84707 )

merge me
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this pull request Jun 19, 2021
@Stupremee Stupremee deleted the remove-fake-defids-in-rustdoc branch June 26, 2021 12:03
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 6, 2021
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of fake DefIds in rustdoc
10 participants