Skip to content

Conversation

@GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jun 11, 2025

Fixes #51129.

This PR changeda surprisingly small amount of things to put negative trait impls before the others: basically just adding a new information in the generated JS file for foreign implementors and a "negative marker" DOM element to know where to insert negative impls.

I also used this occasion to make the foreign implementors sort the same as the local ones by using compare_names.

You can test it here.

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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha, @lolbinarycat

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Took me a while to figure out where the typescript definition was stored to fix the error. ^^'

let part = OrderedJson::array_sorted(
implementors.sort_unstable();

let part = OrderedJson::array_unsorted(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely an improvement, as it eliminates an allocation, but we're still allocating an intermediate string for each element.

OrderedJson could be much more efficient if it had a method that appended using serde_json::to_writer.

I can open an issue for improving the OrderedJson interface, if you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

An issue would be welcome indeed.

@rust-log-analyzer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jun 17, 2025
alternate interface for OrderedJson to reduce allocations

inspired by #142380 (comment)

r? `@GuillaumeGomez`
<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
@bors
Copy link
Collaborator

bors commented Jun 22, 2025

☔ The latest upstream changes (presumably #142667) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez
Copy link
Member Author

Fixed merge conflicts.

@notriddle
Copy link
Contributor

Either JavaScript-loaded content needs to go on the bottom, or it needs to be loaded in a blocking manner. Otherwise, you get layout shift and potential misclicks.

output.mp4

Copy link
Contributor

@notriddle notriddle left a comment

Choose a reason for hiding this comment

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

Need a solution to the layout shift problem.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2025
@GuillaumeGomez
Copy link
Member Author

Fair enough. I can make the implementors content to be hidden by default (when JS is enabled) and display it when the updated is done.

@GuillaumeGomez
Copy link
Member Author

So now, the implementors lists are only displayed once they have been filled by the JS. I still display the headings though. I also opened the hosted example.

Does that sound good to you @notriddle or do you have something else in mind?

@notriddle
Copy link
Contributor

How does this work on a page like

// It tries to load a JS for each trait but there are none since they're not implemented.
fail-on-request-error: false
that has no foreign impls at all?

@notriddle
Copy link
Contributor

Does that sound good to you @notriddle or do you have something else in mind?

I wanted to put downstream foreign trait impls on the bottom, so we end up equivalent to impls.sort_by_key(|i| (!i.is_foreign, i.is_negative)). That way main.js and trait.Sync.js don't block us from showing content that's already in the HTML anyway.

But, in order of preference, if I have to pick between longer load time and more layout shift, I'll usually pick longer load time. But I'd rather go with an option that avoids both.

@rustbot
Copy link
Collaborator

rustbot commented Dec 10, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@GuillaumeGomez
Copy link
Member Author

Implemented suggestions.

@rust-log-analyzer

This comment has been minimized.

@yotamofek
Copy link
Contributor

yotamofek commented Dec 10, 2025

Looks really good!

All that's left is my question about the noscript thingy (can maybe be resolved by just explaining to me why I'm wrong 😅),
and
maybe some squashing? The last commit can probably just be part of the previous commits. Not a big deal though, it's fine like this too.

@GuillaumeGomez
Copy link
Member Author

I'll leave it as is if you don't mind. No energy to squash any additional commit today. ^^'

@yotamofek
Copy link
Contributor

@bors r+
Let's not roll this up for the off chance it affects perf

@bors
Copy link
Collaborator

bors commented Dec 10, 2025

📌 Commit fb9d3a5 has been approved by yotamofek

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 10, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Dec 11, 2025
…=yotamofek

Put negative implementors first and apply same ordering logic to foreign implementors

Fixes rust-lang#51129.

This PR changeda surprisingly small amount of things to put negative trait impls before the others: basically just adding a new information in the generated JS file for foreign implementors and a "negative marker" DOM element to know where to insert negative impls.

I also used this occasion to make the foreign implementors sort the same as the local ones by using `compare_names`.

You can test it [here](https://rustdoc.crud.net/imperio/neg-implementors/core/marker/trait.Sync.html#implementors).

r? `@notriddle`
bors added a commit that referenced this pull request Dec 11, 2025
Rollup of 4 pull requests

Successful merges:

 - #142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - #149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - #149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - #149867 (only resolve main in bin crates)

r? `@ghost`
`@rustbot` modify labels: rollup
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Dec 11, 2025
…=yotamofek

Put negative implementors first and apply same ordering logic to foreign implementors

Fixes rust-lang#51129.

This PR changeda surprisingly small amount of things to put negative trait impls before the others: basically just adding a new information in the generated JS file for foreign implementors and a "negative marker" DOM element to know where to insert negative impls.

I also used this occasion to make the foreign implementors sort the same as the local ones by using `compare_names`.

You can test it [here](https://rustdoc.crud.net/imperio/neg-implementors/core/marker/trait.Sync.html#implementors).

r? ``@notriddle``
bors added a commit that referenced this pull request Dec 11, 2025
…uwer

Rollup of 10 pull requests

Successful merges:

 - #142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - #146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - #148717 (Point at span within local macros even when error happens in nested external macro)
 - #148825 (Add SystemTime::{MIN, MAX})
 - #149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - #149770 (Rename some issue-* tests)
 - #149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - #149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - #149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - #149867 (only resolve main in bin crates)

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

Successful merges:

 - #142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - #146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - #148717 (Point at span within local macros even when error happens in nested external macro)
 - #149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - #149770 (Rename some issue-* tests)
 - #149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - #149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - #149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - #149867 (only resolve main in bin crates)

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

Successful merges:

 - #142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - #146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - #148717 (Point at span within local macros even when error happens in nested external macro)
 - #149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - #149770 (Rename some issue-* tests)
 - #149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - #149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - #149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - #149867 (only resolve main in bin crates)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 52cadc0 into rust-lang:main Dec 12, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 12, 2025
rust-timer added a commit that referenced this pull request Dec 12, 2025
Rollup merge of #142380 - GuillaumeGomez:neg-implementors, r=yotamofek

Put negative implementors first and apply same ordering logic to foreign implementors

Fixes #51129.

This PR changeda surprisingly small amount of things to put negative trait impls before the others: basically just adding a new information in the generated JS file for foreign implementors and a "negative marker" DOM element to know where to insert negative impls.

I also used this occasion to make the foreign implementors sort the same as the local ones by using `compare_names`.

You can test it [here](https://rustdoc.crud.net/imperio/neg-implementors/core/marker/trait.Sync.html#implementors).

r? ```@notriddle```
@GuillaumeGomez GuillaumeGomez deleted the neg-implementors branch December 12, 2025 09:51
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 13, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - rust-lang/rust#146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - rust-lang/rust#148717 (Point at span within local macros even when error happens in nested external macro)
 - rust-lang/rust#149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - rust-lang/rust#149770 (Rename some issue-* tests)
 - rust-lang/rust#149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - rust-lang/rust#149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - rust-lang/rust#149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - rust-lang/rust#149867 (only resolve main in bin crates)

r? `@ghost`
`@rustbot` modify labels: rollup
@Kobzol
Copy link
Member

Kobzol commented Dec 16, 2025

@GuillaumeGomez Any idea about how to claw back the doc perf? The regression is pretty big.

@GuillaumeGomez
Copy link
Member Author

Gonna take a look, I'm surprised the impact is this big.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] Implementors section of Sync (and other similar traits) should separate implementors and !implementors

9 participants