Skip to content

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

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
Wilfred:fix-escaped-region-infer
Aug 10, 2026
Merged

fix: Unresolved type variables shouldn't escape impl selection#23072
ChayimFriedman2 merged 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.

@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

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.
@Wilfred
Wilfred force-pushed the fix-escaped-region-infer branch from c12eb56 to d799ff3 Compare August 10, 2026 10:33
@Wilfred

Wilfred commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Added a FIXME which I think describes the your comment accurately.

@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 Aug 10, 2026
Merged via the queue into rust-lang:master with commit 513f60b Aug 10, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2026
@Wilfred
Wilfred deleted the fix-escaped-region-infer branch August 10, 2026 11:23
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.

3 participants