Skip to content

Rustdoc: regression in intra-doc link to trait function #92662

Closed
@rnarubin

Description

@rnarubin

Code

Example code:

#![deny(rustdoc::broken_intra_doc_links)]

use std::marker::PhantomData;

pub trait Bar<T> {
    fn bar(&self);
}

pub struct Foo<U>(PhantomData<U>);

impl<T, U> Bar<T> for Foo<U> {
    fn bar(&self) {}
}

/// link to [`Foo::bar`]
fn main() {}

Version it worked on

docs build successfully on 1.57.0:

$ cargo +1.57.0 --version
cargo 1.57.0 (b2e52d7ca 2021-10-21)
$ cargo +1.57.0 doc
 Documenting trait-link-example v0.1.0 (/tmp/trait-link-example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.53s

Version with regression

docs fail to build on 1.59.0-nightly (358e79fe5 2022-01-04):

$ cargo +nightly-2022-01-07 --version
cargo 1.59.0-nightly (358e79fe5 2022-01-04)
$ cargo +nightly-2022-01-07 doc
 Documenting trait-link-example v0.1.0 (/tmp/trait-link-example)
error: unresolved link to `Foo::bar`
  --> src/main.rs:15:15
   |
15 | /// link to [`Foo::bar`]
   |               ^^^^^^^^ the struct `Foo` has no field or associated item named `bar`
   |
note: the lint level is defined here
  --> src/main.rs:1:9
   |
1  | #![deny(rustdoc::broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not document `trait-link-example`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type bin --crate-name trait_link_example src/main.rs -o /tmp/trait-link-example/target/doc --error-format=json --json=diagnostic-rendered-ansi,future-incompat --document-private-items -C metadata=af2f029e3f5db9a3 -L dependency=/tmp/trait-link-example/target/debug/deps --crate-version 0.1.0` (exit status: 1)

The generics appear necessary for the bug. Removing them from either the type or the trait resolves the failure.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions