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

Intra-doc links should implicitly add Self:: prefix as needed #98270

Closed
clarfonthey opened this issue Jun 20, 2022 · 1 comment
Closed

Intra-doc links should implicitly add Self:: prefix as needed #98270

clarfonthey opened this issue Jun 20, 2022 · 1 comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Jun 20, 2022

It's extremely common to reference methods on the same type when writing docs. For example, Vec::reserve_exact mentions Vec::reserve.

In almost all of these cases, the method being linked doesn't include the full type or Self:: in the actual text, and has to resort to copying the method name with Self:: in the link destination.

It would be nice if rustdoc automatically resolved these links without the need to add the extra Self:: prefix. For example, writing [`reserve`] should automatically resolve to Self::reserve if a reserve item doesn't exist on its own. If both the method and the standalone item exist, we could add a lint to point out the ambiguity, requiring the user to clarify either self::reserve or Self::reserve; this feels like the best move to avoid changing the existing behaviour.

Either way, this pattern feels very common and seems like a papercut that makes documentation just a little bit harder to write.

@jyn514 jyn514 added the A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name label Jun 20, 2022
@jyn514
Copy link
Member

jyn514 commented Jun 20, 2022

Duplicate of #59039

@jyn514 jyn514 marked this as a duplicate of #59039 Jun 20, 2022
@jyn514 jyn514 closed this as completed Jun 20, 2022
@jyn514 jyn514 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants