Skip to content

Fix bug when rustdoc "go to only result" setting is not working as expected"#158308

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:fix-only-result-bug
Jun 25, 2026
Merged

Fix bug when rustdoc "go to only result" setting is not working as expected"#158308
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:fix-only-result-bug

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

Can be reproduced as follows on std docs:

  • Disable the Directly go to item in search if there is only one result setting
  • Search for "var" (without the quotes)
  • Enable the Directly go to item in search if there is only one result setting
  • Reload the page
  • It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if any tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle

@rustbot

rustbot commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @lolbinarycat

@rustbot rustbot added A-rustdoc-js Area: Rustdoc's JS front-end 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 Jun 23, 2026
go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
// We enter it into the search.
click: "#search-button"
wait-for: "#alternative-display .search-input"

@GuillaumeGomez GuillaumeGomez Jun 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm surprised it worked before to directly write into the search input even if it's not displayed. It triggered a bug when I wrote Whitespace into it: it only had pace, the beginning was removed. I think it's because the item gets moved in-between and if there are few enough letters, it works, but it's only by change.

View changes since the review

write-into: (".search-input", "HasALongTraitWithParams")
wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
assert-window-property: ({"location"."pathname": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)

@GuillaumeGomez GuillaumeGomez Jun 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have no clue how this could have work before since window.location is indeed an object. Gonna investigate on browser-ui-test side.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
show-text: true

// The setting should be disabled.

@GuillaumeGomez GuillaumeGomez Jun 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To confirm this test works, run it without the fix. It should fail. :)

View changes since the review

@notriddle

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2262b8e has been approved by notriddle

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot 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 Jun 24, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158294 (Use .drectve for MSVC DLL exports)
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158355 (Fixup the refactoring errors in #156246)
 - #158390 (Fix: auto trait, const trait bound)

Failed merges:

 - #155535 (export symbols: support macos/windows(32/64))
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158355 (Fixup the refactoring errors in #156246)
 - #158390 (Fix: auto trait, const trait bound)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158355 (Fixup the refactoring errors in #156246)
 - #158390 (Fix: auto trait, const trait bound)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158355 (Fixup the refactoring errors in #156246)
 - #158390 (Fix: auto trait, const trait bound)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158390 (Fix: auto trait, const trait bound)

Failed merges:

 - #158355 (Fixup the refactoring errors in #156246)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158390 (Fix: auto trait, const trait bound)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158390 (Fix: auto trait, const trait bound)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158390 (Fix: auto trait, const trait bound)
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #155535 (export symbols: support macos/windows(32/64))
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158390 (Fix: auto trait, const trait bound)
@rust-bors rust-bors Bot merged commit 0b5b960 into rust-lang:main Jun 25, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 25, 2026
rust-timer added a commit that referenced this pull request Jun 25, 2026
Rollup merge of #158308 - GuillaumeGomez:fix-only-result-bug, r=notriddle

Fix bug when rustdoc "go to only result" setting is not working as expected"

Can be reproduced as follows on `std` docs:

 * Disable the `Directly go to item in search if there is only one result` setting
 * Search for "var" (without the quotes)
 * Enable the `Directly go to item in search if there is only one result` setting
 * Reload the page
 * It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if **any** tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle
@GuillaumeGomez GuillaumeGomez deleted the fix-only-result-bug branch June 26, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-js Area: Rustdoc's JS front-end 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.

3 participants