-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustdoc: Semantically disambiguate impls and associated impl items rather than using numeric suffixes #92052
Comments
I'm interested in working on this, but I might not be able to get to it for a few weeks. If someone else is interested in taking this on, feel free to ping me here. :) In the meantime, @rustbot claim |
Is this the relevant code, @camelid? (I've never worked on rustdoc before, so this should be fun!) |
Hmm, I don't think that's it. I think the relevant code is at the top of let id = cx.derive_id(match i.inner_impl().trait_ {
Some(ref t) => {
if is_on_foreign_type {
get_id_for_impl_on_foreign_type(&i.inner_impl().for_, t, cx)
} else {
format!("impl-{}", small_url_encode(format!("{:#}", t.print(cx))))
}
}
None => "impl".to_string(),
}); though there's also The |
Could we do something as naive as this, as a starting point? aliases: &[String],
) {
let id = cx.derive_id(match i.inner_impl().trait_ {
- Some(ref t) => {
- if is_on_foreign_type {
- get_id_for_impl_on_foreign_type(&i.inner_impl().for_, t, cx)
- } else {
- format!("impl-{}", small_url_encode(format!("{:#}", t.print(cx))))
- }
- }
+ Some(ref t) => get_id_for_impl(&i.inner_impl().for_, t, cx),
None => "impl".to_string(),
});
let aliases = if aliases.is_empty() {
@@ -2194,7 +2188,7 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
}
}
-fn get_id_for_impl_on_foreign_type(
+fn get_id_for_impl(
for_: &clean::Type,
trait_: &clean::Path,
cx: &Context<'_>,
@@ -2210,7 +2204,7 @@ fn extract_for_impl_name(item: &clean::Item, cx: &Context<'_>) -> Option<(String
// so this parameter does nothing.
(
format!("{:#}", i.for_.print(cx)),
- get_id_for_impl_on_foreign_type(&i.for_, trait_, cx),
+ get_id_for_impl(&i.for_, trait_, cx),
)
})
}
Except we do want to know about foreign types, still... |
Perhaps. It's hard to know without seeing the results.
I'm not sure I understand what you mean. |
I'm afraid I'm too far removed from this code now to see this across the finish line... |
@GuillaumeGomez : Can this be closed now that #98939 is merged? |
It can indeed! Thanks for notifying. |
**Change** * Pipeline job `pages` started failing because of the error shown below ``` Found invalid urls in struct.Context.html: Fragment #impl-Display at struct.YDBError.html does not exist! ``` * This error is from execution of `cargo deadlinks` command * This error is due to the fact that implementation of trait `fmt::Display` for `YDBError` was not found at fragment `impl-Display` of `struct.YDBError.html` * This error started occuring with the `rust version 1.64.0 (a55dd71d5 2022-09-19)` and not before. The previous version as seen in pipeline jobs previous to this failure is `1.63.0 (4b91a6ea7 2022-08-08)` * When attempted to generate the docs locally it was found that the documentation for `Display` with the new rust version (1.64.0) was seen at fragment `impl-Display-for-YDBError` * Changing the fragment part in rustdoc solved the issue * The following pull request seems to have introduced this change to rustdoc rust-lang/rust#98939 (rustdoc: Add more semantic information to impl IDs #98939) and this is the issue on github related to this change -> rust-lang/rust#92052 (rustdoc: Semantically disambiguate impls and associated impl items rather than using numeric suffixes #92052) **Misc** * @jsikri94 found another issue where the intra-doc link format was broken. This change also fixed the issue. * Previous to this change following line was seen in docs : `ci_t! and cip_t! cip_t!: crate::cip_t! ci_t!: crate::ci_t!` * After this change it is replaced by : `ci_t! and cip_t!` * The fix was to include an empty line between the intra link and its definition. As it was absent both the lines were being combined into one as seen above in the first sub-point. With the empty line the line seen in docs is fixed and is seen as shown by the second sub-point above.
Problem
Links to impls and their associated items are currently unstable in the sense that the addition of other items causes pre-existing items to have different URL fragments. This is because the URL fragments are only disambiguated by suffixing a number. If more items are added, the suffix changes. In addition, the suffix is not very human-understandable; it's hard to know which suffix will be chosen by rustdoc.
Proposed changes
#impl
,#impl-1
, etc., generate IDs like#impl-Add<&str>-for-String
(or similar).Concerns and unresolved questions
The text was updated successfully, but these errors were encountered: