Skip to content

fix: avoid panic for mismatched opaque type parameters - #23211

Open
YUZHEthefool wants to merge 1 commit into
rust-lang:masterfrom
YUZHEthefool:fix/opaque-type-parameter-panic
Open

fix: avoid panic for mismatched opaque type parameters#23211
YUZHEthefool wants to merge 1 commit into
rust-lang:masterfrom
YUZHEthefool:fix/opaque-type-parameter-panic

Conversation

@YUZHEthefool

@YUZHEthefool YUZHEthefool commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Because the closure type in the generic method foo<T> will carry two parameters [S, T], but the associated opaque type E only allows the use of [S].
So I add a new function to check when instantiating a hidden type, check whether the type, const, lifetime parameters referenced by it exist and the types match.
And record opaque errors for illegal ATIT generic input to avoid passing incompatible parameters to the binder.
Fix: #23124

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2026

@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.

@YUZHEthefool

Copy link
Copy Markdown
Contributor Author

Maybe I need move the check to the consider_opaque_type_use stage, patch in the generic parameter remap, and keep the recovery path for NonDefiningUse🤔

@YUZHEthefool
YUZHEthefool force-pushed the fix/opaque-type-parameter-panic branch from 4dbe9c3 to 05c0f73 Compare August 21, 2026 17:24
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: highlight: type parameter #1 (#1/1) out of range when instantiating, args=[#0]

3 participants