Rust

E0087 Too Many Type Parameters Fix

If you arrived here from an old E0087 message, the first fact is that the code itself is retired: the error codes index heads the E0087 page with the note that this error code is no longer emitted by the compiler, and its example - a one-parameter function called with two type arguments - fails today as E0107. The underlying mistake is unchanged, and so is the repair: the number of supplied arguments must exactly match the number of defined parameters, so you either remove the extra argument at the use site or add the missing parameter at the definition. This guide works the too-many shapes across functions, structs, enums, type aliases, and traits, shows the repairs running, and separates the neighbors that share the fix but not the wording: too few arguments, an extra lifetime argument, and a type supplied where a const was expected.

Written November 30, 2026 · Tested with Rust 1.99.0 · 18 min read

By the end of this guide
  • The rule underneath: supplied arguments must match defined parameters
  • How to read the diagnostic
  • The first failures: too many arguments, item by item
  • The zero-parameter shapes: an argument where none belong

Written November 30, 2026

Tested with Rust 1.99.0

What this guide is

Error E0087 was the too-many-type-arguments error. The error codes index defines it in one sentence - "Too many type arguments were supplied for a function" - gives the example of foo::<f64, bool>() called on a function defined as fn foo<T>(), with the comment "wrong number of type arguments: expected 1, found 2", and states the rule: "The number of supplied arguments must exactly match the number of defined type parameters." Above that definition, the same page carries the note that decides how to read any E0087 message today: "this error code is no longer emitted by the compiler."

That note is not a technicality. In this guide's probed set, not one too-many shape emitted E0087 - every one of them emitted E0107, the current wrong-number-of-generic-arguments code, whose index page opens "An incorrect number of generic arguments was provided." So this guide is written under the E0087 name you searched for, and its transcripts show the code the current compiler actually produces. The diagnosis and the repairs are the ones E0087 always pointed at; only the number on the error line has changed.

The practical payoff is that the current diagnostic does the counting for you. Each E0107 failure in the probed set names the kind of item ("function takes 1 generic argument but 2 generic arguments were supplied", "struct takes...", "enum takes...", "trait takes..."), underlines the extra argument with the help "remove the unnecessary generic argument", and adds a note pointing at the definition - "function defined here, with 1 generic parameter: T" - so you can see both sides of the mismatch in one message. Read the two counts first: they tell you whether to edit the use site or the definition.

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: supplied arguments must match defined parameters

The E0087 page's rule - supplied must exactly match defined - is the same rule the E0107 page states for generic arguments generally: "When using/declaring an item with generic arguments, you must provide the exact same number". The Rust Reference's generic parameters section is where the defined side of that count comes from: an item's generic parameters are the type, lifetime, and const parameters declared in its angle brackets, and a use of the item supplies arguments against that declared list, in order. That ordering is why the wrong-kind neighbor at the end of this guide fails differently: positions in the list have kinds, and a type sitting in a const parameter's position is not a count error but a kind error.

Two consequences follow in the probed set. First, the count is over all generic arguments together where kinds are mixed: a struct declared with one type parameter and one const parameter "takes 2 generic arguments", and supplying three is the same E0107 as supplying two to a one-parameter function. Second, a parameter with a default still counts toward the defined total - in the checker's probe, supplying three arguments to a struct defined with one type parameter and one defaulted type parameter failed with "struct takes at most 2 generic arguments but 3 generic arguments were supplied" - but a trailing defaulted parameter may itself be left out of an explicit list, and a parameter the compiler could infer at a call still has to be answered for when you write a turbofish list yourself, which does not accept a partial list. The repairs below either trim the supplied list to the defined count or extend the definition to the supplied count.

How to read the diagnostic

In the probed set, the too-many E0107 header has one shape: " takes generic argument(s) but generic arguments were supplied", where the kind word is function, struct, enum, or trait, matching the item used. The span underlines the item name, marks the extra argument, and attaches the help "remove the unnecessary generic argument" to it - the compiler is pointing at the exact token its first suggested repair deletes. The note then shows the definition with its parameters marked, which is the evidence you need for the other repair direction: if the extra argument carries real meaning, the definition is missing a parameter, and the note shows you where it would go.

The neighbors read differently, and the differences are in the header itself. Too few arguments says "but 1 generic argument was supplied" against a larger defined count, or, for a struct used with no brackets at all, "missing generics for struct Foo" with the help "add missing generic argument". An extra lifetime argument is counted separately, as a lifetime: "function takes 0 lifetime arguments but 1 lifetime argument was supplied". And a type in a const position is not counted at all - it is E0747, with no E0107 in the output. The sections below keep those wordings separate, because the repair follows the wording.

The first failures: too many arguments, item by item

The error index's own E0087 example, verbatim in shape: a function with one type parameter, called with two. This is the program the retired code was defined on, and today it is E0107:

Rust
fn foo<T>() {}
fn main() {
    foo::<f64, bool>();
}
Output
error[E0107]: function takes 1 generic argument but 2 generic arguments were supplied
 --> p1.rs:3:5
  |
3 |     foo::<f64, bool>();
  |     ^^^      ------ help: remove the unnecessary generic argument
  |     |
  |     expected 1 generic argument
  |
note: function defined here, with 1 generic parameter: `T`
 --> p1.rs:1:4
  |
1 | fn foo<T>() {}
  |    ^^^ -

error: aborting due to 1 previous error

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

A struct field is the same mismatch in type position. The E0107 index's own too-many example is a struct Foo<T> used as Foo<S, T> inside a two-parameter struct; in the probed set that shape is:

Rust
struct Foo<T> {
    x: T,
}
struct Baz<S, T> {
    a: Foo<S, T>,
    b: S,
    c: T,
}
fn main() {
    let _b: Baz<u8, u16>;
    println!("ok");
}
Output
error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied
 --> p2.rs:5:8
  |
5 |     a: Foo<S, T>,
  |        ^^^  --- help: remove the unnecessary generic argument
  |        |
  |        expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> p2.rs:1:8
  |
1 | struct Foo<T> {
  |        ^^^ -

error: aborting due to 1 previous error

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

An enum used with two arguments against one parameter fails identically in structure, with "enum" as the kind word:

Rust
enum Choice<T> {
    One(T),
    None,
}
fn main() {
    let _c: Choice<u8, bool> = Choice::None;
    println!("ok");
}
Output
error[E0107]: enum takes 1 generic argument but 2 generic arguments were supplied
 --> p3.rs:6:13
  |
6 |     let _c: Choice<u8, bool> = Choice::None;
  |             ^^^^^^   ------ help: remove the unnecessary generic argument
  |             |
  |             expected 1 generic argument
  |
note: enum defined here, with 1 generic parameter: `T`
 --> p3.rs:1:6
  |
1 | enum Choice<T> {
  |      ^^^^^^ -

error: aborting due to 1 previous error

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

A type alias does not add a parameter list of its own in this shape - the alias target's count is what is checked, and supplying two arguments to the one-parameter struct through the alias is E0107 naming the struct:

Rust
struct Pair<T> {
    x: T,
}
type P = Pair<u8, u16>;
fn main() {
    let _p: P;
    println!("ok");
}
Output
error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied
 --> p4.rs:4:10
  |
4 | type P = Pair<u8, u16>;
  |          ^^^^   ----- help: remove the unnecessary generic argument
  |          |
  |          expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> p4.rs:1:8
  |
1 | struct Pair<T> {
  |        ^^^^ -

error: aborting due to 1 previous error

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

A trait in an impl header is checked the same way. A one-parameter trait implemented with two arguments:

Rust
trait Convert<T> {
    fn convert(&self) -> T;
}
struct Num(u8);
impl Convert<u8, bool> for Num {
    fn convert(&self) -> u8 {
        self.0
    }
}
fn main() {
    println!("{}", Num(3).convert());
}
Output
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
 --> p11.rs:5:6
  |
5 | impl Convert<u8, bool> for Num {
  |      ^^^^^^^   ------ help: remove the unnecessary generic argument
  |      |
  |      expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> p11.rs:1:7
  |
1 | trait Convert<T> {
  |       ^^^^^^^ -

error: aborting due to 1 previous error

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

In all five shapes the failing line is the use, not the definition: each definition is legal on its own, and each use supplies exactly one argument more than its item defines.

The zero-parameter shapes: an argument where none belong

The extreme case of too many is supplying an argument to an item that defines none. A non-generic struct given a type argument fails with a defined count of zero - the header reads "struct takes 0 generic arguments but 1 generic argument was supplied", and the help changes to "remove the unnecessary generics", brackets and all:

Rust
struct Bar {
    x: u8,
}
fn main() {
    let _b: Bar<u32> = Bar { x: 1 };
    println!("ok");
}
Output
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
 --> p8.rs:5:13
  |
5 |     let _b: Bar<u32> = Bar { x: 1 };
  |             ^^^----- help: remove the unnecessary generics
  |             |
  |             expected 0 generic arguments
  |
note: struct defined here, with 0 generic parameters
 --> p8.rs:1:8
  |
1 | struct Bar {
  |        ^^^

error: aborting due to 1 previous error

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

An extra lifetime argument to a non-generic function is the same shape counted in lifetimes. The E0107 index lists this case explicitly - f::<'static>() on fn f(), commented "wrong number of lifetime arguments: expected 0, found 1" - and in the probed set it is:

Rust
fn f() {}
fn main() {
    f::<'static>();
}
Output
error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> p7.rs:3:5
  |
3 |     f::<'static>();
  |     ^----------- help: remove the unnecessary generics
  |     |
  |     expected 0 lifetime arguments
  |
note: function defined here, with 0 lifetime parameters
 --> p7.rs:1:4
  |
1 | fn f() {}
  |    ^

error: aborting due to 1 previous error

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

For these shapes there is no definition-side repair that keeps the code's meaning: the item was never generic, so the argument has nothing to bind to. Either the brackets come off the use, as in fix f4 below, or the item genuinely needs to become generic - a definition change, not a call-site edit.

Mixed kinds: type and const parameters count together

A struct with a type parameter and a const parameter defines two generic parameters, and the diagnostic counts them together. Supplying a third argument - a second const value with nowhere to go - is E0107 with a defined count of 2:

Rust
struct Arr<T, const N: usize> {
    data: [T; N],
}
fn main() {
    let _a: Arr<u8, 3, 4>;
    println!("ok");
}
Output
error[E0107]: struct takes 2 generic arguments but 3 generic arguments were supplied
 --> p9.rs:5:13
  |
5 |     let _a: Arr<u8, 3, 4>;
  |             ^^^      --- help: remove the unnecessary generic argument
  |             |
  |             expected 2 generic arguments
  |
note: struct defined here, with 2 generic parameters: `T`, `N`
 --> p9.rs:1:8
  |
1 | struct Arr<T, const N: usize> {
  |        ^^^ -  --------------

error: aborting due to 1 previous error

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

The note underlines both defined parameters, of both kinds: "T" and the const parameter N. So when a header's defined count looks larger than the number of type parameters you remember writing, check the const parameters before assuming the compiler miscounted - in the probed set, they are part of the same count. The matching correct use, with exactly one argument per parameter, is fix f5 below.

The traps: neighbors that are not the too-many shape

Trap
Three nearby shapes fail differently, or for a different reason.

Too few arguments is the same code, E0107, with the counts reversed. A two-parameter function called with one explicit argument:

Rust
fn foo<T, U>() {}
fn main() {
    foo::<bool>();
}
Output
error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
 --> p6.rs:3:5
  |
3 |     foo::<bool>();
  |     ^^^   ---- supplied 1 generic argument
  |     |
  |     expected 2 generic arguments
  |
note: function defined here, with 2 generic parameters: `T`, `U`
 --> p6.rs:1:4
  |
1 | fn foo<T, U>() {}
  |    ^^^ -  -
help: add missing generic argument
  |
3 |     foo::<bool, U>();
  |               +++

error: aborting due to 1 previous error

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

And a generic struct used with no argument list at all is also E0107, but with a different header - "missing generics for struct" - and the opposite help, "add missing generic argument". This is the E0107 index's first erroneous example shape, struct Bar { x: Foo } against struct Foo<T>:

Rust
struct Foo<T> {
    x: T,
}
struct Bar {
    x: Foo,
}
fn main() {
    let _b: Bar;
    println!("ok");
}
Output
error[E0107]: missing generics for struct `Foo`
 --> p5.rs:5:8
  |
5 |     x: Foo,
  |        ^^^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> p5.rs:1:8
  |
1 | struct Foo<T> {
  |        ^^^ -
help: add missing generic argument
  |
5 |     x: Foo<T>,
  |           +++

error: aborting due to 1 previous error

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

Both too-few shapes are covered in depth by the E0107 guide; they are shown here because the repair direction flips with the counts - too many trims the use or grows the definition, too few does the reverse - and misreading which side is short sends the edit to the wrong line.

A type supplied where a const generic was expected is not a count error at all. A struct whose only parameter is a const N, used with a type argument in that position, produced E0747 in the probed set - "type provided when a constant was expected" - and no E0107:

Rust
struct Arr<const N: usize> {
    data: [u8; N],
}
fn main() {
    let _a: Arr<u8>;
    println!("ok");
}
Output
error[E0747]: type provided when a constant was expected
 --> p10.rs:5:17
  |
5 |     let _a: Arr<u8>;
  |                 ^^
  |
help: if this generic argument was intended as a const parameter, surround it with braces
  |
5 |     let _a: Arr<{ u8 }>;
  |                 +    +

error: aborting due to 1 previous error

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

The help even anticipates the confusion, offering to brace the argument as a const expression - which would still be a type inside braces, not a value, so in this shape the real repair is to supply a const value (or nothing, where inference or a default applies), not to adjust any count. Kind errors and count errors share the angle brackets and nothing else.

Fixes in reach order

First, remove the extra argument at the use site - the compiler's own help, and the right repair when the definition is the intended one. The index's E0087 example, with the call trimmed to the one defined parameter, compiles and runs:

Rust
fn foo<T>() -> u8 {
    7
}
fn main() {
    println!("{}", foo::<f64>());
}
Output
7

The output is 7, the value the corrected function returns. The same trim repairs the struct shape: the p2 failure, with each field given a one-argument Foo matching its own parameter, compiles and runs:

Rust
struct Foo<T> {
    x: T,
}
struct Baz<S, T> {
    a: Foo<S>,
    b: Foo<T>,
}
fn main() {
    let z = Baz { a: Foo { x: 1u8 }, b: Foo { x: 2u16 } };
    println!("{} {}", z.a.x, z.b.x);
}
Output
1 2

The output is 1 2 - the two fields' values, in declaration order. Note what the repair did to the shape of the code: the second parameter T did not disappear, it moved to its own Foo<T> field. Where two supplied arguments were carrying two real values, the fix is usually of this kind - each value gets its own correctly-counted use - rather than a value being deleted.

The enum shape trims the same way. The p3 failure, with the type used at its defined count of one, compiles and runs:

Rust
enum Choice<T> {
    One(T),
    None,
}
fn main() {
    let c: Choice<u8> = Choice::One(9);
    match c {
        Choice::One(v) => println!("{}", v),
        Choice::None => println!("none"),
    }
}
Output
9

The output is 9, the value carried by the One variant.

Second, when the item defines no parameters, remove the brackets entirely. The p8 failure, with the non-generic struct used bare, compiles and runs:

Rust
struct Bar {
    x: u8,
}
fn main() {
    let b: Bar = Bar { x: 1 };
    println!("{}", b.x);
}
Output
1

The output is 1, the field's value.

Third, for mixed kinds, match the defined list position by position - one argument per parameter, of the right kind in each position. The p9 struct at its exact defined count, a type followed by a const value, compiles and runs:

Rust
struct Arr<T, const N: usize> {
    data: [T; N],
}
fn main() {
    let a: Arr<u8, 3> = Arr { data: [1, 2, 3] };
    println!("{}", a.data.len());
}
Output
3

The output is 3, the length of the array the const argument sized.

Last, the definition-side direction: if the extra argument at the use site expresses a distinction the type genuinely needs - two element types, a size the current definition hard-codes - then the definition is the wrong side, and the repair is to add the parameter there and use it in the definition, so the supplied count becomes the defined count. That direction is a design change, not a diagnostic repair: in the probed set every failure above was fixed at the use site, and no probed program needed a new parameter to run. Reach for it only when the trimmed code would lose information the program actually uses.

Decision summary

E0087, "too many type arguments were supplied for a function", is a retired code: its index page says it is no longer emitted, and in this guide's probed set every too-many shape - a function, a struct field, an enum, a type alias target, and a trait in an impl header, each supplied one argument over its defined count, plus a non-generic struct supplied one argument against a defined count of zero, and a mixed type-and-const list supplied three against two - emitted E0107 instead, with a header naming the item kind and both counts, a help marking the extra argument for removal, and a note showing the definition's parameters. An extra lifetime argument to a non-generic function is also E0107, counted as a lifetime argument. The repairs act at the use site in the probed set: remove the extra argument, remove the brackets entirely for a non-generic item, or match a mixed list position by position; adding a parameter at the definition is the remaining direction when the extra argument carries real meaning. The neighbors are distinct in the probed set: too few arguments is E0107 with reversed counts or a "missing generics" header, and a type supplied in a const parameter's position is E0747, a kind error with no count involved.

Checklist

  • If an old message, book, or answer names E0087, translate it before searching current documentation: in the probed set, the same shapes are E0107 today.
  • Read both counts in the header first: supplied over defined is the too-many shape; supplied under defined is the too-few shape, and the repair direction flips between them.
  • Follow the underlined argument: in the probed set, the too-many help marks the extra argument itself - that token is where the use-site repair lands.
  • Check the definition note before editing: it shows every defined parameter, including const parameters, which in the probed set count toward the same total as type parameters.
  • For a defined count of zero, remove the whole bracketed list, not just one argument - the item is not generic.
  • Check the kind of each position before adjusting a count: in the probed set, a type in a const position is E0747, and no count change repairs it.

Sources

  • Rust error codes index, E0087 - the note that this error code is no longer emitted by the compiler; the definition "Too many type arguments were supplied for a function"; the erroneous example fn foo<T>() {} called as foo::<f64, bool>() with the comment "wrong number of type arguments: expected 1, found 2"; the rule that the number of supplied arguments must exactly match the number of defined type parameters.
  • Rust error codes index, E0107 - an incorrect number of generic arguments was provided; the erroneous examples covering a generic struct used with no arguments ("expected 1, found 0"), the same struct used with two ("expected 1, found 2"), a two-parameter function called with one and with three, and a non-generic function given a lifetime argument ("expected 0, found 1"); the rule that when using or declaring an item with generic arguments, you must provide the exact same number, with corrected examples.
  • The Rust Reference, Generic parameters - generic parameters on items: the type, lifetime, and const parameters declared for an item, against which generic arguments at a use are supplied.

Keep Exploring