Skip to content

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

@coastalwhite

Description

@coastalwhite

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

Activity

Nemo157

Nemo157 commented on Mar 11, 2021

@Nemo157
Member

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

Nemo157 commented on Mar 11, 2021

@Nemo157
Member

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

Nemo157 commented on Mar 11, 2021

@Nemo157
Member

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.

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.[/+] on Mar 11, 2021
coastalwhite

coastalwhite commented on Mar 11, 2021

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

Nemo157 commented on Mar 11, 2021

@Nemo157
Member

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

jyn514 commented on Mar 11, 2021

@jyn514
Member

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

Nemo157 commented on Mar 11, 2021

@Nemo157
Member

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

jyn514 commented on Mar 11, 2021

@jyn514
Member

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.

added
A-buildsArea: Building the documentation for a crate
C-bugCategory: This is a bug
on Mar 11, 2021
GuillaumeGomez

GuillaumeGomez commented on Mar 11, 2021

@GuillaumeGomez
Member

Checking what's wrong.

GuillaumeGomez

GuillaumeGomez commented on Mar 11, 2021

@GuillaumeGomez
Member

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

GuillaumeGomez

GuillaumeGomez commented on Mar 11, 2021

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

GuillaumeGomez commented on Mar 11, 2021

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

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-buildsArea: Building the documentation for a crateC-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @Nemo157@GuillaumeGomez@coastalwhite@jyn514

      Issue actions

        docs.rs reuses crate-specific resources from `empty_library` for other crates · Issue #1313 · rust-lang/docs.rs