-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Closed
Copy link
Description
Consider code like this:
impl<C> fmt::Display for Stuff<C>
where C: SomeTrait<Type=()>
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
panic!()
}
}
impl<C> fmt::Display for Stuff<C>
where C: SomeTrait<Type=Vec<C>>
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
panic!()
}
}It is obvious, that C cannot in any way implement the same trait so the associated Type is both () and Vec<C> at the same time. The compiler should be able to infer that these trait implementations are completely independent. Alas, in the current nightly you get something like
error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `Stuff<_>`:
--> <anon>:24:1
|
15 | impl<C> ::std::fmt::Display for Stuff<C>
| - first implementation here
...
24 | impl<C> ::std::fmt::Display for Stuff<C>
| ^ conflicting implementation for `Stuff<_>`
instead.
Metadata
Metadata
Assignees
Labels
No labels