Skip to content

rustdoc fails to build an intra doc link when linking through 3 crates without explicit use #92910

Open
@mockersf

Description

@mockersf

With three crates:

  • Crate C export a public struct
  • Crate B depends on crate C and export a public struct with doc linking to the crate C pub item
  • Crate A reexport everything from crate B

When building doc for crate A, the intra doc link will not work without a warning.

This is what's happening in Bevy on the doc for DefaultPlugins (bevyengine/bevy#3654).

I managed to write a UI test reproducing the issue: mockersf@1c4d478

Test failure message

14: @has check failed
	`XPATH PATTERN` did not match
	// @has 'issue_zzzz/struct.Reexported.html' '//div[@class="docblock"]/p/a[@href="../issue_zzzz_internal/struct.Internal.html"]' 'issue_zzzz_internal::Internal'

Encountered 1 errors

Screenshot 2022-01-15 at 00 00 31

The link is not replaced, even though rustdoc was able to correctly link the struct in the definition.
If I uncomment the `extern crate` in the reexported crate (crate B from above), the link works

Screenshot 2022-01-15 at 00 00 00

Ideally I would like the link to work. I'm guessing it's something about the external crate not being in context for link resolution when it's not explicitly used, but it seems it is later on as the link is correct for the struct definition. I tried to follow the code to where the context could be different between the two but didn't manage to find it.

If it's not possible, would it be OK to issue a warning?

Meta

Reproduced with rust 1.57, 1.58, nightly 1bd4fdc 2022-01-12 and 256721e

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions