2024-02-16 20:02:50 +00:00
|
|
|
//@ compile-flags: -Znext-solver
|
2023-03-26 00:02:24 +00:00
|
|
|
#![feature(specialization)]
|
|
|
|
|
//~^ WARN the feature `specialization` is incomplete
|
|
|
|
|
|
|
|
|
|
trait Default {
|
2023-10-26 11:36:49 +00:00
|
|
|
type Id;
|
2023-03-26 00:02:24 +00:00
|
|
|
|
2023-10-26 11:36:49 +00:00
|
|
|
fn intu(&self) -> &Self::Id;
|
2023-03-26 00:02:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> Default for T {
|
2024-05-30 15:07:32 -04:00
|
|
|
default type Id = T;
|
2023-10-26 11:36:49 +00:00
|
|
|
fn intu(&self) -> &Self::Id {
|
2025-04-25 17:59:33 +00:00
|
|
|
self //~ ERROR mismatched types
|
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()
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-22 14:59:52 +01:00
|
|
|
use std::num::NonZero;
|
|
|
|
|
|
2023-03-26 00:02:24 +00:00
|
|
|
fn main() {
|
2025-04-25 17:59:33 +00:00
|
|
|
let s = transmute::<u8, Option<NonZero<u8>>>(0);
|
|
|
|
|
//~^ ERROR type mismatch resolving `<u8 as Default>::Id == Option<NonZero<u8>>`
|
2023-03-26 00:02:24 +00:00
|
|
|
assert_eq!(s, None);
|
|
|
|
|
}
|