Email me

Rust errors / Const, static and compile-time

Rust compiler error · checked with rustc 1.99.0

Rust error E0080: attempt to shift left by `500_i32`, which would overflow

What it meansA constant value failed to get evaluated.

What rustc prints

error[E0080]: attempt to shift left by `500_i32`, which would overflow
 --> main.rs:2:9
  |
2 |     X = (1 << 500),
  |         ^^^^^^^^^^ evaluation of `Enum::X::{constant#0}` failed here

Real output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.

E0080Const, static and compile-time
Activein rustc 1.99.0
3related errors linked below

The compiler team's explanation

A constant value failed to get evaluated.

Erroneous code example:

enum Enum {
    X = (1 << 500),
    Y = (1 / 0),
}

This error indicates that the compiler was unable to sensibly evaluate a constant expression that had to be evaluated. Attempting to divide by 0 or causing an integer overflow are two ways to induce this error.

Ensure that the expressions given can be evaluated as the desired integer type.

See the [Discriminants] section of the Reference for more information about setting custom integer types on enums using the repr attribute.

From rustc --explain E0080 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.

Related errors

All 518 Rust error codes · Rust crate data · Glossary

Up next

Often hit nextE0015: cannot call non-const fn in constantsA related error from the same family.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ