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.

29 lines
607 B
Rust
Raw Normal View History

2023-12-14 06:11:28 -06:00
// compile-flags: -Znext-solver
2023-03-25 19:02:24 -05:00
#![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; //~ ERROR type annotations needed
2023-06-27 16:13:50 -05:00
// This will be fixed by #111994
fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed
2023-03-25 19:02:24 -05:00
self
2023-06-27 16:13:50 -05:00
}
2023-03-25 19:02:24 -05:00
}
fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
*t.intu()
}
use std::num::NonZeroU8;
fn main() {
2023-06-27 16:13:50 -05:00
let s = transmute::<u8, Option<NonZeroU8>>(0); // this call should then error
2023-03-25 19:02:24 -05:00
assert_eq!(s, None);
}