-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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-doc links are not resolved in inherited docs from upstream traits #73829
Comments
cc @jyn514 who has been doing some work in this area recently. |
I expect this to be fixed by #73101. I'll test locally. |
Interesting, it was not fixed - rustdoc resolves links for associated items relative to the type, not relative to the trait. The lack of warning is definitely a bug, but I'm not sure the behavior is incorrect.
|
Oh hold on that shouldn't make a difference - the trait is in scope in both places. I have to look at this more, I'm not sure what's going on. |
It's worth mentioning that these impl method docs are subtly broken in other ways (see my linked PR above) but as long as you use inline links you should be able to avoid those bugs. |
Reduced test case: // inner.rs
/// [SomeType] links to [bar]
pub struct SomeType;
pub trait SomeTrait {}
/// [bar] links to [SomeTrait] and also [SomeType]
pub mod bar {}
All the links on the documentation for |
This code looks wrong: rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 436 to 441 in 6742382
Not sure if it's related to the |
I have a fix for this in #73101. Thanks for the bug report! |
Update so all the discussion is in one place: My fix didn't do what I thought (it only worked for modules, not docs taken from the trait parent). However it will depend on the changes in #73101, so I'm leaving this be for now until that lands. |
... I think I found why this is broken. Oops. rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 830 to 837 in e25a67f
|
Removing that override gives a |
…illaumeGomez rustdoc: do not use plain summary for trait impls Fixes rust-lang#38386. Fixes rust-lang#48332. Fixes rust-lang#49430. Fixes rust-lang#62741. Fixes rust-lang#73474. Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy. (In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.) Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened rust-lang#73829. EDIT: This is now ready!
I tried this code:
There are two crates,
outer
andinner
.outer
depends oninner
.outer/src/lib.rs:
outer/inner/src/lib.rs:
I expected to see this happen: The trait implementation docs for
SomeTrait::foo
onouter::SomeStruct
link toSomeTrait
.Instead, this happened: The link is not resolved, and there is no warning or indication that it failed. Here is a screenshot of the generated docs:
Notably, the docs on
inner::bar::BarStruct
resolve correctly despite being in a different module, indicating that this is a cross-crate issue.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: