-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 regression: intra-doc link links to wrong item #136777
Comments
I reproduced this regression in the master branch: tests/rustdoc/auxiliary/macro-bar.rs //@ force-host
//@ no-prefer-dynamic
//@ compile-flags: --crate-type proc-macro
#![crate_type="proc-macro"]
#![crate_name = "bar"]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn a1(_attr: TokenStream, item: TokenStream) -> TokenStream {
item
} tests/rustdoc/issue-136777.rs //@ aux-build:macro-bar.rs
#![crate_name = "foo"]
extern crate bar;
//@ has foo/attr.new_a1.html '//a/@href' 'attr.a1.html'
/// Link to [`a1`].
pub use bar::a1 as new_a1;
pub use bar::a1; error code% ./x test tests/rustdoc/issue-136777.rs ... running 1 tests[rustdoc] tests/rustdoc/issue-136777.rs ... F failures: error: htmldocck failed! Encountered 1 errors@rustbot claim |
After investigation, I found that this is a corner case of making internal link: BisectAfter #134806 is merged, this problem is occurred. Background: internal behavior of making a linkRustdoc creates a link from [ Behavior in the current stable
/// Link to [`d2`].
pub use std::debug_assert as d1;
/// Link to [`d1`].
pub use std::debug_assert as d2;
/// Link to [`d2`].
pub use std::debug_assert as d3; Behavior after the PR above
So if you change the order of your re-export items, I think the link will be fixed (of course this is not a fundamental solution). |
As I wrote above, both the current master and the stable have the issue. Ideally we should modify it, but we need to change the internal structure of Rustdoc (for example, Cache may need to have multiple values for one item_def_id. But it may break other part). Since this is a corner case, I think 1) deciding what the current proper behavior (first win or last win) of it, then 2) adding an unit test to ensure the decision, is good for a temporary solution. Since I have limited knowledge around Rustdoc, I want to ask someone in Rustdoc team if there is a better way (probably @GuillaumeGomez ?) |
Reproduction steps
I tried to document
autocxx::subclass::is_subclass()
from the autocxx crate (docs.rs page), which has the following doc comment:I expected to see this happen: the
subclass
link points to the documentation for thesubclass
item defined in the same file. This is indeed what happens on stable,rustdoc 1.84.1 (e71f9a9a9 2025-01-27)
.Instead, this happened: the
subclass
link points to the documentation for theis_subclass
item—the same page I'm already on! This happens onrustdoc 1.86.0-nightly (ad211ced8 2025-01-07)
, currently in use by docs.rs, as well as today's beta (rustdoc 1.85.0-beta.8 (38213856a 2025-02-06)
) and today's nightly (rustdoc 1.86.0-nightly (942db6782 2025-02-06)
).Sorry this example is using a real crate rather than a minimized test case. I haven't taken the time to dig any deeper than what I've written here, but I can if it'd be helpful.
Version it worked on
It most recently worked on: rustdoc 1.84.1
Version with regression
rustdoc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
The text was updated successfully, but these errors were encountered: