Skip to content
ZOLO / TE304 Type · error

trait method signature is incompatible

Compiler diagnostic TE304: trait method signature is incompatible.

Why this fires

A method in impl Trait for Type does not match the trait after substituting Self, trait arguments, associated types, and method-generic parameters. Parameter names/types and qualifiers, return type, generic bounds, and effect rows are all part of the contract.

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

impl Convert<int> for Converter {
    fn convert(self, value: str) -> str { value }
//     ^^^^^^^ error[TE304]: incompatible trait signature
}

Fix it

Copy the declared trait signature and apply the impl header's arguments. Here both value and the return type must be int. An omitted annotation may be inferred from the trait contract, but an explicit annotation must agree with it.

See also

  • TE303 — undeclared methods or overlapping impls.
  • TE305 — invalid associated types.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en