-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.This change is insta-stable, or significant enough to need a team FCP to proceed.
Description
I have code like this:
struct Foo { bar: i32 }
impl Foo {
/// Get a reference to [`Foo::bar`].
// ^^^ I want this to link to the field. Currently it links to the method.
fn bar(&self) -> i32 { self.bar }
}
This is a decently-common Rust "design pattern" where you have have a private
field but give public read-only access via a method of the same name. However,
there's no way in rustdoc currently to disambiguate between the function and the
field. Rustdoc seems to always link to the method in this case.
It would be good if we had a disambiguator for struct/enum fields: something
like field@Foo::bar
. I don't think it's necessary to have a different one for
struct vs enum variant fields, but we should still decide that since intra-doc
links are now stable (and thus we can't remove things).
See the discussion on Zulip.
cc @jyn514
pierwill, nashley, GnomedDev, zopsicle, JarredAllen and 11 more
Metadata
Metadata
Assignees
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.This change is insta-stable, or significant enough to need a team FCP to proceed.