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

[rustdoc] Fix type based search #115436

Merged
merged 5 commits into from
Sep 3, 2023

Conversation

GuillaumeGomez
Copy link
Member

Fixes #114522.

The problem was a bit more tricky than I originally thought it would be: we only kept type ID and generics in short, but as soon as there was a full path in the user query, the element didn't get an ID anymore because the ID map didn't know about x::y (although it knew about y). So for this first problem, I instead always pass the element name to get the ID.

Then a new problem occurred: we actually needed to check if paths matched, otherwise whatever the path, as long as the "end types" match, it's all good. meaning, we needed to add path information, but to do so, we needed it to be added into the search index directly as there was no mapping between "p" and "q".

I hope this explanation makes sense to someone else than me. ^^'

r? @notriddle

@rustbot rustbot added 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. labels Sep 1, 2023
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2023

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha

// The String is alias name and the vec is the list of the elements with this alias.
//
// To be noted: the `usize` elements are indexes to `items`.
aliases: &'a BTreeMap<String, Vec<usize>>,
}

struct Paths {
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 needed to create this type because in case there is no path (for primitive types for example), we don't want the array to finish with a null element.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed the eslint issue: it was a comma after the last function's argument...

if path.len() < 2 {
return Paths { ty: *ty, name: path[0], path: None };
}
let index = mod_paths.get(&join_with_double_colon(&path[..path.len() - 1]));
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this work when a function signature contains a type that’s defined in another crate and not inlined into this one anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't, good catch. We only get the paths from the cache. We can get the path with def_path_str. Going to take a look.

@GuillaumeGomez
Copy link
Member Author

Fixed the paths for foreign items as well. I added their paths at the end of the full_paths list so they can be indexed like all other paths.

@notriddle
Copy link
Contributor

notriddle commented Sep 3, 2023

That sounds good.

@bors r+ rollup=never

This will have a perf impact, since it adds more data to the search index. That's expected, and since this is a bug fix, acceptable as long as it isn't huge.

@bors
Copy link
Contributor

bors commented Sep 3, 2023

📌 Commit e161fa1 has been approved by notriddle

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 Sep 3, 2023
@bors
Copy link
Contributor

bors commented Sep 3, 2023

⌛ Testing commit e161fa1 with merge 3ec4b3b...

@bors
Copy link
Contributor

bors commented Sep 3, 2023

☀️ Test successful - checks-actions
Approved by: notriddle
Pushing 3ec4b3b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 3, 2023
@bors bors merged commit 3ec4b3b into rust-lang:master Sep 3, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 3, 2023
@GuillaumeGomez GuillaumeGomez deleted the fix-type-based-search branch September 3, 2023 10:35
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3ec4b3b): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [2.2%, 2.6%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.2%, 2.6%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-2.8%, -2.8%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 629.598s -> 630.213s (0.10%)
Artifact size: 316.67 MiB -> 316.63 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Full paths in type-based search don't work
6 participants