Skip to content
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

Lint suggestion: Useless explicit documentation link #87799

Closed
ThomasdenH opened this issue Feb 2, 2019 · 10 comments · Fixed by #113167
Closed

Lint suggestion: Useless explicit documentation link #87799

ThomasdenH opened this issue Feb 2, 2019 · 10 comments · Fixed by #113167
Assignees
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ThomasdenH
Copy link

ThomasdenH commented Feb 2, 2019

Once intra-rustdoc links lands, many explicit links will become unnecessary. It would be very useful to have a lint that would warn if the computed automatic link is the same as the provided link.

For example:

[Iterator](std::iter::Iterator)
Warning: unnecessary explicit rustdoc lint; you could replace this by "[Iterator]"
@sharksforarms
Copy link

sharksforarms commented Jan 12, 2021

Landed in 1.48: #43466

@sharksforarms
Copy link

Related: rust-lang/rust-clippy#1007

@jyn514
Copy link
Member

jyn514 commented Aug 5, 2021

This would be difficult to do in clippy because it needs access to resolve_str_path_error, which needs a resolver, which is destroyed when the TyCtxt is created. It would be much easier to implement in Rustdoc - that could be done by adding a check around here which sees if the link text resolves to the same item as the link target:

let link = self.resolve_link(&item, &doc, &self_name, parent_node, krate, md_link);

You'd also need to extend markdown_links to include the link text, right now it only includes the target:

if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 {

@jyn514
Copy link
Member

jyn514 commented Aug 5, 2021

@flip1995 can you move this to rust-lang/rust? It's still a good first issue, but it's not a good first issue for clippy.

@flip1995
Copy link
Member

flip1995 commented Aug 5, 2021

I don't have the rights to move this to rust-lang/rust, so @Manishearth

@Manishearth Manishearth transferred this issue from rust-lang/rust-clippy Aug 5, 2021
@jyn514 jyn514 added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Aug 5, 2021
@mdsn
Copy link
Contributor

mdsn commented Aug 29, 2021

@rustbot claim

@yerke
Copy link
Contributor

yerke commented Feb 7, 2022

@mdsn Are you still working on it?

@mdsn
Copy link
Contributor

mdsn commented Feb 8, 2022

@yerke hi! No, please go right ahead and claim it. 😃 If you search for the issue number on Zulip you'll find some questions of mine back then. I'll try to post later some of what I thought while looking into this issue.

@yerke
Copy link
Contributor

yerke commented Feb 8, 2022

@rustbot claim

@ChAoSUnItY
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants