Skip to content

Conversation

lolbinarycat
Copy link
Contributor

@lolbinarycat lolbinarycat commented Aug 26, 2025

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
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-search-trait-parent branch from 738dcc9 to 8444219 Compare August 26, 2025 19:35
@lolbinarycat
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.

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat
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.

@lolbinarycat lolbinarycat force-pushed the rustdoc-search-trait-parent branch from 8444219 to 0574e11 Compare August 30, 2025 20:21
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-search-trait-parent branch from 0574e11 to 0c19f15 Compare August 30, 2025 20:45
@lolbinarycat
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.

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-search-trait-parent branch from 0c19f15 to a78352a Compare August 30, 2025 20:56
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat
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.
@lolbinarycat lolbinarycat force-pushed the rustdoc-search-trait-parent branch from a78352a to 2cf6317 Compare August 31, 2025 03:19
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat
Copy link
Contributor Author

we need a new regression test for #78724 now.

@rust-log-analyzer
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
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
Development

Successfully merging this pull request may close these issues.

Blanket impls cause bloated search results in rustdoc
3 participants