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

rustdoc: intra doc links link to re-exported primitives #77757

Closed

Conversation

Stupremee
Copy link
Member

@rust-highfive
Copy link
Collaborator

Some changes occurred in intra-doc-links.

cc @jyn514

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jyn514 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2020
@Stupremee Stupremee added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 9, 2020
@GuillaumeGomez
Copy link
Member

Nice! Does it work for methods on slice too?

@Stupremee
Copy link
Member Author

Stupremee commented Oct 9, 2020

No, it doesn't, but I can try to make it work

@GuillaumeGomez
Copy link
Member

Oh... That was the sad hope haha.

@jyn514
Copy link
Member

jyn514 commented Oct 9, 2020

@Stupremee #63351 is a much harder issue, please don't mix it into any other changes.

Comment on lines +1905 to +1920
.next();
prim.or_else(|| {
let res = cx
.enter_resolver(|resolver| {
resolver.resolve_str_path_error(DUMMY_SP, &path_str, ns, module_id)
})
.ok()?
.1;
PRIMITIVES
.iter()
.find(|(_, prim_res)| match (res, prim_res) {
(Res::PrimTy(ty1), Res::PrimTy(ty2)) if ty1 == *ty2 => true,
(_, _) => false,
})
.copied()
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right. Instead of changing is_primitive to go through rustc_resolve, can you change some of the callsites not to use is_primitive? The only place that should be doing string comparisons is the ambiguity check for modules vs. primitives.

See also #77743 (comment).

if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ch == ':' || ch == '_')) {
return None;
}
let mut path_str = if let Ok((d, path)) = Disambiguator::from_str(&link) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split this refactor into a separate commit so the logic changes are easier to see?

@jyn514
Copy link
Member

jyn514 commented Oct 10, 2020

I'm going to close this in favor of #77743, I like the approach there better. Sorry your code didn't make it in - if you're interested in working on other intra-doc issues let me know and I'm happy to mentor!

@jyn514 jyn514 closed this Oct 10, 2020
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intra-doc links don't work for associated items on re-exported primitives
4 participants