use disjoint_impls::disjoint_impls; pub trait Dispatch { type Group; } pub enum GroupA {} impl Dispatch for String { type Group = GroupA; } impl Dispatch for Vec { type Group = GroupA; } pub enum GroupB {} impl Dispatch for i32 { type Group = GroupB; } impl Dispatch for u32 { type Group = GroupB; } disjoint_impls! { pub trait U where U: From { const NAME: &'static str; } impl> U for T where U: From { const NAME: &'static str = "Blanket A"; } impl> U for T where U: From { const NAME: &'static str = "Blanket B"; } } /* pub trait U where U: From { const NAME: &'static str; } const _: () = { pub trait _U0<_1: ?Sized, U> where U: From { const NAME: &'static str; } impl<_0, _1: Dispatch> _U0 for _1 where _0: From { const NAME: &'static str = "Blanket A"; } impl<_0, _1: Dispatch> _U0 for _1 where _0: From { const NAME: &'static str = "Blanket B"; } impl<_0, _1> U<_0> for _1 where _0: From, _1: Dispatch, Self: _U0<<_1 as Dispatch>::Group, _0> { const NAME: &'static str = ::Group, _0>>::NAME; } }; */ #[test] fn overlapping_trait_and_param_idents() { assert_eq!("Blanket A", >::NAME); assert_eq!("Blanket A", as U>::NAME); assert_eq!("Blanket B", >::NAME); assert_eq!("Blanket B", >::NAME); }