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

intra-rustdoc links fail for the pointer primitive type #87289

Closed
hawkw opened this issue Jul 19, 2021 · 3 comments
Closed

intra-rustdoc links fail for the pointer primitive type #87289

hawkw opened this issue Jul 19, 2021 · 3 comments
Labels
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.

Comments

@hawkw
Copy link
Contributor

hawkw commented Jul 19, 2021

When attempting to use intra-rustdoc links to link to *const T/*mut T methods (the pointer primitive type in the std docs), the link is not resolved properly.

This minimal reproduction:

#![deny(rustdoc::broken_intra_doc_links)]

/// [std::pointer::offset]
pub struct MyStruct;

fails like this:

:; cargo doc 
 Documenting rustdoc-repro v0.1.0 (/home/eliza/Code/rustdoc-repro)
error: unresolved link to `std::pointer::offset`
 --> src/lib.rs:3:6
  |
3 | /// [std::pointer::offset]
  |      ^^^^^^^^^^^^^^^^^^^^ no item named `pointer` in module `std`
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(rustdoc::broken_intra_doc_links)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not document `rustdoc-repro`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_repro src/lib.rs -o /home/eliza/Code/rustdoc-repro/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/eliza/Code/rustdoc-repro/target/debug/deps --crate-version 0.1.0` (exit status: 1)

I noticed that PR #58642 fixed intra-doc links to methods on other primitive types, but the match added in that change doesn't include pointer:
https://github.com/tspiteri/rust/blob/aa0fa752c455eca11db012be76caa94b15804350/src/librustdoc/passes/collect_intra_doc_links.rs#L607-L625

Meta

This issue occurs on stable rustdoc:
rustdoc --version --verbose:

rustdoc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustdoc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

...and on nightly:
rustdoc --version --verbose:

rustdoc 1.55.0-nightly (59216858a 2021-07-18)
binary: rustdoc
commit-hash: 59216858a323978a97593cba22b5ed84350a3783
commit-date: 2021-07-18
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1
@hawkw hawkw added the C-bug Category: This is a bug. label Jul 19, 2021
@hawkw
Copy link
Contributor Author

hawkw commented Jul 19, 2021

I noticed that PR #58642 fixed intra-doc links to methods on other primitive types, but the match added in that change doesn't include pointer:
https://github.com/tspiteri/rust/blob/aa0fa752c455eca11db012be76caa94b15804350/src/librustdoc/passes/collect_intra_doc_links.rs#L607-L625

It looks like that match also doesn't include the reference, array, slice, or tuple primitive modules that exist in RustDoc.

Interestingly, the slice and array primitives can be linked to, but their methods are not linkable. On the other hand, the reference and tuple primitives cannot be linked to at all.

For example, on the same nightly version I posted above, this code

#![deny(rustdoc::broken_intra_doc_links)]
#![feature(array_map)] // all of `array`'s inherent methods are unstable

/// [std::slice]
/// [std::array]
/// [std::slice::len]
/// [std::array::map]
/// [std::tuple]
/// [std::reference]
pub struct MyStruct;

emits these errors:

 Documenting rustdoc-repro v0.1.0 (/home/eliza/Code/rustdoc-repro)
error: unresolved link to `std::slice::len`
 --> src/lib.rs:6:6
  |
6 | /// [std::slice::len]
  |      ^^^^^^^^^^^^^^^ no item named `len` in module `slice`
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(rustdoc::broken_intra_doc_links)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unresolved link to `std::array::map`
 --> src/lib.rs:7:6
  |
7 | /// [std::array::map]
  |      ^^^^^^^^^^^^^^^ no item named `map` in module `array`

error: unresolved link to `std::tuple`
 --> src/lib.rs:8:6
  |
8 | /// [std::tuple]
  |      ^^^^^^^^^^ no item named `tuple` in module `std`

error: unresolved link to `std::reference`
 --> src/lib.rs:9:6
  |
9 | /// [std::reference]
  |      ^^^^^^^^^^^^^^ no item named `reference` in module `std`

error: could not document `rustdoc-repro`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_repro src/lib.rs -o /home/eliza/Code/rustdoc-repro/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/eliza/Code/rustdoc-repro/target/debug/deps --crate-version 0.1.0` (exit status: 1)

(note that the std::array and std::slice links don't error, but the links to std::slice::len and std::array::map do)

@inquisitivecrystal inquisitivecrystal added 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. labels Jul 19, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 20, 2021

I haven't read each example, but std::slice is not a primitive, it's a module. There are very few modules named after primitives in the standard library, which is why the links don't work. Try removing std::.

@jyn514 jyn514 removed the C-bug Category: This is a bug. label Jul 20, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 24, 2021

I'm going to close this because it's not a bug - feel free to reopen if you're still having trouble after removing std::.

@jyn514 jyn514 closed this as completed Jul 24, 2021
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 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