Skip to content

rustdoc: links from items in a trait impl are inconsistent - #83068

Merged
bors merged 8 commits into
rust-lang:masterfrom
mockersf:method-trait-foreign-impl
Apr 14, 2021
Merged

rustdoc: links from items in a trait impl are inconsistent#83068
bors merged 8 commits into
rust-lang:masterfrom
mockersf:method-trait-foreign-impl

Conversation

@mockersf

@mockersfmockersf commented Mar 13, 2021

Copy link
Copy Markdown
Contributor

Depending on where the struct implementing a trait is coming from, or the current page, the items in a trait impl are not linking to the same thing:

itemtrait page, implementorstrait page, implementations on Foreign Typesstruct page, trait implementations
functionlink to current impllink to first impl in the listlink to trait def
default functionnot presentnot presentlink to trait def
default function with custom impllink to current impllink to trait deflink to trait def
constantlink to current impllink to trait deflink to trait def
associated typelink to current impllink to trait deflink to trait def
missing link to trait deffunction link wrong + missing link to current implmissing link to current impl
rust code with those cases
pubtraitMyTrait{typeAssoc;constVALUE:u32;fntrait_function(&self);fndefaulted(&self){}fndefaulted_override(&self){}}implMyTraitforString{/// will link to trait deftypeAssoc = ();/// will link to trait defconstVALUE:u32 = 5;/// will link to first foreign implementorfntrait_function(&self){}/// will link to trait deffndefaulted_override(&self){}}implMyTraitforVec<u8>{/// will link to trait deftypeAssoc = ();/// will link to trait defconstVALUE:u32 = 5;/// will link to first foreign implementorfntrait_function(&self){}/// will link to trait deffndefaulted_override(&self){}}implMyTraitforMyStruct{/// in trait page, will link to current impl////// in struct page, will link to trait deftypeAssoc = bool;/// in trait page, will link to current impl////// in struct page, will link to trait defconstVALUE:u32 = 20;/// in trait page, will link to current impl////// in struct page, will link to trait deffntrait_function(&self){}/// in trait page, will link to current impl////// in struct page, will link to trait deffndefaulted_override(&self){}}pubstructMyStruct;

In this PR, I fixed all links to target the trait definition, and added an anchor-link to the current implementation appearing on mouse hover.

@rust-highfive

Copy link
Copy Markdown
Contributor

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @GuillaumeGomez

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 13, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
Member

Looks good to me, thanks! Can you add a test in src/test/rustdoc to ensure that it works as expected please? You already wrote the file with all the cases so that should be quick. ;)

@mockersf

Copy link
Copy Markdown
ContributorAuthor

test added 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm lost here: what's the point of testing that this exists on the trait when we're currently on a trait implementation on a type?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is on the struct impl for the trait on the trait doc page. the method.defaulted_override-3 is targeting the impl, not the trait itself

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently not because the href you test is "#method.defaulted_override".

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, in the h4 with id method.defaulted_override-3, there is now the function name (class fnname that links to it's trait definition, so #method.defaulted_override, and anchor (class anchor) that links to itself (the line under this one)

this pr makes it so that every item in a trait impl is that way

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That part makes sense, but why are you testing that on the trait page whereas we "are" (so to speak) on the type?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the type implements the trait, it is present on both page

@bors

bors commented Mar 26, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #82873) made this pull request unmergeable. Please resolve the merge conflicts.

@camelidcamelid added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Mar 29, 2021
@jyn514

Copy link
Copy Markdown
Member

ping @GuillaumeGomez - this is waiting on your review.

@mockersf do you mind fixing the merge conflict in the meantime?

@GuillaumeGomez

Copy link
Copy Markdown
Member

Still in my review list. :)

@mockersf
mockersfforce-pushed the method-trait-foreign-impl branch from 76a49ca to 7f39530CompareApril 13, 2021 21:14
@rust-log-analyzer

This comment has been minimized.

@mockersf

Copy link
Copy Markdown
ContributorAuthor

@mockersf do you mind fixing the merge conflict in the meantime?

fixed!

@GuillaumeGomez

Copy link
Copy Markdown
Member

Thanks!

@bors: r+

@bors

bors commented Apr 14, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit e36ca09 has been approved by GuillaumeGomez

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2021
@bors

bors commented Apr 14, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e36ca09 with merge b203b0d...

@bors

bors commented Apr 14, 2021

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing b203b0d to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Apr 14, 2021
@bors
bors merged commit b203b0d into rust-lang:masterApr 14, 2021
@rustbotrustbot added this to the 1.53.0 milestone Apr 14, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@mockersf@rust-highfive@rust-log-analyzer@GuillaumeGomez@bors@jyn514@camelid@rustbot