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

Fix intra-doc links for inherent impls that are both lang items and not the default impl #75649

Merged
merged 9 commits into from
Aug 19, 2020

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Aug 17, 2020

I found in #75464 (comment) that str::to_uppercase() doesn't resolve while str::trim() does. The only real difference is that to_uppercase is defined in alloc, while trim is defined in core. It turns out that rustdoc was ignoring lang_items.str_alloc_impl() - it saw them in collect_trait_impls, but not for intra-doc links.

This uses the same impls for all parts of rustdoc, so that there can be no more inconsistency. It does have the slight downside that the matches are no longer exhaustive but it will be very clear if a new lang item is missed because it will panic when you try to document it (and if you don't document it, does rustdoc really need to know about it?).

This needs a test case (probably just str::to_uppercase). Added.

This is best reviewed commit-by-commit.

r? @GuillaumeGomez

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Aug 17, 2020
@rust-highfive
Copy link
Collaborator

Some changes occurred in intra-doc-links.

cc @jyn514

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 17, 2020
@jyn514

This comment has been minimized.

@jyn514
Copy link
Member Author

jyn514 commented Aug 17, 2020

This does keep one small change from #74489, which is to use find_by_name_and_namespace instead of filter_by_name_unhygenic. But that's a good change anyway and meant fewer rebase conflicts.

@jyn514 jyn514 changed the title [WIP] Fix intra-doc links for inherent impls that are both lang items and not the default impl Fix intra-doc links for inherent impls that are both lang items and not the default impl Aug 17, 2020
@GuillaumeGomez
Copy link
Member

Nice work!

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 18, 2020

📌 Commit 7be824e has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Aug 18, 2020
…aumeGomez

Fix intra-doc links for inherent impls that are both lang items and not the default impl

I found in rust-lang#75464 (comment) that `str::to_uppercase()` doesn't resolve while `str::trim()` does. The only real difference is that `to_uppercase` is defined in `alloc`, while trim is defined in `core`. It turns out that rustdoc was ignoring `lang_items.str_alloc_impl()` - it saw them in `collect_trait_impls`, but not for intra-doc links.

This uses the same `impls` for all parts of rustdoc, so that there can be no more inconsistency. It does have the slight downside that the matches are no longer exhaustive but it will be very clear if a new lang item is missed because it will panic when you try to document it (and if you don't document it, does rustdoc really need to know about it?).

~~This needs a test case (probably just `str::to_uppercase`).~~ Added.

This is best reviewed commit-by-commit.

r? @GuillaumeGomez
tmandry added a commit to tmandry/rust that referenced this pull request Aug 18, 2020
…aumeGomez

Fix intra-doc links for inherent impls that are both lang items and not the default impl

I found in rust-lang#75464 (comment) that `str::to_uppercase()` doesn't resolve while `str::trim()` does. The only real difference is that `to_uppercase` is defined in `alloc`, while trim is defined in `core`. It turns out that rustdoc was ignoring `lang_items.str_alloc_impl()` - it saw them in `collect_trait_impls`, but not for intra-doc links.

This uses the same `impls` for all parts of rustdoc, so that there can be no more inconsistency. It does have the slight downside that the matches are no longer exhaustive but it will be very clear if a new lang item is missed because it will panic when you try to document it (and if you don't document it, does rustdoc really need to know about it?).

~~This needs a test case (probably just `str::to_uppercase`).~~ Added.

This is best reviewed commit-by-commit.

r? @GuillaumeGomez
tmandry added a commit to tmandry/rust that referenced this pull request Aug 19, 2020
…aumeGomez

Fix intra-doc links for inherent impls that are both lang items and not the default impl

I found in rust-lang#75464 (comment) that `str::to_uppercase()` doesn't resolve while `str::trim()` does. The only real difference is that `to_uppercase` is defined in `alloc`, while trim is defined in `core`. It turns out that rustdoc was ignoring `lang_items.str_alloc_impl()` - it saw them in `collect_trait_impls`, but not for intra-doc links.

This uses the same `impls` for all parts of rustdoc, so that there can be no more inconsistency. It does have the slight downside that the matches are no longer exhaustive but it will be very clear if a new lang item is missed because it will panic when you try to document it (and if you don't document it, does rustdoc really need to know about it?).

~~This needs a test case (probably just `str::to_uppercase`).~~ Added.

This is best reviewed commit-by-commit.

r? @GuillaumeGomez
@tmandry
Copy link
Member

tmandry commented Aug 19, 2020

Failed in #75688 (comment) due to Cargo.lock being out of date
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 19, 2020
@bors
Copy link
Contributor

bors commented Aug 19, 2020

☔ The latest upstream changes (presumably #75692) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514
Copy link
Member Author

jyn514 commented Aug 19, 2020

@bors r=GuilluameGomez

@bors
Copy link
Contributor

bors commented Aug 19, 2020

📌 Commit 570b0d9 has been approved by GuilluameGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 19, 2020
@jyn514
Copy link
Member Author

jyn514 commented Aug 19, 2020

@bors r-

I want to add a test for f32 and f64 methods.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 19, 2020
@jyn514
Copy link
Member Author

jyn514 commented Aug 19, 2020

@bors r=@GuillaumeGomez

Tagging you so you can look at the changes if you want :) but it's only adding a new test.

@bors
Copy link
Contributor

bors commented Aug 19, 2020

📌 Commit aff01f8 has been approved by guillaumegomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 19, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Aug 19, 2020
…aumegomez

Fix intra-doc links for inherent impls that are both lang items and not the default impl

I found in rust-lang#75464 (comment) that `str::to_uppercase()` doesn't resolve while `str::trim()` does. The only real difference is that `to_uppercase` is defined in `alloc`, while trim is defined in `core`. It turns out that rustdoc was ignoring `lang_items.str_alloc_impl()` - it saw them in `collect_trait_impls`, but not for intra-doc links.

This uses the same `impls` for all parts of rustdoc, so that there can be no more inconsistency. It does have the slight downside that the matches are no longer exhaustive but it will be very clear if a new lang item is missed because it will panic when you try to document it (and if you don't document it, does rustdoc really need to know about it?).

~~This needs a test case (probably just `str::to_uppercase`).~~ Added.

This is best reviewed commit-by-commit.

r? @GuillaumeGomez
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#75069 (move const param structural match checks to wfcheck)
 - rust-lang#75587 (mir building: fix some comments)
 - rust-lang#75593 (Adjust installation place for compiler docs)
 - rust-lang#75648 (Make OnceCell<T> transparent to dropck)
 - rust-lang#75649 (Fix intra-doc links for inherent impls that are both lang items and not the default impl)
 - rust-lang#75674 (Move to intra doc links for std::io)
 - rust-lang#75696 (Remove `#[cfg(miri)]` from OnceCell tests)

Failed merges:

r? @ghost
@bors bors merged commit 7d14077 into rust-lang:master Aug 19, 2020
@jyn514 jyn514 deleted the inherent-lang-impls branch August 19, 2020 20:34
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
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 C-bug Category: This is a bug. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants