Add back `tests/rustdoc-gui/notable-trait.goml` test
Part of https://github.com/rust-lang/rust/issues/152197.
Mostly the same test, I just replaced the flaky `assert-position` with a `wait-for-position`.
r? @Urgau
[rustdoc] Only generate search DOM elements if the search is actually needed
I realized that we were generating the search DOM elements (everything contained into `#search`) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that.
r? @lolbinarycat
Add back flaky gui rustdoc test `tests/rustdoc-gui/headers-color.goml`
Part of https://github.com/rust-lang/rust/issues/152197.
This PR adds back `tests/rustdoc-gui/headers-color.goml` with a little tweak: instead of using `go-to` command to change the focused element, we click on the anchors.
r? @Urgau
[rustdoc] Put back one removed flaky GUI test (which hopefully isn't flaky anymore)
Part of https://github.com/rust-lang/rust/issues/152197
You can see the original code of this test in https://github.com/rust-lang/rust/pull/152194 (where it was removed).
The `browser-ui-test` update comes from https://github.com/GuillaumeGomez/browser-UI-test/pull/759. We can now use the `click` command to click on an `option` inside a `select` (surprisingly enough, it needs to be special-cased in puppeteer...).
That update allowed me to replace all the `press-key` with one `click`. Starting from this change, I couldn't reproduce the failure, so hopefully it's gone.
cc @notriddle @JonathanBrouwer
r? @Urgau
For types, rustdoc produces different impl orderings in the sidebar vs.
the main section.
E.g. for `std::cell::UnsafeCell` the "Trait Implementations" sidebar
order is this:
```
!Freeze
!RefUnwindSafe
!Sync
CoerceUnsized<UnsafeCell<U>>
Debug
Default
DispatchFromDyn<UnsafeCell<U>>
From<T>
```
The primary sort is on polarity, and the secondary sort is alphabetical.
Makes sense.
The main section order is this:
```
impl<T> Debug for UnsafeCell<T>
impl<T> Default for UnsafeCell<T>
impl<T> From<T> for UnsafeCell<T>
impl<T, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T>
impl<T, U> DispatchFromDyn<UnsafeCell<U>> for UnsafeCell<T>
impl<T> !Freeze for UnsafeCell<T>
impl<T> !RefUnwindSafe for UnsafeCell<T>
impl<T> !Sync for UnsafeCell<T>
```
This strange ordering occurs because the entries are sorted on the
generated HTML. Impls with methods (the first three) come first because
they start with a `<details>` tag while the others start with a
`<section>` tag. After that, the order depends on a section id of the
form `impl-{trait}-for-{type}` that doesn't include the polarity, which
is why the secondary ordering is alphabetical but ignores the `!`.
The sidebar ordering is the better of the two. This commit changes the
main section to use the same ordering as the sidebar. This involves
creating a new function `impl_trait_key` shared between the two parts.
rustdoc: deterministic sorting for `doc_cfg` badges
Fixesrust-lang/rust#156391
Currently, target-exclusive `doc_cfg` badges (eg. "Available on...") reuse the order of predicates as they appear in the source code. This often buries popular targets behind niche ones and leads to inconsistent UI rendering.
This PR introduces a deterministic sorting mechanism to the `Cfg` AST prior to HTML/JSON rendering.
**Note for Reviewers:**
To provide the best UX, I implemented a lightweight tiering heuristic (prioritizing major platforms like Linux/Apple/Windows first, followed by mobile, then BSDs, and alphabetizing the rest). However, I am completely open to tweaking these priority groupings or falling back to a different sorting logic if the team prefers. Let me know what you think!
[rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results
Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.
It looks like this:
<img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" />
r? @lolbinarycat