Skip to content

fix: don't panic on a qualified path whose trait is not a trait - #22930

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
shulaoda:07-27-fix_don_t_panic_on_a_qualified_path_whose_trait_is_not_a_trait
Jul 28, 2026
Merged

fix: don't panic on a qualified path whose trait is not a trait#22930
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
shulaoda:07-27-fix_don_t_panic_on_a_qualified_path_whose_trait_is_not_a_trait

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

Closes #22799

<S as S>::S where S is a struct panics with the only possible situation here is incorrect lifetime order, even though there are no lifetimes anywhere.

check_generic_args_len() skips the self type unconditionally, but the loop that consumes the arguments only skips it when the def has a Self parameter. A struct has none, so the self type is left over, matched against a regular parameter, and trips an assertion that assumes any leftover argument is a misordered lifetime. Skipping it in the loop as well keeps the two in agreement.

This only stops the panic. rustc reports E0404: expected trait, found struct, and there is no handler for it under ide-diagnostics/src/handlers/, so we still say nothing about the path itself.

🤖 AI-assisted: understanding the issue, locating the cause, and writing the test.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 27, 2026
Comment thread crates/hir-ty/src/lower/path.rs
Comment thread crates/hir-ty/src/tests/regression.rs Outdated
@shulaoda
shulaoda force-pushed the 07-27-fix_don_t_panic_on_a_qualified_path_whose_trait_is_not_a_trait branch from 37130d9 to 94af7e7 Compare July 28, 2026 00:20
@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master 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.

@shulaoda
shulaoda requested a review from ChayimFriedman2 July 28, 2026 00:22

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ChayimFriedman2
ChayimFriedman2 added this pull request to the merge queue Jul 28, 2026
Merged via the queue into rust-lang:master with commit ffc3232 Jul 28, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: the only possible situation here is incorrect lifetime order but there are no lifetimes, only <S as S>::S;

3 participants