-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add an intra-doc link disambiguator for fields #80283
Comments
It would be nice if we had special-casing for the disambiguator so that |
IMHO using |
Yeah, I second this. |
I think I’m willing to contribute this if the idea itself gets accepted. I kinda don’t have the energy to push it, ping relevant people, write justifications and do other social stuff like that right now. I’m not even sure how to make (organisational) progress here, since this issue exists for 3 years and there’s no reaction from the rustdoc team. |
You are talking about a different problem than the one mentioned in the issue. We are not planning to add |
That’s kinda sad but fair. How about special-casing |
That should probably have an FCP from the rustdoc team. You can bring it up on Zulip if you want to get initial feedback on whether they think it's a good idea: https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc |
For anyone that is still looking for a way to link to a struct field, adding This appears to generate the following URL when I generate the docs with Example: struct Foo {
bar: i32,
}
impl Foo {
// THE LINE BELOW ⬇️
/// Get a reference to [`crate::my_sub_module::Foo#structfield.bar`].
fn bar(&self) -> i32 {
self.bar
}
} |
I have code like this:
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 forstruct 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
The text was updated successfully, but these errors were encountered: