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

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

Open
mockersf opened this issue Jan 14, 2022 · 1 comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@mockersf
Copy link
Contributor

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

@mockersf mockersf added the C-bug Category: This is a bug. label Jan 14, 2022
@bjorn3 bjorn3 added A-doctests Area: Documentation tests, run by rustdoc A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-doctests Area: Documentation tests, run by rustdoc labels Jan 14, 2022
@jyn514
Copy link
Member

jyn514 commented Jan 16, 2022

#81979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants