-
Notifications
You must be signed in to change notification settings - Fork 13k
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: Correct anchor for links to associated trait items #32461
Conversation
@@ -2085,7 +2085,13 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item, | |||
let href = match link { | |||
AssocItemLink::Anchor => anchor, | |||
AssocItemLink::GotoSource(did) => { | |||
href(did).map(|p| format!("{}{}", p.0, anchor)).unwrap_or(anchor) | |||
// We're creating a link from an impl-item to the corresponding | |||
// trait-item and need to map the anchored type accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. This is wrong for default methods ("provided methods")
pub trait Bar {
// #method.bar
fn bar(&self) {}
// #tymethod.baz
fn baz(&self);
}
pub struct Foo;
impl Bar for Foo {
fn baz(&self) {}
}
Hm so right now we have a linkchecker script which ensures that all links point to valid locations. Perhaps we could extend that with checking anchors as well? It may be relatively easy enough to just grep for |
5d3e500
to
23de1cc
Compare
Good idea, I've mostly got the linkchecker working, now I just need to somehow deal with redirect pages. |
Nice! Feel free to ping me when that happens and I'll likely r+ :) |
ea78484
to
d742cda
Compare
These should always correspond to the values in `ItemType::to_static_str`
This adds checks to ensure that: * link anchors refer to existing id's on the target page * id's are unique within an html document * page redirects are valid
Adding these "known" values to the table of used ids is only required when embedding markdown into a rustdoc html page and may yield unexpected results when rendering a standalone `*.md` file.
(updated) I've had to whitelist some cases in the same vein as #32130, and |
if file.ends_with("std/string/struct.String.html") { | ||
return | ||
if file.ends_with("std/string/struct.String.html") || | ||
file.ends_with("collections/string/struct.String.html") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the addition of these new ignores, can you be sure that issues are filed and these are tagged with a FIXME?
⌛ Testing commit 41916d8 with merge a464b19... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
Checking a redirect page during tree traversal before trying to actually follow the redirect leads to retrieval of the redirect pages source instead.
7849e2f
to
4e0abdb
Compare
(updated, should work now) |
rustdoc: Correct anchor for links to associated trait items fixes #28478 r? @alexcrichton
fixes #28478
r? @alexcrichton