Closed
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