Email me

Rust errors / Types and traits

Rust compiler error · checked with rustc 1.99.0

Rust error E0275: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<_>>>>>>>: Foo`

What it meansAn evaluation of a trait requirement overflowed.

What rustc prints

error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<_>>>>>>>: Foo`
 --> main.rs:5:33
  |
5 | impl<T> Foo for T where Bar<T>: Foo {}
  |                                 ^^^
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`main`)
note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<_>>>>>>>>>>>>>` to implement `Foo`
 --> main.rs:5:9
  |
5 | impl<T> Foo for T where Bar<T>: Foo {}
  |         ^^^     ^               --- unsatisfied trait bound introduced here
  = note: 126 redundant requirements hidden
  = note: required for `Bar<T>` to implement `Foo`
  = note: the full name for the type has been written to 'C:\Users\Matthew\AppData\Local\Temp\rerr-t1v_0c9_\out.long-type-5365014652263787654.txt'
  = note: consider using `--verbose` to print the full type name to the console

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.

E0275Types and traits
Activein rustc 1.99.0
7related errors linked below

The compiler team's explanation

An evaluation of a trait requirement overflowed.

Erroneous code example:

trait Foo {}

struct Bar<T>(T);

impl<T> Foo for T where Bar<T>: Foo {}

This error occurs when there was a recursive trait requirement that overflowed before it could be evaluated. This often means that there is an unbounded recursion in resolving some type bounds.

To determine if a T is Foo, we need to check if Bar<T> is Foo. However, to do this check, we need to determine that Bar<Bar<T>> is Foo. To determine this, we check if Bar<Bar<Bar<T>>> is Foo, and so on. This is clearly a recursive requirement that can't be resolved directly.

Consider changing your trait bounds so that they're less self-referential.

From rustc --explain E0275 (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 nextE0308: mismatched typesA 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