E0091 Unused Type Parameter Fix

Written December 3, 2026 · Tested with Rust 1.99.1 · 17 min read

By the end of this guide
  • The rule underneath: an alias parameter must appear in the body
  • How to read the diagnostic
  • The first failure: the index examples
  • The same error in other places and with other decorations

Written December 3, 2026

Tested with Rust 1.99.1

What this guide is

Error E0091 means an unnecessary type parameter was given in a type alias - a parameter declared on the alias that the alias's body never uses. The error codes index puts it plainly: an unnecessary type parameter was given in a type alias, and its advice is to check you did not write too many parameters.

In the shapes probed in this guide, E0091 fires on its own for both index examples, for the same shape at the top level of a file, for an unused parameter that carries a trait bound, and for an alias that is used in a function signature - using the alias does not cure the unused parameter. The count follows the parameters in the probed shapes: two unused parameters on one alias drew two reports. A second code rides along in the probed shape where the same program also uses an unresolved name. Neighboring shapes draw a different code instead: the same unused parameter on a struct and on an enum drew E0392. At the boundary, an unused lifetime parameter and an unused const parameter on an alias drew no E0091 in the probed shapes, a function with an unused type parameter compiled and ran, and an alias whose body uses its parameter - directly, or through a phantom marker - compiles and runs. This guide shows the E0091 shapes, the ride-along and neighboring shapes, the boundary, and the repairs.

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

The rule underneath: an alias parameter must appear in the body

A type alias is a name for another type. A parameter on the alias is only meaningful if the body - the type on the right of the equals sign - mentions it, because the parameter exists to be substituted into that body at each use. A parameter the body never mentions changes nothing at any use site: every use of the alias names the same type no matter what argument is supplied for that parameter. That is the defect E0091 reports, and it is reported on the definition, whether or not the alias is ever used, and whether or not the alias is used with the parameter in a signature elsewhere - in the probed shapes both of those uses still drew the code.

Two things that look like uses do not count, in the probed shapes. A trait bound on the parameter is not a use: an alias whose only mention of its parameter was a Clone bound in the parameter list drew exactly one E0091. A where clause mentioning the parameter is not a use either: an alias whose only other mention of its parameter was a where T: Clone clause before the equals sign drew exactly one E0091 in a checker probe, with only the remove-or-refer help line. And the parameter's kind matters: in the probed shapes, an unused lifetime parameter and an unused const parameter on an alias drew no E0091 at all - this code is about type parameters, as its wording says.

The honest repairs are the two the diagnostic itself names, plus the marker form: remove the parameter, refer to it in the body of the alias, or - when the parameter must stay for the alias's meaning - mention it in the body through a phantom marker, which the boundary section shows compiling.

How to read the diagnostic

The E0091 header names the parameter directly: "type parameter T is never used", with the parameter's own spelling in backticks. One span underlines the parameter in the alias's parameter list and labels it "unused type parameter". Two help lines follow in the probed shapes: the first offers the two repairs - consider removing the parameter, or referring to it in the body of the type alias - and the second asks whether a const parameter was intended instead, suggesting the const form. The help is part of this diagnostic: unlike some codes in this series, E0091 tells you its own fixes.

The count follows the parameters, in the probed shapes. Two unused type parameters on one alias drew exactly two E0091 reports, one per parameter, ending with "aborting due to 2 previous errors". Fix the reported parameter first and recompile only to confirm the rest of the program, not to discover whether a second unused parameter is also reported - in the probed shape, it already was.

The first failure: the index examples

The index's first erroneous example, verbatim:

Rust
#![allow(unused)]
fn main() {
type Foo<T> = u32; // error: type parameter `T` is never used
}
Output
error[E0091]: type parameter `T` is never used
 --> fail_index.rs:3:10
  |
3 | type Foo<T> = u32; // error: type parameter `T` is never used
  |          ^ unused type parameter
  |
  = help: consider removing `T` or referring to it in the body of the type alias
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 1 previous error

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

Exactly one E0091, and no other error code. Nothing else in the program is wrong: the alias is never used. The parameter promises a variation the body never delivers, and the mismatch is in the definition alone.

The index's second erroneous example makes the per-parameter shape visible - the body uses the first parameter and ignores the second:

Rust
#![allow(unused)]
fn main() {
type Foo<A, B> = Box<A>; // error: type parameter `B` is never used
}
Output
error[E0091]: type parameter `B` is never used
 --> fail_second.rs:3:13
  |
3 | type Foo<A, B> = Box<A>; // error: type parameter `B` is never used
  |             ^ unused type parameter
  |
  = help: consider removing `B` or referring to it in the body of the type alias
  = help: if you intended `B` to be a const parameter, use `const B: /* Type */` instead

error: aborting due to 1 previous error

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

Exactly one E0091, naming B - the used parameter A is not reported. The check is per parameter, not per alias: each parameter is asked whether the body mentions it, and only the ones it does not mention are named.

The same error in other places and with other decorations

Placement does not matter, in the probed shapes. The same alias at the top level of a file drew exactly one E0091:

Output
error[E0091]: type parameter `T` is never used
 --> fail_toplevel.rs:1:10
  |
1 | type Foo<T> = u32;
  |          ^ unused type parameter
  |
  = help: consider removing `T` or referring to it in the body of the type alias
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 1 previous error

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

A bound is not a use. An alias whose parameter carried a Clone bound, and whose body still never mentioned the parameter, drew exactly one E0091 in the probed shape - and this shape's diagnostic carries only the first help line, without the const-parameter suggestion:

Output
error[E0091]: type parameter `T` is never used
 --> fail_bound_only.rs:1:10
  |
1 | type Foo<T: Clone> = u32;
  |          ^ unused type parameter
  |
  = help: consider removing `T` or referring to it in the body of the type alias

error: aborting due to 1 previous error

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

Using the alias does not cure it. A program that named the alias, with an argument for the unused parameter, in a function signature drew exactly one E0091 in the probed shape, on the definition - a use site cannot mention the parameter into the body:

Output
error[E0091]: type parameter `T` is never used
 --> fail_generic_use.rs:1:10
  |
1 | type Foo<T> = u32;
  |          ^ unused type parameter
  |
  = help: consider removing `T` or referring to it in the body of the type alias
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 1 previous error

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

And the count follows the parameters. One alias with two unused parameters drew exactly two E0091 reports in the probed shape, one naming each parameter at its own span, ending with "aborting due to 2 previous errors" - the full transcript is two reports of the fail_index shape, one per parameter at its own span, in the file fail_two_unused.rs.

The shape where a second code rides along

Other errors in the same program are reported alongside E0091. A program whose unused-parameter alias shared the file with an unresolved name in the entry point drew E0425 and E0091 together in the probed shape, ending with "aborting due to 2 previous errors":

Output
error[E0425]: cannot find value `missing_name` in this scope
 --> ride_unresolved.rs:2:28
  |
2 | fn main() { println!("{}", missing_name); }
  |                            ^^^^^^^^^^^^ not found in this scope

error[E0091]: type parameter `T` is never used
 --> ride_unresolved.rs:1:10
  |
1 | type Foo<T> = u32;
  |          ^ unused type parameter
  |
  = help: consider removing `T` or referring to it in the body of the type alias
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0091, E0425.
For more information about an error, try `rustc --explain E0091`.

Removing the parameter clears the E0091 in that shape and leaves the E0425 standing - the unresolved name is a separate problem that happens to share the output.

The shapes that are not this error

The same unused parameter on a struct is a neighboring code, not this one. That shape drew exactly one E0392 in the probed shape, with the same headline wording - "type parameter T is never used" - under the other code, and with a help line that also offers the phantom marker:

Output
error[E0392]: type parameter `T` is never used
 --> neighbour_struct.rs:1:12
  |
1 | struct Foo<T>;
  |            ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 1 previous error

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

An enum with an unused parameter drew the same neighboring code in the probed shape: exactly one E0392, on the parameter. The alias is what makes the code E0091 - the same defect on a data-carrying item is E0392, and the repair logic is shared even though the codes differ.

A function is different again. A function with a type parameter its signature and body never use compiled and ran in the probed shape, printing 3 - a function's unused parameter is not reported under either code, because a caller can still name the parameter explicitly at the call site, as that program does.

The boundary: parameters and bodies the rule accepts

The line is whether the body mentions the parameter, and on the other side of it the same shapes are ordinary code. The index's own corrected forms compile: an alias with no parameter at all, and an alias whose body is built from its parameter - both shown running in the repairs below. A body that mentions the parameter through a container works the same way: an alias for a vector of its parameter compiled and ran in the probed shape, printing 2, the length of the vector built through it.

The phantom marker counts as a mention. An alias whose body pairs a plain integer type with a phantom marker over the parameter compiled and ran in the probed shape, printing 3:

Rust
use std::marker::PhantomData;
type Foo<T> = (u32, PhantomData<T>);
fn main() { let x: Foo<i32> = (3, PhantomData); println!("{}", x.0); }
Output
3

That is the form for a parameter the alias must keep - one that carries meaning for the alias's uses even though the stored type does not mention it. The marker is zero-sized: the same alias over a string parameter, built and measured in the probed shape, printed 5 4 - the value stored, and a size of 4 for the whole aliased type, the integer alone.

The parameter's kind is the other boundary. In the probed shapes, an alias with an unused lifetime parameter drew no E0091 - it compiled, with only a warning that the alias itself was never used - and an alias with an unused const parameter drew no E0091 either, compiling with the same kind of warning. This code's wording is exact: it is type parameters that must be used in an alias body.

For an unused type parameter on a struct or an enum, the neighboring code is E0392. For an unresolved name used in the same program, the neighboring code is E0425.

The repairs

Every repair below starts from the same observation: the body never mentions the parameter. Either take the parameter off the alias, or put it into the body - directly, when the aliased type should vary with it, or through a phantom marker, when it should not.

Remove the parameter. Dropping the parameter from the index alias compiled and ran in the probed shape, printing 3 - every use of the alias then names the plain type, which is what the body said all along:

Rust
type Foo = u32;
fn main() { let x: Foo = 3; println!("{}", x); }
Output
3

Use the parameter in the body. The index's second example, repaired by keeping only the used parameter and the body that uses it, is the boundary shape above; the direct form of the same repair - changing the body so it is built from the parameter - compiled and ran in the probed shape, printing 7:

Rust
type Foo<T> = Box<T>;
fn main() { let x: Foo<i32> = Box::new(7); println!("{}", x); }
Output
7

Keep the parameter through a phantom marker. When the parameter must stay - because uses of the alias are meant to be distinguished by it - the marker form from the boundary section is the repair: that shape compiled and ran in the probed shapes, printing 3 for the integer-parameter use and 5 4 for the string-parameter use measured by size. Every use site keeps naming its argument; the body now mentions the parameter, which is all the rule asks.

Fixes in reach order

First, read the span. The underlined parameter is the one the body never mentions, and the header names it in backticks. That pair is the whole diagnosis - no other part of the program needs to change for a pure E0091.

Second, decide whether the alias is meant to vary with the parameter. If it is not, remove the parameter - and remove the corresponding argument at each use of the alias in the same change.

Third, if the alias is meant to vary, put the parameter in the body: build the aliased type from it, as in the box repair above. Do not reach for a bound as a substitute: in the probed shapes a bound on the parameter still drew E0091, because a bound is not a mention in the body, and a where clause mentioning the parameter drew it too in a checker probe.

Fourth, if the parameter must stay but the stored type must not change, mention it through a phantom marker in the body. The marker is zero-sized, so the aliased type's size and layout stay what they were in the probed shapes.

Fifth, if the output also carries a second code, fix that shape on its own terms after the E0091 is gone: an unresolved name elsewhere in the program stays an E0425, and the same unused parameter on a struct or an enum is an E0392 with the same repair logic under the other code.

Sixth, recompile and check the count. In the probed shapes, each unused parameter drew its own E0091, so an alias with two of them needs both parameters repaired, not just the first one reported.

Decision summary

E0091 fired on its own in the probed shapes for the first index example (exactly one E0091, naming the only parameter), for the second index example (exactly one E0091, naming the second parameter, whose body-mate was used), at the top level, for a parameter carrying only a trait bound, and for an alias used in a function signature (exactly one E0091 each). Two unused parameters on one alias drew exactly two. It rode along with E0425 for an unresolved name elsewhere in the program, in the probed shapes. It did not fire, in the probed shapes, for an alias whose body uses its parameter (compiled and ran, printing 7 for the box form and 2 for the vector form), for an alias whose body mentions its parameter through a phantom marker (compiled and ran, printing 3, and 5 4 for the measured string-parameter form), for an alias with no parameter (compiled and ran, printing 3), for an unused lifetime parameter or an unused const parameter on an alias (compiled, with only an unused-alias warning), or for a function with an unused type parameter (compiled and ran, printing 3). The neighboring shapes drew other output instead in the probed shapes: an unused parameter on a struct and on an enum each drew exactly one E0392. The repairs that compiled and ran in the probed shapes were removing the parameter (printing 3), using the parameter in the body (printing 7), and keeping the parameter through a phantom marker (printing 3, and 5 4 in the measured form).

Checklist

  • The body is the test, in the probed shapes: a type parameter on an alias must be mentioned by the alias's body, and nothing else - not a bound, not a use site - counts as a mention.
  • The count is per parameter, in the probed shapes: two unused parameters on one alias drew two E0091 reports, and a used parameter on the same alias was not reported.
  • The kind is exact, in the probed shapes: unused lifetime and const parameters on an alias drew no E0091.
  • The item is exact, in the probed shapes: the same unused parameter on a struct or an enum drew E0392, and on a function drew nothing.
  • The marker is a mention, in the probed shapes: a phantom marker over the parameter in the body compiled and ran, at zero size.
  • On the other side of the line there is no error, in the probed shapes: an alias whose body uses or marks its parameter, and an alias with no parameter, compiled and ran.

Sources

  • Rust error codes index, E0091 - an unnecessary type parameter was given in a type alias; the erroneous examples are a one-parameter alias whose body is a plain integer type and a two-parameter alias whose body uses only the first parameter; the advice is to check you did not write too many parameters, and the corrected examples remove the parameter and use the parameter in the body.
  • Rust error codes index, E0392 - a type parameter given in a data-carrying item, such as a struct or an enum, is never used; the neighboring code drawn in the probed shapes by an unused parameter on a struct and on an enum, whose help also offers the phantom marker.
  • Rust error codes index, E0425 - an unresolved name was used; the neighboring code drawn in the probed shape alongside E0091 by a program that also used an unresolved name.
  • The Rust Reference, Type aliases - a type alias is a name for another type, declared with the type keyword, and may carry generic parameters that the aliased type is built from.

Keep Exploring