Rust

E0107 Wrong Generics Fix

The item declares a fixed number of generic parameters; the use supplies a different number. This guide separates the shapes that produce E0107 - too many, too few, none where one is required, a type argument where the trait takes an associated type, a lifetime where none is declared - and matches each one to the correction that makes the counts agree: remove an argument, add one, or bind the associated type.

Written November 23, 2026 · Tested with Rust 1.99.1 · 26 min read

By the end of this guide
  • The rule underneath: the supplied count must equal the declared count, parameter kind by parameter kind
  • How to read the diagnostic
  • The first failure: a struct given an extra type argument
  • The second failure: a struct used with no generic argument

Written November 23, 2026

Tested with Rust 1.99.1

What this guide is

Error E0107 is a count disagreement in angle brackets. The error codes index states it in one line: an incorrect number of generic arguments was provided. Every generic item - a struct, an enum, a function, a trait - declares a fixed list of generic parameters in its definition, and every use of the item that writes generic arguments out must supply the same number. Supply one too many, one too few, or one where the item declares none, and the use is E0107, whatever the arguments themselves are.

The forms in this guide each reproduce E0107 with a small, complete program, and each fails at a different kind of use. A struct given an extra type argument. The same struct used with no argument at all. A standard library struct, HashMap, given only one of its two required type arguments. A generic function called with an extra argument in the turbofish. A generic function called with one turbofish argument missing. A trait implemented with an extra argument. A trait, Iterator, given a type argument when it declares no generic parameters at all, because the type belongs in an associated type binding instead. And a lifetime argument supplied to a function that declares no lifetime parameters. In each family the failing program is small, the full compiler output is shown, and the fix makes the supplied count match the declared count - or, in the Iterator family, moves the type to the position the trait actually declares.

Three neighboring results are not E0107 and are worked only in the traps and the decision summary. A lifetime that a signature needs but does not name at all is E0106 - the subject of the E0106 guide - because nothing was counted wrong; a required lifetime is absent from the declaration itself. The wrong number of ordinary value arguments in a function call is E0061 - the subject of the E0061 guide - because the count that is off is in parentheses, not in angle brackets. And a value whose type does not match the type expected is E0308, where the counts on both sides can be exactly right.

Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.

The rule underneath: the supplied count must equal the declared count, parameter kind by parameter kind

The Reference states that functions, type aliases, structs, enumerations, unions, traits, and implementations may be parameterized by types, constants, and lifetimes, with the parameters listed in angle brackets immediately after the name of the item - after impl itself for implementations. That declaration list is the whole contract for E0107: it fixes how many arguments a use may supply, and of which kinds. The order of the parameters is restricted - lifetime parameters first, then type and const parameters intermixed - and the arguments at a use follow their own order in a path: lifetime arguments, then type arguments, then const arguments, then equality constraints, which is where associated type bindings such as Item = i32 sit.

The error codes index states the consequence directly: when using or declaring an item with generic arguments, you must provide the exact same number. Its own examples cover most of this guide's shapes - a struct used bare where one argument is expected, a struct given two where one is expected, a two-parameter function called with one turbofish argument and with three, and a lifetime argument supplied to a function that expects none. Two qualifications keep the rule from being read too flatly. First, a parameter with a default does not have to be supplied: HashMap declares its hasher parameter with a default, so HashMap<String, i32> supplies two arguments against a longer declaration list and is complete - which is why the HashMap diagnostic below says "at least 2", not "2". Second, in many positions the arguments do not have to be written at all, because inference supplies them: a generic function usually needs no turbofish, and a struct annotation can often be omitted entirely. E0107 is never about an argument the compiler could have inferred - it fires only where arguments were written and the written count disagrees with the declaration, or where a written use names the item with no arguments in a position that requires them.

One family turns on a different distinction. Some traits parameterize their implementors through associated types rather than generic parameters: Iterator declares no generic parameters, and the element type is its associated type Item. Supplying Iterator<i32> treats the trait as if it declared one parameter, and the count is wrong by construction - expected 0, found 1. The correction is not to delete the type but to move it: Iterator<Item = i32> binds the associated type, in the equality-constraint position the Reference's argument order reserves for it, and the compiler's help prints exactly that rewrite.

How to read the diagnostic

The header states both counts and the kind of item: "struct takes 1 generic argument but 2 generic arguments were supplied", "function takes 2 generic arguments but 1 generic argument was supplied", "trait takes 0 generic arguments but 1 generic argument was supplied", "function takes 0 lifetime arguments but 1 lifetime argument was supplied". Read it literally - it has already done the arithmetic. The one header with different wording is the missing case, "missing generics for struct Pair", where no brackets were written at all; the label under the caret then states the expected count.

The note is the second half of the diagnosis: "struct defined here, with 1 generic parameter: T", "function defined here, with 2 generic parameters: T, U", "trait defined here, with 0 generic parameters". It points at the declaration and lists its parameters, which is the list to count your arguments against. When the declaration is your own, the note points into your file; when it is a standard library item, it points into the library source, and the parameter list it shows - defaults included - is still the contract. The helps then perform the arithmetic correction: "remove the unnecessary generic argument" underlines the argument to delete, "add missing generic argument" shows where the missing one goes, and "turn the generic argument into an associated item binding" rewrites a miscounted trait argument into the binding form. Where a help underlines one specific argument for removal, it is identifying the surplus by position - the arguments are matched to parameters in order, so the surplus is the one past the declared list, not whichever argument looks least wanted.

The first failure: a struct given an extra type argument

Pair declares one type parameter, T, for its single field. The annotation supplies two arguments, i32 and String - one more than the declaration has parameters to receive:

Rust
struct Pair<T> { first: T }
fn main() {
    let p: Pair<i32, String> = Pair { first: 7 };
    println!("{}", p.first);
}
Terminal
$ rustc --edition 2021 fail_pair_extra.rs -o fail_pair_extra
error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied
 --> fail_pair_extra.rs:3:12
  |
3 |     let p: Pair<i32, String> = Pair { first: 7 };
  |            ^^^^    -------- help: remove the unnecessary generic argument
  |            |
  |            expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> fail_pair_extra.rs:1:8
  |
1 | struct Pair<T> { first: T }
  |        ^^^^ -

error: aborting due to 1 previous error

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

The help underlines String, the second argument, because arguments match parameters in order: i32 fills T, and String has no parameter left to fill. That positional reading decides the fix when the two arguments differ - the question is never which argument to keep in the abstract, it is what the single declared parameter should be. Here the value stored is an integer, so T is i32 and the surplus argument comes off:

Rust
struct Pair<T> { first: T }
fn main() {
    let p: Pair<i32> = Pair { first: 7 };
    println!("{}", p.first);
}
Terminal
$ rustc --edition 2021 fix_pair_extra.rs -o fix_pair_extra
$ ./fix_pair_extra
7

The output is 7, the stored value. The other resolution exists and is a design change rather than a correction: if the struct was meant to hold two types, the declaration gains a second parameter - struct Pair<T, U> with a second field - and the two-argument use becomes right. E0107 itself cannot say which side is wrong; it says only that the two sides disagree. The declaration is normally the authority, because every other use of the item was written against it.

The second failure: a struct used with no generic argument

The opposite direction against the same declaration. Pair still declares T, but this annotation writes the bare name with no brackets at all, in a position where the argument cannot be left to inference - a written type has to name the parameter's value or the parameter itself:

Rust
struct Pair<T> { first: T }
fn main() {
    let p: Pair = Pair { first: 7 };
    println!("{}", p.first);
}
Terminal
$ rustc --edition 2021 fail_pair_missing.rs -o fail_pair_missing
error[E0107]: missing generics for struct `Pair`
 --> fail_pair_missing.rs:3:12
  |
3 |     let p: Pair = Pair { first: 7 };
  |            ^^^^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> fail_pair_missing.rs:1:8
  |
1 | struct Pair<T> { first: T }
  |        ^^^^ -
help: add missing generic argument
  |
3 |     let p: Pair<T> = Pair { first: 7 };
  |                +++

error: aborting due to 1 previous error

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

The header changes shape for this direction - "missing generics for struct Pair" instead of a takes/supplied count - and the help inserts a placeholder, Pair<T>, naming the parameter rather than a concrete type. The placeholder is a template, not the fix: in real code the argument is the concrete type the value determines, here i32 from the stored 7. The fix supplies it:

Rust
struct Pair<T> { first: T }
fn main() {
    let p: Pair<i32> = Pair { first: 7 };
    println!("{}", p.first);
}
Terminal
$ rustc --edition 2021 fix_pair_missing.rs -o fix_pair_missing
$ ./fix_pair_missing
7

The output is 7. Note the boundary of this family: omitting the annotation altogether - let p = Pair { first: 7 }; - is not an error, because inference then has no written count to check. The error needs the name written in a type position with its required arguments absent; the same is true of Vec written bare in an annotation, which fails the same way with "missing generics for struct Vec".

The third failure: a standard library type given too few arguments

HashMap is the standard library's hash map, documented as HashMap<K, V, S = RandomState, ...> - a key type and a value type, then further parameters that carry defaults. The annotation supplies only the key type:

Rust
use std::collections::HashMap;
fn main() {
    let m: HashMap<String> = HashMap::new();
    println!("{}", m.len());
}
Terminal
$ rustc --edition 2021 fail_hashmap_one.rs -o fail_hashmap_one
error[E0107]: struct takes at least 2 generic arguments but 1 generic argument was supplied
   --> fail_hashmap_one.rs:3:12
    |
  3 |     let m: HashMap<String> = HashMap::new();
    |            ^^^^^^^ ------ supplied 1 generic argument
    |            |
    |            expected at least 2 generic arguments
    |
note: struct defined here, with at least 2 generic parameters: `K`, `V`
   --> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/collections/hash/map.rs:245:12
    |
245 | pub struct HashMap<
    |            ^^^^^^^
246 |     K,
    |     -
247 |     V,
    |     -
help: add missing generic argument
    |
  3 |     let m: HashMap<String, V> = HashMap::new();
    |                          +++

error: aborting due to 1 previous error

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

Two details separate this from the second family. The wording is "at least 2": the declaration continues past K and V into parameters with defaults, and those may be omitted, so the contract is a minimum rather than an exact count - the one common case where the index's "exact same number" is softened by defaults. And the note points into the standard library source rather than your file, because the declaration being counted against lives there. The fix adds the value type, i32; the defaulted parameters stay unwritten:

Rust
use std::collections::HashMap;
fn main() {
    let mut m: HashMap<String, i32> = HashMap::new();
    m.insert("a".to_string(), 1);
    println!("{}", m.len());
}
Terminal
$ rustc --edition 2021 fix_hashmap_one.rs -o fix_hashmap_one
$ ./fix_hashmap_one
1

The output is 1, the number of entries after the insert. Supplying a third argument is also legitimate for this type - it names the hasher, HashMap<String, i32, RandomState> - which is worth knowing before "correcting" a three-argument HashMap on sight: for types with defaults, count the parameters without defaults first, and only those set the minimum.

The fourth failure: a generic function called with an extra turbofish argument

In an expression, generic arguments for a function are written after :: in the turbofish form the Reference describes - the :: is required there so the < is not read as a comparison. show declares one type parameter, and the call supplies two:

Rust
fn show<T>(value: T) -> T { value }
fn main() {
    println!("{}", show::<i32, String>(7));
}
Terminal
$ rustc --edition 2021 fail_fn_extra.rs -o fail_fn_extra
error[E0107]: function takes 1 generic argument but 2 generic arguments were supplied
 --> fail_fn_extra.rs:3:20
  |
3 |     println!("{}", show::<i32, String>(7));
  |                    ^^^^      -------- help: remove the unnecessary generic argument
  |                    |
  |                    expected 1 generic argument
  |
note: function defined here, with 1 generic parameter: `T`
 --> fail_fn_extra.rs:1:4
  |
1 | fn show<T>(value: T) -> T { value }
  |    ^^^^ -

error: aborting due to 1 previous error

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

The shape matches the first family - one surplus argument, underlined by the help - moved from a type position into a call. The surplus is again positional: i32 fills T, and String has nowhere to go. The fix removes it:

Rust
fn show<T>(value: T) -> T { value }
fn main() {
    println!("{}", show::<i32>(7));
}
Terminal
$ rustc --edition 2021 fix_fn_extra.rs -o fix_fn_extra
$ ./fix_fn_extra
7

The output is 7, the value passed through. Most calls to a generic function write no turbofish at all and let inference take every parameter from the arguments - the turbofish appears when inference cannot, or when the programmer wants the types pinned. That is why this family usually arrives as an edit artifact: a parameter was removed from the function, or copied from a call to a wider function, and the call site kept the old list.

The fifth failure: a generic function called with a turbofish argument missing

first declares two type parameters, T and U. The call's turbofish supplies only one - a partial list, which Rust does not accept: a written turbofish is all-or-nothing up to parameters that inference or _ placeholders cover, and here the count itself is short:

Rust
fn first<T, U>(a: T, _b: U) -> T { a }
fn main() {
    println!("{}", first::<i32>(1, 2));
}
Terminal
$ rustc --edition 2021 fail_fn_few.rs -o fail_fn_few
error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
 --> fail_fn_few.rs:3:20
  |
3 |     println!("{}", first::<i32>(1, 2));
  |                    ^^^^^   --- supplied 1 generic argument
  |                    |
  |                    expected 2 generic arguments
  |
note: function defined here, with 2 generic parameters: `T`, `U`
 --> fail_fn_few.rs:1:4
  |
1 | fn first<T, U>(a: T, _b: U) -> T { a }
  |    ^^^^^ -  -
help: add missing generic argument
  |
3 |     println!("{}", first::<i32, _>(1, 2));
  |                               +++

error: aborting due to 1 previous error

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

The help inserts _, the inference placeholder, which is a genuine fix and not only a template: first::<i32, _>(1, 2) compiles, letting the second argument's type be inferred from the value 2. The fix below spells the type out instead, which is clearer where the inferred type is not obvious at the call site:

Rust
fn first<T, U>(a: T, _b: U) -> T { a }
fn main() {
    println!("{}", first::<i32, i32>(1, 2));
}
Terminal
$ rustc --edition 2021 fix_fn_few.rs -o fix_fn_few
$ ./fix_fn_few
1

The output is 1, the first argument, which is what the function returns. The contrast with the second family is the position: there, a written type omitted brackets the position requires; here, brackets were written and closed early. Both are the same arithmetic - supplied count below declared count - and the note's parameter list is the checklist for either.

The sixth failure: a trait implemented with an extra argument

Traits are generic items too, and an impl names the trait with its arguments. Label declares one type parameter; the implementation supplies two:

Rust
trait Label<T> { fn label(&self, value: T) -> String; }
struct Thing;
impl Label<i32, String> for Thing {
    fn label(&self, value: i32) -> String { format!("n={}", value) }
}
fn main() {
    println!("{}", Thing.label(3));
}
Terminal
$ rustc --edition 2021 fail_trait_extra.rs -o fail_trait_extra
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
 --> fail_trait_extra.rs:3:6
  |
3 | impl Label<i32, String> for Thing {
  |      ^^^^^    -------- help: remove the unnecessary generic argument
  |      |
  |      expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> fail_trait_extra.rs:1:7
  |
1 | trait Label<T> { fn label(&self, value: T) -> String; }
  |       ^^^^^ -

error: aborting due to 1 previous error

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

The header's first word is the only change from the struct and function families - "trait takes 1 generic argument" - and the correction is the same: the implementation body already matches the one-parameter trait, since label takes an i32, so the surplus String comes off the impl line:

Rust
trait Label<T> { fn label(&self, value: T) -> String; }
struct Thing;
impl Label<i32> for Thing {
    fn label(&self, value: i32) -> String { format!("n={}", value) }
}
fn main() {
    println!("{}", Thing.label(3));
}
Terminal
$ rustc --edition 2021 fix_trait_extra.rs -o fix_trait_extra
$ ./fix_trait_extra
n=3

The output is n=3, the label the implementation formats. The same count check applies wherever a trait is named with arguments - in a bound, in a dyn type, in a qualified path - not only in an impl. It is also the family where the design alternative is most often the real intent: a trait that should vary over two types gains the second parameter in its declaration, and every implementation and bound then has to supply it.

The seventh failure: a trait that takes an associated type, given a generic argument

Iterator declares no generic parameters at all. Its element type is the associated type Item, set with a binding, not a parameter. Writing the bound as Iterator<i32> supplies one argument against a declared count of zero:

Rust
fn total<I: Iterator<i32>>(iter: I) -> usize { iter.count() }
fn main() {
    println!("{}", total(vec![1, 2, 3].into_iter()));
}
Terminal
$ rustc --edition 2021 fail_iterator_arg.rs -o fail_iterator_arg
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
  --> fail_iterator_arg.rs:1:13
   |
 1 | fn total<I: Iterator<i32>>(iter: I) -> usize { iter.count() }
   |             ^^^^^^^^ expected 0 generic arguments
   |
note: trait defined here, with 0 generic parameters
  --> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:42:17
   |
42 | pub const trait Iterator {
   |                 ^^^^^^^^
help: turn the generic argument into an associated item binding
   |
 1 | fn total<I: Iterator<Item = i32>>(iter: I) -> usize { iter.count() }
   |                      ++++++

error: aborting due to 1 previous error

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

This is the one family where deleting the surplus argument is the wrong fix: Iterator alone compiles as a bound, but it throws away the element type the code meant to state. The help names the right correction - turn the argument into an associated item binding, Item = i32, in the equality-constraint position at the end of the argument list. The fix takes it, and with the element type bound, the body can also use what the binding states - here, summing the elements rather than counting them:

Rust
fn total<I: Iterator<Item = i32>>(iter: I) -> i32 { iter.sum() }
fn main() {
    println!("{}", total(vec![1, 2, 3].into_iter()));
}
Terminal
$ rustc --edition 2021 fix_iterator_arg.rs -o fix_iterator_arg
$ ./fix_iterator_arg
6

The output is 6, the sum of the three elements. The pattern generalizes to every trait with associated types - Iterator<Item = T>, IntoIterator<Item = T>, Add<Output = T> mixes both forms, a generic parameter for the right-hand side and a binding for the output. When a header says a trait takes 0 generic arguments, read it as a sign the type you supplied belongs to an associated type, and look for the binding form before removing anything.

The eighth failure: a lifetime argument supplied where none is declared

Generic arguments are not only types. plain declares no parameters of any kind, and the call supplies a lifetime argument, 'static, in the turbofish - a count error in the lifetime list, reported in its own wording:

Rust
fn plain(value: i32) -> i32 { value }
fn main() {
    println!("{}", plain::<'static>(3));
}
Terminal
$ rustc --edition 2021 fail_lifetime_fn.rs -o fail_lifetime_fn
error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> fail_lifetime_fn.rs:3:20
  |
3 |     println!("{}", plain::<'static>(3));
  |                    ^^^^^----------- help: remove the unnecessary generics
  |                    |
  |                    expected 0 lifetime arguments
  |
note: function defined here, with 0 lifetime parameters
 --> fail_lifetime_fn.rs:1:4
  |
1 | fn plain(value: i32) -> i32 { value }
  |    ^^^^^

error: aborting due to 1 previous error

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

The header counts lifetimes separately from types - "0 lifetime arguments but 1 lifetime argument was supplied" - and the note confirms the declaration has no lifetime parameters at all. Lifetimes come first in a parameter list, so a stray lifetime also shifts how the following arguments are read; an extra 'static copied from a call to a borrowing function is the usual source. The fix removes the whole turbofish, since the function takes no generic arguments of any kind:

Rust
fn plain(value: i32) -> i32 { value }
fn main() {
    println!("{}", plain(3));
}
Terminal
$ rustc --edition 2021 fix_lifetime_fn.rs -o fix_lifetime_fn
$ ./fix_lifetime_fn
3

The output is 3. Keep this family separate from a missing lifetime: here a lifetime was supplied to an item that declares none, which is a count error; a signature that needs a lifetime and names none is the first trap below, under a different code, and is fixed at the declaration rather than at the call.

The fixes in reach order

  • The header says an item "takes N generic arguments but M were supplied" with M greater than N, and the help underlines one argument: that argument is surplus - remove it, or add a parameter to the declaration if the item was meant to take it.
  • The header says "missing generics" for an item, or "takes N but M were supplied" with M below N: an argument is absent - supply it, using the note's parameter list as the checklist and _ where inference should fill a position in a turbofish.
  • The header says "at least N": the item has defaulted parameters past the first N - supply the N required ones and leave the defaulted ones unwritten, unless the default itself is what needs overriding.
  • The header says a trait "takes 0 generic arguments" and the help reads "turn the generic argument into an associated item binding": the type belongs to an associated type - rewrite it as Trait<Item = T> rather than deleting it.
  • The header counts lifetime arguments separately and the item declares none: a stray lifetime was supplied - remove the lifetime, or the whole turbofish if the item takes no generic arguments at all.
  • In every case, the note's parameter list is the authority: count the declaration's parameters, in order - lifetimes, then types and consts - and make the use match it.

Traps

  • A missing lifetime in a signature is E0106, not E0107. Nothing here is counted: longest returns a reference, and the signature names no lifetime at all, so there is no argument list to miscount - the declaration itself is incomplete:
Rust
fn longest(x: &str, y: &str) -> &str { if x.len() > y.len() { x } else { y } }
fn main() {
    println!("{}", longest("ab", "c"));
}
Terminal
$ rustc --edition 2021 probe_e0106.rs -o probe_e0106
error[E0106]: missing lifetime specifier
 --> probe_e0106.rs:1:33
  |
1 | fn longest(x: &str, y: &str) -> &str { if x.len() > y.len() { x } else { y } }
  |               ----     ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y`
help: consider introducing a named lifetime parameter
  |
1 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { if x.len() > y.len() { x } else { y } }
  |           ++++     ++          ++          ++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0106`.
Trap
The header reads "missing lifetime specifier" and the error codes index defines E0106 as a lifetime missing from a type, fixed by naming the lifetime in the declaration - the E0106 guide works that side. The boundary with the eighth family is direction: E0107 supplies a lifetime the item does not declare; E0106 fails to declare a lifetime the item needs. - The wrong number of value arguments is E0061, not E0107. add is not generic at all; the call passes one value argument where the signature takes two, and the short count is in the parentheses:
Rust
fn add(a: i32, b: i32) -> i32 { a + b }
fn main() {
    println!("{}", add(1));
}
Terminal
$ rustc --edition 2021 probe_e0061.rs -o probe_e0061
error[E0061]: this function takes 2 arguments but 1 argument was supplied
 --> probe_e0061.rs:3:20
  |
3 |     println!("{}", add(1));
  |                    ^^^--- argument #2 of type `i32` is missing
  |
note: function defined here
 --> probe_e0061.rs:1:4
  |
1 | fn add(a: i32, b: i32) -> i32 { a + b }
  |    ^^^         ------
help: provide the argument
  |
3 |     println!("{}", add(1, /* i32 */));
  |                         +++++++++++

error: aborting due to 1 previous error

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

The header reads "this function takes 2 arguments but 1 argument was supplied" - the same arithmetic as the fifth family with the word "generic" absent - and the error codes index defines E0061 as an invalid number of arguments passed when calling a function. The two codes divide by bracket: angle brackets E0107, parentheses E0061, and a single call can in principle carry both at once, in which case each is reported separately. The E0061 guide works the value side. - A value of the wrong type is E0308, not E0107. The annotation and the initializer disagree about the type itself; no generic item is involved and no count is off:

Rust
fn main() {
    let x: i32 = "hi";
    println!("{}", x);
}
Terminal
$ rustc --edition 2021 probe_e0308.rs -o probe_e0308
error[E0308]: mismatched types
 --> probe_e0308.rs:2:18
  |
2 |     let x: i32 = "hi";
  |            ---   ^^^^ expected `i32`, found `&str`
  |            |
  |            expected due to this

error: aborting due to 1 previous error

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

The header reads "mismatched types" and the error codes index defines E0308 as the expected type not matching the received type. It is the trap that waits inside E0107 fixes: supplying the right number of arguments with the wrong types - Pair<String> over an integer value, say - clears the count error and lands here, because the two checks are independent. A fix is only complete when the program compiles past both.

Decision summary

  • The header says an item "takes N generic arguments but M generic arguments were supplied" (E0107), M greater than N: an extra argument - remove the underlined one, or widen the declaration.
  • The header says "missing generics" for an item, or "takes N but M were supplied" with M below N (E0107): a missing argument - supply it, concretely or as _ in a turbofish.
  • The header says "at least N generic arguments" (E0107): required parameters are missing and the rest have defaults - supply the required ones only.
  • The header says a trait "takes 0 generic arguments but 1 generic argument was supplied" (E0107): the type is an associated type - rewrite it as a binding, Item = T.
  • The header says an item "takes 0 lifetime arguments but 1 lifetime argument was supplied" (E0107): a stray lifetime - remove it.
  • The header says "missing lifetime specifier" (E0106): the declaration names no lifetime it needs - add the lifetime parameter at the declaration.
  • The header says a function "takes N arguments but M arguments were supplied" with no "generic" in it (E0061): the value arguments are miscounted - fix the call's parentheses.
  • The header says "mismatched types" (E0308): the counts may be right and a type is wrong - fix the value or the annotation's type, not its argument count.

Checklist

  • The declared parameter list read from the diagnostic's note before any edit: it names every parameter, in order, and the supplied list must match it position by position.
  • The kind of the miscounted argument identified: type, const, or lifetime - the header counts lifetimes separately, and a stray lifetime shifts the reading of the arguments after it.
  • Defaults accounted for before calling a count wrong: a parameter with a default may be omitted, so "at least N" items are complete at N supplied arguments.
  • For a trait that takes 0 generic arguments, the associated type checked before deleting anything: the supplied type usually belongs in an Item = T binding.
  • The surplus argument identified by position, not by preference: arguments fill parameters in order, so the surplus is the one past the end of the declared list.
  • The side to change chosen deliberately: the use is normally corrected to the declaration; widening the declaration is a design change that obliges every other use to match.
  • After the count is fixed, the program compiled again and run: a correct count with a wrong type surfaces as E0308, and the fix is finished only when the output is the value the program was written to produce.

Sources

  • Rust, Error codes index: E0107 - the definition of the error: an incorrect number of generic arguments was provided, with the rule that when using or declaring an item with generic arguments the exact same number must be provided, and examples covering a struct used bare, a struct given an extra argument, a function called with too few and too many turbofish arguments, and a lifetime argument supplied where none is expected.
  • The Rust Reference, Generic parameters - functions, type aliases, structs, enumerations, unions, traits, and implementations may be parameterized by types, constants, and lifetimes, listed in angle brackets after the item's name, with lifetime parameters ordered before type and const parameters.
  • The Rust Reference, Paths - generic arguments in expression paths are written with the turbofish :: before the <, and the order of generic arguments in a path is lifetime arguments, then type arguments, then const arguments, then equality constraints such as associated type bindings.
  • The Rust Programming Language, Generic Data Types - generic type parameters in function signatures, struct definitions, and enum definitions: the parameter is declared in angle brackets in the definition and supplied in angle brackets at each use, with multiple parameters declared and supplied as a list.
  • The Rust Programming Language, Traits: Defining Shared Behavior - trait definitions and implementations: a trait is implemented for a type with impl Trait for Type, and generic traits are named with their arguments in the implementation.
  • Rust std::collections, HashMap - HashMap as a hash map declared with key and value parameters followed by defaulted parameters, HashMap<K, V, S = RandomState, ...> - the declaration behind the "at least 2" wording in the third family.
  • Rust, Error codes index: E0106 - the neighboring lifetime error: a lifetime is missing from a type, covering a signature that names no lifetime it needs rather than a lifetime supplied to an item that declares none.
  • Rust, Error codes index: E0061 - the neighboring count error for values: an invalid number of arguments was passed when calling a function, covering the count in a call's parentheses rather than in its angle brackets.
  • Rust, Error codes index: E0308 - the neighboring type error: the expected type did not match the received type, covering a wrong type supplied at the right count.

Keep Exploring