Skip to content

Intra-doc link should rule out hidden items when resolving ambiguous link #130233

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

Closed
dtolnay opened this issue Sep 11, 2024 · 1 comment · Fixed by #131691
Closed

Intra-doc link should rule out hidden items when resolving ambiguous link #130233

dtolnay opened this issue Sep 11, 2024 · 1 comment · Fixed by #131691
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

@dtolnay
Copy link
Member

dtolnay commented Sep 11, 2024

pub struct Thing {}

#[doc(hidden)]
#[allow(non_snake_case)]
pub fn Thing() {}

/// Do stuff with [`Thing`].
pub fn repro(_: Thing) {}
$ cargo doc

warning: `Thing` is both a function and a struct
 --> src/lib.rs:7:21
  |
7 | /// Do stuff with [`Thing`].
  |                     ^^^^^ ambiguous link
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
help: to link to the function, add parentheses
  |
7 | /// Do stuff with [`Thing()`].
  |                          ++
help: to link to the struct, prefix with `struct@`
  |
7 | /// Do stuff with [`struct@Thing`].
  |                     +++++++

I expected to see this happen: No broken_intra_doc_links warning. [`Thing`] works and means the same thing as [`struct@Thing`], because [`Thing()`] has been ruled out for being hidden. Explicitly writing [`Thing()`] produces a broken link. Only when documented with --document-hidden-items is there an ambiguity.

Instead, this happened: [`Thing`] and [`Thing()`] each produce broken link.

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (0ee7cb5e3 2024-09-10)
binary: rustc
commit-hash: 0ee7cb5e3633502d9a90a85c3c367eccd59a0aba
commit-date: 2024-09-10
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
@dtolnay dtolnay added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Sep 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 11, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 12, 2024
@GuillaumeGomez
Copy link
Member

Sending a fix.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 14, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 14, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 2, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 8, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 8, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 10, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 14, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 16, 2024
…er-out-2, r=notriddle

Delay ambiguous intra-doc link resolution after `Cache` has been populated

Fixes rust-lang#130233.

I was getting nowhere with rust-lang#130278. I took a wrong turn at some point and ended making way too many changes so instead I started again back from 0 and this time it worked out as expected.

r? `@notriddle`
Urgau added a commit to Urgau/rust that referenced this issue Oct 16, 2024
…er-out-2, r=notriddle

Delay ambiguous intra-doc link resolution after `Cache` has been populated

Fixes rust-lang#130233.

I was getting nowhere with rust-lang#130278. I took a wrong turn at some point and ended making way too many changes so instead I started again back from 0 and this time it worked out as expected.

r? ``@notriddle``
@bors bors closed this as completed in 87c31fe Oct 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 16, 2024
Rollup merge of rust-lang#131691 - GuillaumeGomez:intra-doc-link-filter-out-2, r=notriddle

Delay ambiguous intra-doc link resolution after `Cache` has been populated

Fixes rust-lang#130233.

I was getting nowhere with rust-lang#130278. I took a wrong turn at some point and ended making way too many changes so instead I started again back from 0 and this time it worked out as expected.

r? ```@notriddle```
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
4 participants