Skip to content

rustdoc ICE fix: When collecting Deref impls with their targets, skip the negative ones#154444

Open
jakubadamw wants to merge 3 commits intorust-lang:mainfrom
jakubadamw:issue-128801
Open

rustdoc ICE fix: When collecting Deref impls with their targets, skip the negative ones#154444
jakubadamw wants to merge 3 commits intorust-lang:mainfrom
jakubadamw:issue-128801

Conversation

@jakubadamw
Copy link
Copy Markdown
Contributor

@jakubadamw jakubadamw commented Mar 26, 2026

rustdoc assumed every Deref impl has an associated Target type, but negative impls (e.g. impl !Deref for T {}) have none.

Skip them in both the trait-impl collection pass and the HTML render pass to avoid panicking on the missing Target.

Closes #128801.

@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 Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

r? @fmease

rustbot has assigned @fmease.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, fmease, lolbinarycat, notriddle

Copy link
Copy Markdown
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks! I've got an optional request. If you don't want to impl it, I'm fine with accepting this PR as is.

View changes since this review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The two build_impl fns (one in clean/mod.rs, the other in clean/mod.rs) also invoke extra code when encountering Deref trait impls by calling build_deref_target_impls. Likewise, in render/sidebar.rs we have two places that perform extra work for deref impls.

I'm relatively sure that all four of these places still process negative deref trait impls, likely unnecessarily so. If it's not too much work for you, could you filter out negative impls in these places (unless it's impossible for negative deref impls to show up there). It probably doesn't save that much or any processing time but it might be more robust.

If you do that it might also be worth adding a HTML test in tests/rustdoc-html to ensure that we still actually render impl !Deref for … impls (in the sidebar and the main container).

Copy link
Copy Markdown
Contributor Author

@jakubadamw jakubadamw Mar 28, 2026

Choose a reason for hiding this comment

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

@fmease, thank you for reviewing the PR. 🙂

The two build_impl fns (one in clean/mod.rs, the other in clean/mod.rs)

I take it you mean clean/mod.rs and clean/inline.rs, as well as clean_impl and build_impl, respectively? I pushed a commit that addresses the suggestion for those four sites, and adds an HTML test. 🙂

Thanks again! Let me know if there’s anything else I’m missing here.

@rustbot ready

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fmease, would you be able to take a look at this again? I made the requested change. Thanks! 🙂

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The two build_impl fns (one in clean/mod.rs, the other in clean/mod.rs)

I take it you mean clean/mod.rs and clean/inline.rs, as well as clean_impl and build_impl, respectively?

Ah yes, haha. Silly typo.

Thanks for addressing my feedback! Sorry, the PR slipped through the cracks because apparently rustbot still doesn't honor @rustbot ready in review comments, so this PR didn't show up using my usual filter.

@fmease fmease 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 Mar 27, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 1, 2026
…egative ones

rustdoc assumed every `Deref` impl has an associated `Target` type,
but negative impls (e.g. `impl !Deref for T {}`) have none.
Skip them in both the trait-impl collection pass and the
HTML render pass to avoid panicking on the missing Target.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 1, 2026

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.

@jakubadamw jakubadamw requested a review from fmease April 2, 2026 16:49
Copy link
Copy Markdown
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 2, 2026

📌 Commit 02a73db has been approved by fmease

It is now in the queue for this repository.

@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 Apr 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones

rustdoc assumed every `Deref` impl has an associated `Target` type, but negative impls (e.g. `impl !Deref for T {}`) have none.

Skip them in both the trait-impl collection pass and the HTML render pass to avoid panicking on the missing `Target`.

Closes rust-lang#128801.
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #154444 (rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones)
 - #154590 (Make #[cfg] suggest any or all on #[cfg(a, b)])
 - #154691 (core: Update the feature gate on `TryFrom<integer> for bool`)
 - #154697 (rustdoc: fix href of extern crates in search results)

Failed merges:

 - #154722 (fix(lints): Improve `ill_formed_attribute_input` with better help message)
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 3, 2026
rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones

rustdoc assumed every `Deref` impl has an associated `Target` type, but negative impls (e.g. `impl !Deref for T {}`) have none.

Skip them in both the trait-impl collection pass and the HTML render pass to avoid panicking on the missing `Target`.

Closes rust-lang#128801.
rust-bors bot pushed a commit that referenced this pull request Apr 3, 2026
Rollup of 6 pull requests

Successful merges:

 - #154444 (rustdoc ICE fix: When collecting `Deref` impls with their targets, skip the negative ones)
 - #154590 (Make #[cfg] suggest any or all on #[cfg(a, b)])
 - #154691 (core: Update the feature gate on `TryFrom<integer> for bool`)
 - #154697 (rustdoc: fix href of extern crates in search results)
 - #154728 (rustdoc: Improve internal function name)
 - #154732 (fix(std): avoid AT_MINSIGSTKSZ on uclibc targets)

Failed merges:

 - #154722 (fix(lints): Improve `ill_formed_attribute_input` with better help message)
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: ICE: Deref impl without Target type involving negative Deref impl

4 participants