diff --git a/tests/ui/traits/next-solver/transmute-from-unconstrained.rs b/tests/ui/traits/next-solver/transmute-from-unconstrained.rs new file mode 100644 index 0000000000000..892b23d81d45b --- /dev/null +++ b/tests/ui/traits/next-solver/transmute-from-unconstrained.rs @@ -0,0 +1,20 @@ +//! Regression test for . +//! +//! Calling a function with an unconstrained `TransmuteFrom` obligation used to +//! trigger a `layout_of: unexpected type` ICE under the next-gen trait solver +//! instead of reporting that type annotations are needed. + +//@ compile-flags: -Znext-solver=globally + +#![feature(transmutability)] + +fn assert_transmutable() +where + (): std::mem::TransmuteFrom, +{ +} + +fn main() { + assert_transmutable() + //~^ ERROR type annotations needed +} diff --git a/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr b/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr new file mode 100644 index 0000000000000..a3a1cee105d59 --- /dev/null +++ b/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr @@ -0,0 +1,23 @@ +error[E0283]: type annotations needed + --> $DIR/transmute-from-unconstrained.rs:18:5 + | +LL | assert_transmutable() + | ^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `assert_transmutable` + | + = note: cannot satisfy `(): TransmuteFrom<_, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` +note: required by a bound in `assert_transmutable` + --> $DIR/transmute-from-unconstrained.rs:13:9 + | +LL | fn assert_transmutable() + | ------------------- required by a bound in this function +LL | where +LL | (): std::mem::TransmuteFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_transmutable` +help: consider specifying a concrete type for the type parameter `T` + | +LL | assert_transmutable::() + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`.