rust/tests/ui/const-generics/defaults/trait_objects_fail.rs

31 lines
524 B
Rust
Raw Normal View History

2021-10-20 16:56:42 -05:00
trait Trait<const N: u8 = 12> {
fn uwu(&self) -> u8 {
N
}
}
impl Trait<2> for u32 {}
fn foo(arg: &dyn Trait) -> u8 {
arg.uwu()
}
trait Traitor<const N: u8 = 1, const M: u8 = N> {
fn owo(&self) -> u8 {
M
}
}
impl Traitor<2, 3> for bool {}
2021-10-20 16:56:42 -05:00
fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
arg.owo()
}
fn main() {
foo(&10_u32);
//~^ error: the trait bound `u32: Trait` is not satisfied
bar(&true);
//~^ error: the trait bound `bool: Traitor<_>` is not satisfied
2021-10-20 16:56:42 -05:00
}