Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: don't show multiple instances of the same trait item in search #145898

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

Draft
lolbinarycat wants to merge 2 commits into rust-lang:master
base: master
Choose a base branch
Loading
from lolbinarycat:rustdoc-search-trait-parent

Conversation

Copy link
Contributor

@lolbinarycat lolbinarycat commented Aug 26, 2025
edited
Loading

fixes #138251

cc @notriddle

current known issues:

  1. currently, the code does ensure that in the case of duplicate results, it is the trait item that is shown (eg. currently for -> Option, it shows std::char::Lowercase::last as its representative of Iterator::last)

@rustbot rustbot added A-rustdoc-search Area: Rustdoc's search feature S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Aug 26, 2025

This comment has been minimized.

Copy link
Contributor Author

sometimes traitParent is not set properly for cross-crate implementations (eg. alloc::str::Bytes::last is not getting linked to Iterator::last).

this has been fixed (and removed from the PR description), i just needed to also be checking Cache::external_paths when resolving trait_parent_idx.

This comment has been minimized.

Copy link
Contributor Author

Right, I just remembered why my original design had its own deduplication pass, instead of leveraging the existing deduplication pass:

if the user searches for char::from, we should show them both ascii::Char::from and char::from. its only when a search matches the actual trait item (in this case, From::from) where we should perform this deduplication.

notriddle reacted with thumbs up emoji

This comment has been minimized.

Copy link
Contributor Author

I believe I managed to get it working using notriddle's idea for how the search index data should be structured, but with my original idea of having two deduplication passes.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor Author

ok so apparently some impls for unnamable traits get lowered and then filtered out later? which seems mildly wasteful but ig in the meantime i need to remove this debug assertion.

for example, if we're showing `Iterator::next`,
we don't need to also show `Range::next` in the results.

This comment has been minimized.

Copy link
Contributor Author

we need a new regression test for #78724 now.

Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
F (141/141)
/checkout/tests/rustdoc-gui/search-result-color.goml search-result-color... FAILED
[ERROR] `tests/rustdoc-gui/search-result-color.goml` line 24
 from `tests/rustdoc-gui/search-result-color.goml` line 157: `//*[@class='desc'][normalize-space()='Just a normal struct.']` not found: for command `assert-css: (
 "//*[@class='desc'][normalize-space()='Just a normal struct.']",
 {"color": |desc_color|},
 )`
[ERROR] `tests/rustdoc-gui/search-result-color.goml` line 101
 from `tests/rustdoc-gui/search-result-color.goml` line 157: `//*[@class='desc'][normalize-space()='Just a normal struct.']` not found: for command `move-cursor-to: "//*[@class='desc'][normalize-space()='Just a normal struct.']"`
/checkout/tests/rustdoc-gui/search-tab.goml search-tab... FAILED
[ERROR] `tests/rustdoc-gui/search-tab.goml` line 82: The following errors happened: [` (22) ` isn't equal to ` (27) `]: for command `assert-text: ("#search-tabs > button:nth-child(1) > .count", " (27) ")`
Error: ()
Bootstrap failed while executing `test tests/rustdoc-gui --stage 2 --test-args --jobs 1`
Build completed unsuccessfully in 0:04:37
 local time: Tue Sep 2 17:49:35 UTC 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
A-rustdoc-search Area: Rustdoc's search feature S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Blanket impls cause bloated search results in rustdoc

AltStyle によって変換されたページ (->オリジナル) /