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

docs.rs reuses crate-specific resources from empty_library for other crates #1313

Closed
coastalwhite opened this issue Mar 10, 2021 · 14 comments · Fixed by #1317 or #1324
Closed

docs.rs reuses crate-specific resources from empty_library for other crates #1313

coastalwhite opened this issue Mar 10, 2021 · 14 comments · Fixed by #1317 or #1324
Labels
A-builds Area: Building the documentation for a crate C-bug Category: This is a bug

Comments

@coastalwhite
Copy link

coastalwhite commented Mar 10, 2021

Docs.rs shows 'empty_library' in the sidebar and has no search results other than empty_library.

Original bug report

When publishing a no_std crate without dependencies, it will add an empty_library to the crates on [docs.rs].

Reproduction steps:

  1. Publish a no_std library without dependencies.
  2. The docs.rs page will now have a empty_library in the crates.

This seems like a rather awkward way to tell the reader the crate has no dependencies. Now if you click any deeper into the documentation, on the left (under the crates header) the empty_library will be a clickable link that leads to a dead link.

This is what I mean: Link to CRC8-RS Docs

@Nemo157
Copy link
Member

Nemo157 commented Mar 11, 2021

Not specific to no-std libraries, seems to have started happening within the last month or so, either a docs.rs, rustwide or rustdoc change. Skimming the docs.rs merge requests none stand out to me as potentially causing this.

@Nemo157
Copy link
Member

Nemo157 commented Mar 11, 2021

More specifically it appears to have changed between

rustc 1.52.0-nightly (45b3c2851 2021-03-04) docsrs 0.6.0 (da1f362 2021-03-05)

and

rustc 1.52.0-nightly (caca2121f 2021-03-05) docsrs 0.6.0 (918ee5d 2021-03-06)

(from comparing https://docs.rs/syn/1.0.62/syn/ and https://docs.rs/syn/1.0.61/syn/)

docs.rs changes: da1f362...918ee5d
rustdoc changes: rust-lang/rust@45b3c28...caca212

@Nemo157
Copy link
Member

Nemo157 commented Mar 11, 2021

To confirm I went back through the release pages and found the exact builds which changed behaviour, https://docs.rs/near-runtime/4.0.0-pre.1/near_runtime/ was the last build that didn't show empty_library, and https://docs.rs/mangadex-api/0.2.4/mangadex_api/ was the first build that showed it (currently on page https://docs.rs/releases/recent/59, but will be moving further back as more builds happen). These were both with docs.rs da1f362, but the rustc version changed.

@coastalwhite coastalwhite changed the title Publishing a no_std crate without dependencies causes a empty_library dependency. Publishing a crate without dependencies causes a empty_library dependency. Mar 11, 2021
@coastalwhite
Copy link
Author

Would this then be a rustdoc issue, and should I open one over there?

I am not getting this behaviour, when just normally compiling documentation on my local machine. It could be that there are some flags of rustdoc that are bugged.

@Nemo157
Copy link
Member

Nemo157 commented Mar 11, 2021

It seems like it's a change in rustdoc behaviour, but it is docs.rs specific, we use empty_library as a dummy library. It might be that we need to change something here to workaround whatever changed rather than changing rustdoc. (I skimmed the PRs, and couldn't see anything that would have changed rustdoc's behaviour in that release 🤷).

const DUMMY_CRATE_NAME: &str = "empty-library";

@jyn514
Copy link
Member

jyn514 commented Mar 11, 2021

I'd expect this to be a regression from rust-lang/rust#80845, cc @GuillaumeGomez. Do we maybe keep the artifacts from the empty_library crate around when documenting other crates?

@Nemo157
Copy link
Member

Nemo157 commented Mar 11, 2021

Huh, weird that that PR doesn't appear in the compare view though? Looks like that would be in the 2021-03-06/07 nightly, not the 2021-03-05 one.

@jyn514
Copy link
Member

jyn514 commented Mar 11, 2021

Oh oops I was looking at the wrong dates. These are the changes between the toolchains:

$ git log 45b3c2851..caca2121f --oneline src/librustdoc/
8fd946c63a6 Auto merge of #82795 - m-ou-se:rollup-uzx0b92, r=m-ou-se
ad919154557 Remove unused code from main.js
2f28361936f Rollup merge of #82088 - Nicholas-Baron:shorten_html_render, r=GuillaumeGomez
1683cb12e44 Use cache access levels
e4287992a7b No more need for borrow call
ad30c39918c Pass TyCtxt directly instead of DocContext in librustdoc::visit_ast::inherits_doc_hidden
186f13914a8 Move visibility check inside the should_have_doc_example function
4b30625094e Don't warn for `missing_doc_examples` when item is #[doc(hidden)]
afb8220d0af Corrected imports for render tests and mod files
fd14e386123 Moved `write_shared` to its own file
14983b9812e Moved the `make_item_keywords` function to `context.rs` as it is only used there
6c7d7a6bf4b Moved `print_item` and helpers to a separate file
48167c499aa Moved Context and its impls to a separate file

It would be helpful if someone could bisect them.

@jyn514 jyn514 added A-builds Area: Building the documentation for a crate C-bug Category: This is a bug labels Mar 11, 2021
@GuillaumeGomez
Copy link
Member

Checking what's wrong.

@GuillaumeGomez
Copy link
Member

It's an interesting "bug" from rustdoc indeed. Sending a fix.

@GuillaumeGomez
Copy link
Member

Actually no, it's not a bug from rustdoc. Here how it works for rustdoc: crates.js list the crates from search-index.js. Meaning that at some point, the file isn't empty as it should. The problem here is that the rustdoc update wasn't fully integrated into docs.rs.

@GuillaumeGomez
Copy link
Member

So here, I see two possibilities:

  1. We remove crates.js from the folder
  2. We don't generate crates.js when the --disable-per-crate-search argument is passed in rustdoc.

Which solution do you prefer?

@GuillaumeGomez
Copy link
Member

I precise that the second option seems unreliable considering that crates.js isn't only used for search but also to list crates in the sidebar.

@GuillaumeGomez
Copy link
Member

I can't find where you clean/remove the search-index.js file. Any pointer maybe? :)

jyn514 added a commit to jyn514/docs.rs that referenced this issue Mar 20, 2021
When serving 'essential files', we can either serve the global one,
created when building `empty_library`, or the local one, created when
building the local crate. Currently we default to the global one, but
this causes issues when the file should never have been global in the
first place (such as recently for `crates.js`: see
rust-lang#1313).

This gives precedence to the local file so that the bug will be fixed
when rustdoc fixes it, even if we forget to update
`ESSENTIAL_FILES_UNVERSIONED`.
jyn514 added a commit to jyn514/docs.rs that referenced this issue Mar 21, 2021
When serving 'essential files', we can either serve the global one,
created when building `empty_library`, or the local one, created when
building the local crate. Currently we default to the global one, but
this causes issues when the file should never have been global in the
first place (such as recently for `crates.js`: see
rust-lang#1313).

This gives precedence to the local file so that the bug will be fixed
when rustdoc fixes it, even if we forget to update
`ESSENTIAL_FILES_UNVERSIONED`.
@jyn514 jyn514 changed the title Publishing a crate without dependencies causes a empty_library dependency. docs.rs reuses crate-specific resources from empty_library for other crates Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builds Area: Building the documentation for a crate C-bug Category: This is a bug
Projects
None yet
4 participants