Skip to content
ZOLO / TE301 Type · error

generic type argument count mismatch

The number of type arguments supplied does not match the generic's declared parameter count.

Why this fires

A generic type was used with the wrong number of type arguments — either in a type annotation (Pair<int> when Pair takes two parameters) or in an impl header (impl Foo<T> on a target whose declared arity doesn't match, or on a non-generic target).

struct Pair<T, U> { first: T, second: U }

let p: Pair<int> = Pair { first: 1, second: "hello" }
//     ^^^^^^^^^ error[TE301]: type 'Pair' expects 2 type argument(s), found 1
enum Result<T, E> { Ok(T), Err(E) }

impl Result<T> {
//   ^^^^^^^^^ error[TE301]: impl on 'Result' declares 1 type parameter(s), but 'Result' has 2
    fn id(self) -> bool { return true }
}

Fix it

Match the type's declared arity:

let p: Pair<int, str> = Pair { first: 1, second: "hello" }   // ok
impl Result<T, E> {
    fn id(self) -> bool { return true }
}

See also

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br