dusk-network / microkelvin

Mozilla Public License 2.0
16 stars 6 forks source link

Annotation impl conflict #19

Closed vlopes11 closed 3 years ago

vlopes11 commented 4 years ago

The manual implementation of Annotation fails for a given type. Since we expect Annotation to be implemented for types that will be derived from nodes, we may fall into this situation.

Dependencies:

[dependencies]
microkelvin = "0.4"
canonical = "0.4"

Code:

use canonical::Store;
use microkelvin::{Annotation, Compound};

#[derive(Debug, Clone)]
pub struct MockAnnotation {}

impl<C, S> Annotation<C, S> for MockAnnotation
where
    C: Compound<S>,
    S: Store,
{
    fn identity() -> Self {
        unimplemented!()
    }

    fn from_leaf(leaf: &C::Leaf) -> Self {
        unimplemented!()
    }

    fn from_node(node: &C) -> Self {
        unimplemented!()
    }
}

Error:

error[E0119]: conflicting implementations of trait `microkelvin::Annotation<_, _>` for type `MockAnnotation`:
  --> src/lib.rs:7:1
   |
7  | / impl<C, S> Annotation<C, S> for MockAnnotation
8  | | where
9  | |     C: Compound<S>,
10 | |     S: Store,
...  |
22 | |     }
23 | | }
   | |_^
   |
   = note: conflicting implementation in crate `microkelvin`:
           - impl<A, C, S> Annotation<C, S> for A
             where <C as Compound<S>>::Annotation == A, A: Associative<<C as Compound<S>>::Leaf>, C: Compound<S>, S: Store;
   = note: downstream crates may implement trait `microkelvin::Associative<_>` for type `MockAnnotation`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.