2023-12-14 13:11:28 +01:00
|
|
|
//@ compile-flags: -Znext-solver
|
2024-02-02 18:31:35 +00:00
|
|
|
//~^ 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 {
|
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 {
|
2023-11-03 14:34:08 +00:00
|
|
|
default type Id = T; //~ ERROR type annotations needed
|
2023-06-27 23:13:50 +02:00
|
|
|
// This will be fixed by #111994
|
2023-10-26 11:36:49 +00:00
|
|
|
fn intu(&self) -> &Self::Id {
|
2024-01-31 16:34:10 +00:00
|
|
|
//~^ ERROR type annotations needed
|
2024-02-09 12:17:55 +00:00
|
|
|
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() {
|
2024-02-09 12:17:55 +00:00
|
|
|
let s = transmute::<u8, Option<NonZeroU8>>(0); //~ ERROR cannot satisfy
|
2023-03-26 00:02:24 +00:00
|
|
|
assert_eq!(s, None);
|
|
|
|
}
|