E0084 Unsupported Representation Fix

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

By the end of this guide
  • The rule underneath: no values, no representation
  • How to read the diagnostic
  • The first failure: the index example
  • The same error with other representations and in other places

Written December 3, 2026

Tested with Rust 1.99.1

What this guide is

Error E0084 means a representation was attempted on a zero-variant enum - an enum with no variants. The error codes index puts it plainly: an unsupported representation was attempted on a zero-variant enum, because it is impossible to define an integer type to represent zero-variant enum values when there are no such values.

In the shapes probed in this guide, E0084 fires on its own for the index example, for other integer representations, for the C representation, for an explicit Rust representation, and for an alignment-only representation, at the top level, inside a function, through a type alias for the represented enum, and for an enum generated by a macro. A second code rides along in the probed shapes where the representation is combined or invalid in its own right, where the enum carries an unused generic parameter, and where the same program also uses an unresolved name. Neighboring shapes draw a different code instead: two integer representations on an enum that has variants drew E0566, and an integer representation on a struct drew an unnumbered error. At the boundary, a zero-variant enum with no representation at all, and a represented enum with at least one variant, compile and run. This guide shows the E0084 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: no values, no representation

A representation tells the compiler how the values of a type are laid out - for an enum, how its discriminant is stored. The Rust Reference lists the primitive representations, named after the integer types, and states that it is an error for zero-variant enums to have a primitive representation; it also states that the C representation is an error for zero-variant enums. A zero-variant enum has no values and can never be constructed in safe code, so there is no discriminant to store and nothing for a representation to describe.

That is why the check in the probed shapes is broader than the index example suggests. The integer in the index example is one way in, not the only way in: in the probed shapes, a C representation, an explicit Rust representation, and an alignment representation each drew E0084 on a zero-variant enum as well. The question at every represented enum is whether the enum has at least one variant. If it does, a representation has something to describe. If it does not, the honest repairs are the two the index names: give the enum variants, or remove the representation.

How to read the diagnostic

The E0084 header names the shape directly: "unsupported representation for zero-variant enum", in the probed shapes. One span underlines the representation argument in the attribute - the integer name, the C, the Rust, or the alignment argument in the probed shapes - and a second span underlines the enum itself with "zero-variant enum". No help block appeared in any probed pure E0084 shape: the compiler names the problem, and the choice between the two repairs - add variants, or drop the representation - is left to you.

The count follows the enums, in the probed shapes. Two zero-variant enums with representations in one program drew exactly two E0084 reports, one per enum. Fix the reported enum first and recompile only to confirm the rest of the program, not to discover whether a second represented empty enum is also reported - in the probed shape, it already was.

The first failure: the index example

The index's erroneous example, verbatim:

Rust
#![allow(unused)]
fn main() {
#[repr(i32)]
enum NightsWatch {} // error: unsupported representation for zero-variant enum
}
Output
error[E0084]: unsupported representation for zero-variant enum
 --> fail_index.rs:3:8
  |
3 | #[repr(i32)]
  |        ^^^
4 | enum NightsWatch {} // error: unsupported representation for zero-variant enum
  | ---------------- zero-variant enum

error: aborting due to 1 previous error

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

Exactly one E0084, and no other error code. Nothing else in the program is wrong: the enum is never used. The attribute promises a layout for values that can never exist, and the mismatch is in the definition alone, reported whether or not the type is ever named again.

The same error with other representations and in other places

The representation does not have to be i32. A zero-variant enum carrying an unsigned byte representation drew exactly one E0084 in the probed shape:

Output
error[E0084]: unsupported representation for zero-variant enum
 --> fail_u8.rs:1:8
  |
1 | #[repr(u8)]
  |        ^^
2 | enum Empty {}
  | ---------- zero-variant enum

error: aborting due to 1 previous error

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

The same shape with a pointer-sized signed representation drew exactly one E0084 in the probed shape. Neither does the representation have to be an integer at all. A zero-variant enum carrying the C representation drew exactly one E0084 in the probed shape:

Output
error[E0084]: unsupported representation for zero-variant enum
 --> fail_c.rs:1:8
  |
1 | #[repr(C)]
  |        ^
2 | enum Empty {}
  | ---------- zero-variant enum

error: aborting due to 1 previous error

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

Writing the default representation out in full changes nothing. A zero-variant enum carrying an explicit Rust representation drew exactly one E0084 in the probed shape - on the unit side of this rule there is no representation, not a default one spelled out:

Output
error[E0084]: unsupported representation for zero-variant enum
 --> boundary_repr_rust.rs:1:8
  |
1 | #[repr(Rust)]
  |        ^^^^
2 | enum Empty {}
  | ---------- zero-variant enum

error: aborting due to 1 previous error

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

An alignment representation is also a representation. A zero-variant enum carrying only an alignment argument drew exactly one E0084 in the probed shape:

Output
error[E0084]: unsupported representation for zero-variant enum
 --> fail_align.rs:1:8
  |
1 | #[repr(align(8))]
  |        ^^^^^^^^
2 | enum Empty {}
  | ---------- zero-variant enum

error: aborting due to 1 previous error

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

Placement does not matter, in the probed shapes. The index shape moved to the top level of a file drew exactly one E0084, and the same shape defined inside a helper function drew exactly one E0084. Naming the type differently changes nothing: a program whose represented zero-variant enum was also named through a type alias drew exactly one E0084 in the probed shape, on the original definition - an alias adds a name, not a variant. Generating the definition changes nothing either: a zero-variant represented enum produced by a macro drew exactly one E0084 in the probed shape, with the span on the macro call.

The shapes where a second code rides along

Some representations are wrong in two ways at once on a zero-variant enum, and both codes are reported. Combining the C representation with an integer representation on a zero-variant enum drew E0566 and E0084 together in the probed shape, ending with "aborting due to 2 previous errors":

Output
error[E0566]: conflicting representation hints
 --> fail_c_i32.rs:1:8
  |
1 | #[repr(C, i32)]
  |        ^  ^^^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #68585 <https://github.com/rust-lang/rust/issues/68585>
  = note: `#[deny(conflicting_repr_hints)]` (part of `#[deny(future_incompatible)]`) on by default

error[E0084]: unsupported representation for zero-variant enum
 --> fail_c_i32.rs:1:8
  |
1 | #[repr(C, i32)]
  |        ^
2 | enum Empty {}
  | ---------- zero-variant enum

error: aborting due to 2 previous errors

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

The E0566 half is not caused by the emptiness: the same combined representation on an enum with variants drew exactly one E0566 and no E0084 in the probed shape. On current compilers that combination is refused on its own, empty or not - keep that in mind before reaching for it as the repair for an empty enum.

A transparent representation on a zero-variant enum drew E0084 and E0731 together in the probed shape: transparent enums need exactly one variant, and this enum has none, so both rules fire. An unknown representation name on a zero-variant enum drew E0539 and E0084 together in the probed shape - the malformed attribute is reported, and so is the representation on an empty enum. An unused generic parameter rides along the same way: a generic zero-variant enum with an integer representation drew E0084 and E0392 together in the probed shape, while a generic enum with a variant using no parameter compiled in the probed shape - the generic ride-along is about the unused parameter, not about generics themselves.

Other errors in the same program are reported alongside E0084. A program whose represented zero-variant enum shared the file with an unresolved name in the entry point drew E0425 and E0084 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_unknown_name.rs:3:28
  |
3 | fn main() { println!("{}", missing_name); }
  |                            ^^^^^^^^^^^^ not found in this scope

error[E0084]: unsupported representation for zero-variant enum
 --> ride_unknown_name.rs:1:8
  |
1 | #[repr(i32)]
  |        ^^^
2 | enum NightsWatch {}
  | ---------------- zero-variant enum

error: aborting due to 2 previous errors

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

Removing the representation clears the E0084 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

Two integer representations on an enum that has variants is a conflict, not this error. That shape drew exactly one E0566 in the probed shape, "conflicting representation hints", with no E0084 - the enum has variants, so a representation has something to describe, and the only problem is that two integer representations disagree.

An integer representation on a struct is not this error either. That shape drew an unnumbered error in the probed shape - the integer representation attribute cannot be used on structs, and can only be applied to enums - with no E0084 at all. E0084 needs an enum, and it needs that enum to have no variants.

A packed representation on a zero-variant enum split across both kinds of output in the probed shape: an unnumbered error saying the packed attribute cannot be used on enums, plus exactly one E0084. If your output contains E0084, the empty-enum half of the problem is real even when another half is reported without a code.

The boundary: enums the representation can describe

The line is the variant count, and on the other side of it the same attributes are ordinary code. A zero-variant enum with no representation at all compiled and ran in the probed shape, printing ok - an uninhabited type is legal; it is the representation that is not. A represented enum with a single variant compiled and ran in the probed shape, printing 0, and the C representation on an enum with two variants compiled and ran in the probed shape, printing 1. One variant is enough: the representation finally has a discriminant to describe.

For conflicting representation hints on an enum that has variants, the neighboring code is E0566. For a transparent enum with zero or several variants, the neighboring code is E0731. 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 enum has no variants and the attribute has nothing to describe. Either give the enum a value the representation can describe, or - only when the enum is meant to stay empty - remove the representation.

Add variants and keep the representation. Adding the two variants the index proposes to the index enum compiled and ran in the probed shape, printing 0 1 - the discriminants the integer representation now stores:

Rust
#[repr(i32)]
enum NightsWatch { JonSnow, Commander }
fn main() { println!("{} {}", NightsWatch::JonSnow as i32, NightsWatch::Commander as i32); }
Output
0 1

One variant is enough. The unsigned-byte shape from the failing shapes, with a single variant added, compiled and ran in the probed shape, printing 0. The C shape works the same way: the C-represented empty enum with two variants added compiled and ran in the probed shape, printing 1.

Remove the representation and keep the enum empty. If the enum is meant to be uninhabited - a marker that can never be constructed - dropping the attribute is the whole repair: that shape compiled and ran in the probed shape, printing 0, the size of the still-empty enum:

Rust
enum NightsWatch {}
fn main() { println!("{}", std::mem::size_of::<NightsWatch>()); }
Output
0

The same removal applied to the C and alignment shapes compiled and ran in the probed shapes, printing done in both. Every use that expected a stored discriminant has to be rethought in the same change, because an unrepresented empty enum has no values to store one for.

Fixes in reach order

First, read the two spans. The attribute span names the representation that was attempted, and the enum span confirms the enum has no variants. That pair is the whole diagnosis - no other part of the program needs to change for a pure E0084.

Second, decide whether the enum is meant to have values. If it is, add at least one variant and keep the representation; the discriminants then start at zero in declaration order in the probed shapes, unless you assign them explicitly.

Third, if the enum is meant to stay empty, remove the whole representation attribute. Do not swap one representation for another hoping a different one is allowed on an empty enum: in the probed shapes, integer, C, explicit Rust, and alignment representations all drew E0084.

Fourth, if the output also carries a second code, fix that shape on its own terms after the E0084 is gone: a combined C and integer representation drew E0566 even with variants present in the probed shape, a transparent representation on an empty enum also drew E0731, and an unresolved name elsewhere in the program stays an E0425.

Fifth, recompile and check the count. In the probed shapes, each represented zero-variant enum drew its own E0084, so a program with two of them needs both definitions repaired, not just the first one reported.

Decision summary

E0084 fired on its own in the probed shapes for the index example (exactly one E0084), for zero-variant enums carrying an unsigned byte representation and a pointer-sized signed representation (exactly one E0084 each), for the C representation, for an explicit Rust representation, and for an alignment-only representation (exactly one E0084 each), at the top level, inside a function, through a type alias naming the represented enum, and for an enum generated by a macro (exactly one E0084 each). Two represented zero-variant enums in one program drew exactly two. It rode along with E0566 for a combined C and integer representation, with E0731 for a transparent representation, with E0539 for an unknown representation name, with E0392 for an unused generic parameter, and with E0425 for an unresolved name elsewhere in the program, in the probed shapes. It did not fire, in the probed shapes, for a zero-variant enum with no representation (compiled and ran, printing ok), for a represented enum with one variant (compiled and ran, printing 0), or for a C-represented enum with two variants (compiled and ran, printing 1). The neighboring shapes drew other output instead in the probed shapes: two integer representations on an enum with variants drew E0566 alone, an integer representation on a struct drew an unnumbered error alone, and a packed representation on a zero-variant enum drew an unnumbered error plus E0084. The repairs that compiled and ran in the probed shapes were adding two variants while keeping the integer representation (printing 0 1), adding one variant to the unsigned-byte shape (printing 0), adding variants to the C shape (printing 1), and removing the representation while keeping the enum empty (printing 0, and done for the C and alignment shapes).

Checklist

  • No values, no representation, in the probed shapes: a representation describes the discriminant of an enum's values, and a zero-variant enum has none.
  • The integer is only one way in, in the probed shapes: integer, C, explicit Rust, and alignment representations on a zero-variant enum all drew E0084.
  • Placement and naming do not soften the rule, in the probed shapes: top level, inside a function, through a type alias, and generated by a macro all drew the same code on the definition.
  • The count is per enum, in the probed shapes: two represented zero-variant enums in one program drew two E0084 reports.
  • Combined representations can bring their own code, in the probed shapes: a C plus integer representation drew E0566 with variants present too, so that combination is not a repair.
  • On the other side of the line there is no error, in the probed shapes: an unrepresented zero-variant enum, and a represented enum with at least one variant, compiled and ran.

Sources

  • Rust error codes index, E0084 - an unsupported representation was attempted on a zero-variant enum; it is impossible to define an integer type to represent zero-variant enum values because there are no such values and no way to construct an instance in safe code; the two solutions are adding variants or removing the integer representation; the erroneous example is a zero-variant enum carrying an integer representation.
  • The Rust Reference, Type layout - the primitive representations are named after the integer types, it is an error for zero-variant enums to have a primitive representation, and the C representation is an exception for zero-variant enums for which it is an error.
  • Rust error codes index, E0566 - conflicting representation hints have been used on the same item; the neighboring code drawn in the probed shapes by a combined C and integer representation, with and without variants.
  • Rust error codes index, E0731 - an enum with the transparent representation had zero or more than one variant; the neighboring code drawn in the probed shape alongside E0084 by a transparent representation on a zero-variant enum.
  • Rust error codes index, E0425 - an unresolved name was used; the neighboring code drawn in the probed shape alongside E0084 by a program that also used an unresolved name.

Keep Exploring