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

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

31 lines
691 B
Rust
Raw Normal View History

2023-12-14 13:11:28 +01:00
//@ compile-flags: -Znext-solver
//~^ ERROR cannot normalize `<T as Default>::Id: '_`
2023-03-26 00:02:24 +00:00
#![feature(specialization)]
//~^ WARN the feature `specialization` is incomplete
trait Default {
type Id;
2023-03-26 00:02:24 +00:00
fn intu(&self) -> &Self::Id;
2023-03-26 00:02:24 +00:00
}
impl<T> Default for T {
default type Id = T; //~ ERROR type annotations needed
2023-06-27 23:13:50 +02:00
// This will be fixed by #111994
fn intu(&self) -> &Self::Id {
//~^ ERROR type annotations needed
self //~ ERROR cannot satisfy
2023-06-27 23:13:50 +02:00
}
2023-03-26 00:02:24 +00:00
}
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
2023-03-26 00:02:24 +00:00
assert_eq!(s, None);
}