Skip to content

Fix rustdoc ICE when checking if a generic arg can be elided - #160295

Open
Colepng wants to merge 4 commits into
rust-lang:mainfrom
Colepng:main
Open

Fix rustdoc ICE when checking if a generic arg can be elided#160295
Colepng wants to merge 4 commits into
rust-lang:mainfrom
Colepng:main

Conversation

@Colepng

@Colepng Colepng commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #133637

The param_at call expects a index into the full generics list, while index is generated only from the children.

I also noticed a call to skip_norm_wip so I replaced that with skip_normalization

I have one question about adding the regression test, should it live under rustdoc-ui or rustdoc-ui/issue. I will add it later today.

@fmease

@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 Jul 31, 2026
@rustbot

rustbot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
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 8 candidates
  • Random selection from GuillaumeGomez, lolbinarycat, notriddle

@GuillaumeGomez

Copy link
Copy Markdown
Member

Please add a regression test.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

// Regression test for issue #133637. Previously we would index into the flattened generics list
// with the children generic indexes. This resulted in an ICE when debug assertions were on.

struct SomeDefault;

@GuillaumeGomez GuillaumeGomez Jul 31, 2026

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.

This is not the regression test for #133637 as it works fine with current nightly.

View changes since the review

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.

When I run the test locally, I run into the ICE. It might pass on current nightly since I don't believe it's built with debug assertions enabled.

@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 Jul 31, 2026
@rustbot

rustbot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Colepng

Colepng commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Aug 1, 2026
Comment thread src/librustdoc/clean/utils.rs

@fmease fmease Aug 1, 2026

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.

Could you use a smaller reproducer? One, some or all from https://github.com/rust-lang/rust/pull/160295/changes#r3696140723. Thanks!

View changes since the review

@fmease fmease Aug 1, 2026

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.

Smaller reproducer:

trait Trait<T = ()> {
    type Type<'a, 'b>;
}

struct Struct<T: Trait<()>>(T::Type<'static, 'static>);

View changes since the review

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.

When I test locally these do not ICE for me. Do you have the backtrace?

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.

I was able to minimize it to this. I haven't been successful on reproducing the ICE with a struct.

trait Trait<Default = ()> {
    type Type<'a, 'b>;
}

type Type<T> = <T as Trait>::Type<'static, 'static>;

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: cargo doc for diesel triggers debug_assertion in can_elide_generic_arg

5 participants