rust/tests/ui/traits/new-solver/specialization-transmute.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
607 B
Rust
Raw Normal View History

2023-03-25 19:02:24 -05:00
// compile-flags: -Ztrait-solver=next
#![feature(specialization)]
//~^ WARN the feature `specialization` is incomplete
trait Default {
type Id;
fn intu(&self) -> &Self::Id;
}
impl<T> Default for T {
default type Id = T;
fn intu(&self) -> &Self::Id {
self
//~^ ERROR cannot satisfy `T <: <T as Default>::Id`
}
}
fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
*t.intu()
}
use std::num::NonZeroU8;
fn main() {
let s = transmute::<u8, Option<NonZeroU8>>(0);
//~^ ERROR cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>
assert_eq!(s, None);
}