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

std docs has equivalent methods in the search index that lead nowhere #115480

Closed
Alexendoo opened this issue Sep 2, 2023 · 2 comments · Fixed by #116597
Closed

std docs has equivalent methods in the search index that lead nowhere #115480

Alexendoo opened this issue Sep 2, 2023 · 2 comments · Fixed by #116597
Labels
A-rustdoc-search Area: Rustdoc's search feature C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Alexendoo
Copy link
Member

I was checking if std exposed hashbrown::Equivalent and found these seemingly non existent methods

https://doc.rust-lang.org/std/index.html?search=equivalent

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 2, 2023
@Alexendoo Alexendoo changed the title std docs has an equivalent method in the search index that lead nowhere std docs has a equivalent methods in the search index that lead nowhere Sep 2, 2023
@Alexendoo Alexendoo changed the title std docs has a equivalent methods in the search index that lead nowhere std docs has equivalent methods in the search index that lead nowhere Sep 2, 2023
@zachs18
Copy link
Contributor

zachs18 commented Sep 2, 2023

It looks like the search results are present on 1.71.0's docs (and after), but not on 1.70.0's docs (or before)

@Alexendoo
Copy link
Member Author

Seems that's when std's hashbrown was upgraded to the version that added the Equivalent trait - #111306

@Noratrieb Noratrieb added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 2, 2023
@GuillaumeGomez GuillaumeGomez added the A-rustdoc-search Area: Rustdoc's search feature label Sep 4, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 9, 2023
…list, r=<try>

Only add non local items to `RustdocEffectiveVisibilities::extern_public`

While working on rust-lang#115480, I was finally able to track down the origin of the bug, still working on the fix (how to determine if a foreign trait is publically exported from the current crate in short), which led me to this small PR. It should only list foreign items and yet we don't check if they're locals before adding them to the map.

I expect a very minimal perf improvement.

r? `@notriddle`
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 10, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 10, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 11, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 11, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 11, 2023
…l, r=notriddle

Prevent showing methods from blanket impls of not available foreign traits to show up in the search results

Fixes rust-lang#115480.

In the case that the blanket impl trait is not available in the current crate, we prevent adding its methods in the search index.

Now how I found how to fix the issue: the `equivalent` method is not generated in the documentation pages but was still added to the search index. To render impls, we iterate over `cache.impls` so I took a look at how this was generated. Inside `formats/cache.rs`, we have `CacheBuilder::populate` where we push impls into `impls` but with this condition:

```rust
if cx.cache.traits.contains_key(&trait_did) {
```

I re-used this condition in `CacheBuilder::fold_item` to prevent this method from being added in `cache.search_index` or `cache.orphan_impl_items`.

PS: If you want to double-check if the added test works, just comment the code I added in `cache.rs` and it should fail.

r? `@notriddle`
@bors bors closed this as completed in d213983 Oct 11, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 11, 2023
Rollup merge of rust-lang#116597 - GuillaumeGomez:foreign-blanket-impl, r=notriddle

Prevent showing methods from blanket impls of not available foreign traits to show up in the search results

Fixes rust-lang#115480.

In the case that the blanket impl trait is not available in the current crate, we prevent adding its methods in the search index.

Now how I found how to fix the issue: the `equivalent` method is not generated in the documentation pages but was still added to the search index. To render impls, we iterate over `cache.impls` so I took a look at how this was generated. Inside `formats/cache.rs`, we have `CacheBuilder::populate` where we push impls into `impls` but with this condition:

```rust
if cx.cache.traits.contains_key(&trait_did) {
```

I re-used this condition in `CacheBuilder::fold_item` to prevent this method from being added in `cache.search_index` or `cache.orphan_impl_items`.

PS: If you want to double-check if the added test works, just comment the code I added in `cache.rs` and it should fail.

r? ``@notriddle``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
5 participants