From 328893e1a6d71c8017d6229960da13700076ca38 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Mon, 19 Jan 2026 21:35:14 +0900 Subject: [PATCH] Fix an ICE on transmute goals with placeholders in `param_env` --- .../src/solve/trait_goals.rs | 2 +- .../transmute-with-type-params.rs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/ui/transmutability/transmute-with-type-params.rs diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 651f073efb82..003841f3af3f 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -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); } diff --git a/tests/ui/transmutability/transmute-with-type-params.rs b/tests/ui/transmutability/transmute-with-type-params.rs new file mode 100644 index 000000000000..f1630449a41b --- /dev/null +++ b/tests/ui/transmutability/transmute-with-type-params.rs @@ -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() +where + Dst: TransmuteFrom, +{ +} + +fn function_with_generic() { + is_maybe_transmutable::<(), ()>(); +} + +fn main() {}