Rollup merge of #151373 - issue-151300, r=lcnr

Fix an ICE on transmute goals with placeholders in `param_env`

Fixes rust-lang/rust#151300

The next solver short-circuits `consider_builtin_transmute_candidate` when the goal contains non-region placeholders, since `rustc_transmute` does not support type parameters.
However, this check should likely be refined to apply only to the predicate itself: excess bounds with type params in the param env can cause the goal to be rejected even when its predicate trivially holds.

r? types
This commit is contained in:
Guillaume Gomez 2026-01-20 19:50:08 +01:00 committed by GitHub
commit c05083582c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -659,7 +659,7 @@ where
}
// `rustc_transmute` does not have support for type or const params
if goal.has_non_region_placeholders() {
if goal.predicate.has_non_region_placeholders() {
return Err(NoSolution);
}

View file

@ -0,0 +1,21 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ [next] compile-flags: -Znext-solver
//@ check-pass
// A regression test for https://github.com/rust-lang/rust/issues/151300
#![feature(transmutability)]
use std::mem::TransmuteFrom;
pub fn is_maybe_transmutable<Src, Dst>()
where
Dst: TransmuteFrom<Src>,
{
}
fn function_with_generic<T>() {
is_maybe_transmutable::<(), ()>();
}
fn main() {}