Skip to content

[rustdoc] Make aliases search support partial matching #143988

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

Merged
merged 4 commits into from
Jul 20, 2025

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jul 15, 2025

Fixes #140782.

To make this work, I moved aliases into the searchIndex like any other item. It links to the "original" item with a new original field. No so great part is that we need to have some fields like bitIndex to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as @lolbinarycat wished to work on this so I'll leave them this part. 😉

cc @lolbinarycat

@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-rustdoc-search Area: Rustdoc's search feature 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha, @lolbinarycat

@@ -116,7 +116,7 @@ pub(crate) fn build_index(
// Set up alias indexes.
for (i, item) in cache.search_index.iter().enumerate() {
for alias in &item.aliases[..] {
aliases.entry(alias.as_str().to_lowercase()).or_default().push(i);
aliases.entry(alias.to_string()).or_default().push(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there is no longer any transformation taking place, and since aliases doesn't seem to escape the function (based on the fact CrateData is a struct defined within this function and it borrows the aliases variable), couldn't aliases have its type changed to BTreeMap<&str, Vec<usize>> to save a bunch of allocations?

Copy link
Member Author

Choose a reason for hiding this comment

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

Problem is with serde and borrow checker here. If I use &str, we can't do:

    let mut search_index = std::mem::take(&mut cache.search_index);

just below. Other solution would be to keep Symbol instead, but Serialize is not implemented on it, so not possible either. Fixing this would require a lot of code, so better keep it for later optimization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this worth a FIXME comment or is this too small of an optimization?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's worth it. Also I expect you will gove it a try soon enough. 😄

Copy link
Contributor

@lolbinarycat lolbinarycat left a comment

Choose a reason for hiding this comment

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

Reviewed everything except the changes to tester.js, only thing I can think of is putting a doc comment on Row.name to explain that it is the the name of the item or alias, since this does change its semantics, everything else looks pretty good.

@GuillaumeGomez
Copy link
Member Author

Thanks for the review!

@bors r=lolbinarycat rollup

@bors
Copy link
Collaborator

bors commented Jul 19, 2025

📌 Commit 2f14d0a has been approved by lolbinarycat

It is now in the queue for this repository.

@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 Jul 19, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 20, 2025
…lbinarycat

[rustdoc] Make aliases search support partial matching

Fixes rust-lang#140782.

To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as `@lolbinarycat` wished to work on this so I'll leave them this part. 😉

cc `@lolbinarycat`
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this pull request Jul 20, 2025
…lbinarycat

[rustdoc] Make aliases search support partial matching

Fixes rust-lang#140782.

To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as ``@lolbinarycat`` wished to work on this so I'll leave them this part. 😉

cc ``@lolbinarycat``
bors added a commit that referenced this pull request Jul 20, 2025
Rollup of 12 pull requests

Successful merges:

 - #141260 (Allow volatile access to non-Rust memory, including address 0)
 - #143604 (Stabilize `const_float_round_methods`)
 - #143833 (Ban projecting into SIMD types [MCP838])
 - #143988 ([rustdoc] Make aliases search support partial matching)
 - #144078 (Fix debuginfo-lto-alloc.rs test)
 - #144111 (Remove deprecated `MaybeUninit` slice methods)
 - #144116 (Fixes for LLVM 21)
 - #144134 (Cleanup unicode table gen)
 - #144142 (Add implicit sized bound to trait ascription types)
 - #144148 (Remove pretty print hack for async blocks)
 - #144169 (interpret: fix TypeId pointers being considered data pointers)
 - #144196 (Initialize mingw for the runner's user)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 20, 2025
Rollup of 11 pull requests

Successful merges:

 - #141260 (Allow volatile access to non-Rust memory, including address 0)
 - #143604 (Stabilize `const_float_round_methods`)
 - #143988 ([rustdoc] Make aliases search support partial matching)
 - #144078 (Fix debuginfo-lto-alloc.rs test)
 - #144111 (Remove deprecated `MaybeUninit` slice methods)
 - #144116 (Fixes for LLVM 21)
 - #144134 (Cleanup unicode table gen)
 - #144142 (Add implicit sized bound to trait ascription types)
 - #144148 (Remove pretty print hack for async blocks)
 - #144169 (interpret: fix TypeId pointers being considered data pointers)
 - #144196 (Initialize mingw for the runner's user)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit dda5058 into rust-lang:master Jul 20, 2025
10 of 11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 20, 2025
@GuillaumeGomez GuillaumeGomez deleted the alias-inexact branch July 20, 2025 13:08
rust-timer added a commit that referenced this pull request Jul 20, 2025
Rollup merge of #143988 - GuillaumeGomez:alias-inexact, r=lolbinarycat

[rustdoc] Make aliases search support partial matching

Fixes #140782.

To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. 😉

cc ```@lolbinarycat```
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 21, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#141260 (Allow volatile access to non-Rust memory, including address 0)
 - rust-lang/rust#143604 (Stabilize `const_float_round_methods`)
 - rust-lang/rust#143988 ([rustdoc] Make aliases search support partial matching)
 - rust-lang/rust#144078 (Fix debuginfo-lto-alloc.rs test)
 - rust-lang/rust#144111 (Remove deprecated `MaybeUninit` slice methods)
 - rust-lang/rust#144116 (Fixes for LLVM 21)
 - rust-lang/rust#144134 (Cleanup unicode table gen)
 - rust-lang/rust#144142 (Add implicit sized bound to trait ascription types)
 - rust-lang/rust#144148 (Remove pretty print hack for async blocks)
 - rust-lang/rust#144169 (interpret: fix TypeId pointers being considered data pointers)
 - rust-lang/rust#144196 (Initialize mingw for the runner's user)

r? `@ghost`
`@rustbot` modify labels: rollup
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
…lbinarycat

[rustdoc] Make aliases search support partial matching

Fixes rust-lang#140782.

To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. 😉

cc ```@lolbinarycat```
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#141260 (Allow volatile access to non-Rust memory, including address 0)
 - rust-lang#143604 (Stabilize `const_float_round_methods`)
 - rust-lang#143988 ([rustdoc] Make aliases search support partial matching)
 - rust-lang#144078 (Fix debuginfo-lto-alloc.rs test)
 - rust-lang#144111 (Remove deprecated `MaybeUninit` slice methods)
 - rust-lang#144116 (Fixes for LLVM 21)
 - rust-lang#144134 (Cleanup unicode table gen)
 - rust-lang#144142 (Add implicit sized bound to trait ascription types)
 - rust-lang#144148 (Remove pretty print hack for async blocks)
 - rust-lang#144169 (interpret: fix TypeId pointers being considered data pointers)
 - rust-lang#144196 (Initialize mingw for the runner's user)

r? `@ghost`
`@rustbot` modify labels: rollup
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-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. 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.

rustdoc should include aliases in search that only partially matches
5 participants