Skip to content

transmutability: Stall new solver when inference variables remain#149228

Open
lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
lapla-cogito:ice_141400
Open

transmutability: Stall new solver when inference variables remain#149228
lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
lapla-cogito:ice_141400

Conversation

@lapla-cogito
Copy link
Copy Markdown
Contributor

@lapla-cogito lapla-cogito commented Nov 22, 2025

fixes #141400, fixes #148809

The new trait solver's consider_builtin_transmute_candidate() was passing types with inference variables directly to rustc_transmute(), which attempts layout computation and ICEs.

The old solver already guards against this in assemble_candidates_for_transmutability() by setting candidates.ambiguous = true. Add the equivalent guard in the new solver by returning forced_ambiguity when the predicate contains non-region inference variables.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Nov 22, 2025

r? @lcnr

rustbot has assigned @lcnr.
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

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Nov 24, 2025

It seems wrong to return an error here. It should not be impossible to transmute. We should instead stall somehow here. There should probably just be an Answer::Maybe or sth to deal with cases where there are still inference variable to get the trait solver to try again later

@lcnr lcnr 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 Nov 26, 2025
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Jan 12, 2026

☔ The latest upstream changes (presumably #151003) made this pull request unmergeable. Please resolve the merge conflicts.

@reddevilmidzy
Copy link
Copy Markdown
Member

@lapla-cogito any updates on this? thanks.

@lapla-cogito
Copy link
Copy Markdown
Contributor Author

I will update this patch in a few days.

@lapla-cogito lapla-cogito changed the title transmutability: only short-circuit is_transmutable for non-region infers transmutability: Stall new solver when inference variables remain Apr 4, 2026
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Apr 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 4, 2026

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

@lapla-cogito
Copy link
Copy Markdown
Contributor Author

lapla-cogito commented Apr 4, 2026

There should probably just be an Answer::Maybe or sth to deal with cases where there are still inference variable to get the trait solver to try again later

Since adding Answer::Maybe would ultimately result in the trait solver converting it to Certainty::AMBIGUOUS, I determined that this would only increase indirect references. That's why I implemented the changes as they are now (another reason being that the old solver already handles this conversion in a similar way, see the updated PR description).

@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 Apr 4, 2026
Comment on lines +666 to +668
if goal.predicate.has_non_region_infer() {
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
}
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.

can you move this check into ecx.is_transmutable? That should be able to just return Certainty::AMBIGUOUS which is then properly handled already

we want to handle structurally_normalize_const to return something ambiguous or to take something that references an infer var and the returned assume then does not as the infer var wasn't used.

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.

Thanks, done.

@reddevilmidzy
Copy link
Copy Markdown
Member

issue resolved in #154991

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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: layout_of: unexpected type ICE: compiler paniced and panicked while processing panic, program terminated with signal: SIGSEGV

4 participants