Skip to content

[rustdoc] jump-to-def invalid link generated with #[rustc_allow_incoherent_impl] #163112

Description

@GuillaumeGomez

Can be reproduced with this code (each crate depend on the previous one):

baz.rs:

#![feature(rustc_attrs)]
#![allow(internal_features)]

#[rustc_has_incoherent_inherent_impls]
pub struct Error;

bar.rs:

#![feature(rustc_attrs)]
#![allow(internal_features)]

pub mod error {
    pub use baz::Error;
}

impl baz::Error {
    #[rustc_allow_incoherent_impl]
    pub fn new() -> Self {
        Self
    }
}

lib.rs:

fn foo() {
    let x = bar::error::Error::new();
}

When generating docs with --generate-link-to-definition, the link for the Error::new method points to ../../bar/struct.Error.html#method.new, but that's the path for baz::Error, not for bar::Error.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    A-link-to-definitionrustdoc --generate-link-to-definition nightly-only feature
    on Sep 21, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 21, 2026
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 21, 2026
  4. maxdexh commented on Sep 21, 2026

    @maxdexh
    Member

    See also #161699

  5. GuillaumeGomez commented on Sep 21, 2026

    @GuillaumeGomez
    MemberAuthor

    Same root origin, different fix sadly. :-/ (I think)

  6. added a commit that references this issue on Sep 25, 2026
    4d11d37
  7. added a commit that references this issue on Sep 26, 2026
    061c90a
  8. added a commit that references this issue on Sep 26, 2026
    6406f6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-link-to-definitionrustdoc --generate-link-to-definition nightly-only featureC-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