Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/ui/traits/next-solver/transmute-from-unconstrained.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/151314>.
//!
//! 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<T>()
where
(): std::mem::TransmuteFrom<T>,
{
}

fn main() {
assert_transmutable()
//~^ ERROR type annotations needed
}
23 changes: 23 additions & 0 deletions tests/ui/traits/next-solver/transmute-from-unconstrained.stderr
Original file line number Diff line number Diff line change
@@ -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<T>()
| ------------------- required by a bound in this function
LL | where
LL | (): std::mem::TransmuteFrom<T>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_transmutable`
help: consider specifying a concrete type for the type parameter `T`
|
LL | assert_transmutable::</* Type */>()
| ++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0283`.
Loading