Skip to content

fix: Unresolved type variables shouldn't escape impl selection - #23072

Open
Wilfred wants to merge 1 commit into
rust-lang:masterfrom
Wilfred:fix-escaped-region-infer
Open

fix: Unresolved type variables shouldn't escape impl selection#23072
Wilfred wants to merge 1 commit into
rust-lang:masterfrom
Wilfred:fix-escaped-region-infer

Conversation

@Wilfred

@Wilfred Wilfred commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

find_matching_impl() called resolve_vars_if_possible(), but we rely on unresolved region inference variables not escaping. Ensure that we substitute these variables.

Without this fix, we can panic when trying to resolve the variable in the wrong inference context. See the new unit test.

This seems to have always been wrong, but the panic only started occurring due when libcore changed in
rust-lang/rust#136006.

AI disclosure: Code partly written by GPT-5 Codex. I've bisected and confirmed the repro, and reviewed all the code, but possibly there's a nicer place to fix this logic.

find_matching_impl() called resolve_vars_if_possible(), but we rely on
unresolved region inference variables not escaping. Ensure that we
substitute these variables.

Without this fix, we can panic when trying to resolve the variable in
the wrong inference context. See the new unit test.

This seems to have always been wrong, but the panic only started
occurring due when libcore changed in
rust-lang/rust#136006.

AI disclosure: Code partly written by GPT-5 Codex. I've bisected and
confirmed the repro, and reviewed all the code, but possibly there's a
nicer place to fix this logic.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 7, 2026
@Wilfred

Wilfred commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

I encountered this panic when trying to generate SCIP for the rhai crate.

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

I'm not entirely sure if we should replace infer regions with error or erased, but this is good enough for now. Except - can you leave a FIXME for that please?

View changes since this review

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.

3 participants