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.

29 lines
579 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 {
2023-06-27 16:13:50 -05:00
default type Id = T;
// 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);
}