Files
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
585 B
Rust
Raw Normal View History

2023-12-14 13:11:28 +01:00
//@ compile-flags: -Znext-solver
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;
fn intu(&self) -> &Self::Id {
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() {
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);
}