Skip to content

Cross-crate intra doc links to transitive dependencies are not getting interpreted #2081

Closed as not planned
@dtolnay

Description

@dtolnay

I am trying to reproduce why https://docs.rs/tracing-opentelemetry/0.18.0/tracing_opentelemetry/index.html#special-fields has a broken "span kinds" link. The rendered HTML has <a href="opentelemetry::trace::SpanKind">span kinds</a> which is obviously not what was intended.

According to https://docs.rs/crate/tracing-opentelemetry/0.18.0/builds/632715, the build ran using rustc 1.66.0-nightly (a37499ae6 2022-09-18). I attempted to reproduce the issue as follows:

$ rustup toolchain install nightly-2022-09-19
$ rustc +nightly-2022-09-19 --version  # exact same as docs.rs log
rustc 1.66.0-nightly (a37499ae6 2022-09-18)
$ curl -L https://crates.io/api/v1/crates/tracing-opentelemetry/0.18.0/download -o tracing-opentelemetry-0.18.0.tgz
$ tar tf tracing-opentelemetry-0.18.0.tgz
$ cd tracing-opentelemetry-0.18.0
$ RUSTDOCFLAGS='--cfg docsrs --cap-lints=warn' cargo +nightly-2022-09-19 doc --all-features --open
...
warning: unresolved link to `opentelemetry::trace::StatusCode`
   --> src/lib.rs:30:26
    |
30  | //! [span status codes]: opentelemetry::trace::StatusCode
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `StatusCode` in module `trace`
    |
note: the lint level is defined here
   --> src/lib.rs:115:10
    |
115 |     deny(rustdoc::broken_intra_doc_links),
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unresolved link to `MetricsSubscriber`
  --> src/lib.rs:81:32
   |
81 | //! - `metrics`: Enables the [`MetricsSubscriber`] type, a [subscriber] that
   |                                ^^^^^^^^^^^^^^^^^ no item named `MetricsSubscriber` in scope
   |
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `tracing_subscriber::subscribe`
   --> src/lib.rs:100:19
    |
100 | //! [subscriber]: tracing_subscriber::subscribe
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `subscribe` in module `tracing_subscriber`

warning: `tracing-opentelemetry` (lib doc) generated 3 warnings

I put --cfg docs.rs and --all-features based upon the crate's Cargo.toml: https://docs.rs/crate/tracing-opentelemetry/0.18.0/source/Cargo.toml

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

As you can see, it reproduces the warnings seen in the docs.rs log. However, the generated HTML has a correct link <a href="../opentelemetry_api/trace/span/enum.SpanKind.html">span kinds</a>.

Is docs.rs's build doing something that is materially different from this? In order to make the link work, is this a rustdoc bug or a docs.rs bug? If rustdoc is working correctly, what would need to change in docs.rs to support this kind of link?

cc: @chriskonstad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions