Skip to content
ZOLO / TE303 Type · error

undeclared or overlapping trait impl member

An `impl Trait for Type` is not coherent with its trait declaration — either it adds a method the trait does not declare, or another implementation already satisfies the same parameterized target and trait instance.

Why this fires

An implementation is not coherent with its trait declaration. Either it adds a method the trait does not declare, or another implementation can satisfy the same parameterized target and trait instance.

trait Convert<T> { fn convert(self, value: T) -> T }
struct Converter {}

impl Convert<int> for Converter {
    fn convert(self, value: int) -> int { value }
}
impl Convert<int> for Converter {
//   ^^^^^^^^^^^^ error[TE303]: overlapping impl
    fn convert(self, value: int) -> int { value }
}

Fix it

Keep exactly one witness for each target pattern and exact trait instance. Different instances such as Convert<int> and Convert<str> may coexist when their arguments cannot overlap. Remove methods that are not part of the trait, or move them to an inherent impl Type block.

See also

  • TE304 — an implemented method has the wrong signature.
  • TE305 — an associated type contract is invalid.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br