bynk.generics.missing_eq_bound
Error A type parameter is compared with ==/!=, or passed to an Eq-bounded parameter of another generic, but is not declared Eq ([T: Eq], or where A: Eq for a receiver type's parameter). The diagnostic carries a machine-applicable fix (ADR 0430, amended by constrained-generics slice 0).
== and != work on a type parameter only if the function says so with an Eq bound. A type parameter stands for any type, and some types cannot be compared: a function, an Effect, a Query, a Stream or a held Connection. The bound puts that requirement in the signature, where a caller, hover and signature help can see it, instead of leaving it to fail inside the body. The same rule applies when a generic passes its own parameter to an Eq-bounded parameter of another generic, so a bound appears at every link of a chain of calls. Declare T: Eq; T: Ord and T: Key also allow ==. The diagnostic's fix adds the bound, and bynk check --fix applies it across a project.
Example
fn same[T](a: T, b: T) -> Bool { a == b // ✗ `T` could be a function}
fn same[T: Eq](a: T, b: T) -> Bool { a == b // ✓ the bound is in the signature}In the Book
See also
- The grammar rule it governs:
fn_decl. - Every code in its category, Generics, on the diagnostic index.
bynk explain bynk.generics.missing_eq_boundshows the same from the installed toolchain, without a network.