E0055 Auto-Deref Recursion Limit Fix

Written December 2, 2026 · Tested with Rust 1.99.1 · 19 min read

By the end of this guide
  • The rule underneath: the recursion limit caps automatic dereferencing
  • How to read the diagnostic
  • The first failure: the index example
  • The same error as a temporary, at a lower limit, and twice in one program

Written December 2, 2026

Tested with Rust 1.99.1

What this guide is

Error E0055 means the compiler stopped while automatically dereferencing a value during a method call, because the dereference chain needed more steps than the crate's recursion limit allows. The error codes index puts it plainly: during a method call, a value is automatically dereferenced as many times as needed to make the value's type match the method's receiver, and the compiler will only attempt to dereference a number of times up to the recursion limit, which can be set via the recursion_limit attribute.

In the shapes probed in this guide, E0055 fires on its own for a method call on a value behind five reference layers in a crate limited to 4, for the same call written on a temporary, for a call behind three layers at a limit of 2, and once per call when the call is written twice. It rides along with a second code in other shapes: a sixth reference layer and a call to a method that does not exist each drew E0599 alongside, a chain of five boxes drew E0320 alongside, a trait method reached through the chain drew E0275 alongside, and a binding with a mismatched type drew E0308 alongside. At a recursion limit of 8, five to eight reference layers compiled and ran in the probed shapes, and nine layers drew exactly one E0055. This guide shows the E0055 shapes, the shapes where a second code rides along, 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: the recursion limit caps automatic dereferencing

A method call on a reference does not need the receiver's exact type written out. The compiler walks the dereference chain - from a reference to a reference, down to the value - until the type matches the method's receiver. That walk is one of the compile-time operations the recursion_limit attribute caps: The Rust Reference describes the attribute as setting the maximum depth for potentially infinitely-recursive compile-time operations like macro expansion or auto-dereference, and gives the default in rustc as 128.

So E0055 is a depth problem, not a type problem. The method exists, the value has the right type at the bottom of the chain, and the call would be accepted at the default limit - the probed index shape compiled and ran with the attribute removed. The two honest repairs follow from that. If the deep chain is real and needed, raise the limit far enough for the walk to finish. If the chain is deeper than the code needs - the usual case when references to references accumulate by accident - remove layers, or dereference explicitly to a shallow reference before the call, so the automatic walk is short.

How to read the diagnostic

The E0055 header names the type at the bottom of the chain: "reached the recursion limit while auto-dereferencing Foo", in the probed shapes. The span underlines the method name in the call, and the note under it reads "deref recursion limit reached". Below that, a help line proposes a concrete raised limit: "consider increasing the recursion limit by adding a #![recursion_limit = "8"] attribute to your crate", doubling the current limit in the probed shapes - a limit of 4 produced a suggestion of 8, and a limit of 8 produced a suggestion of 16.

The count follows the calls, in the probed shapes: a program with one deep method call drew exactly one error[E0055], and a program with the same call written twice drew exactly two, one per call site. When a second error code appears in the same output, it is reported separately after the E0055 - read both before choosing a fix, because the second code often names the reason the compiler kept walking, as the neighboring shapes below show.

One probed shape gave E0055 with no span at all: when the deep reference was bound to a variable of a mismatched type, the E0055 block carried only the help line, and the span sat on the accompanying E0308 instead. An E0055 with no span is still this error - look for the coded error next to it to find the expression that triggered the walk.

The first failure: the index example

The index's erroneous example, verbatim:

Rust
#![recursion_limit="4"]

struct Foo;

impl Foo {
    fn foo(&self) {}
}

fn main() {
    let foo = Foo;
    let ref_foo = &&&&&Foo;

    // error, reached the recursion limit while auto-dereferencing `&&&&&Foo`
    ref_foo.foo();
}
Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
  --> fail_index.rs:14:13
   |
14 |     ref_foo.foo();
   |             ^^^ deref recursion limit reached
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "8"]` attribute to your crate (`fail_index`)

warning: unused variable: `foo`
  --> fail_index.rs:10:9
   |
10 |     let foo = Foo;
   |         ^^^
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
help: you might have meant to pattern match on the similarly named struct `Foo` (notice the capitalization)
   |
10 -     let foo = Foo;
10 +     let Foo = Foo;
   |
help: if this is intentional, prefix it with an underscore
   |
10 |     let _foo = Foo;
   |         +

error: aborting due to 1 previous error; 1 warning emitted

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

Exactly one E0055, and no other error code. The warning is about the unused foo binding in the example, not about the call: the same program with an allow attribute for unused variables drew exactly one E0055 with the same header, span, and help, and no warning, in the probed shape:

Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
  --> fail_allow_unused.rs:13:13
   |
13 |     ref_foo.foo();
   |             ^^^ deref recursion limit reached
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "8"]` attribute to your crate (`fail_allow_unused`)

error: aborting due to 1 previous error

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

The method, the value, and the call are all ordinary - the only thing wrong is that five dereference steps do not fit inside a recursion limit of 4.

The same error as a temporary, at a lower limit, and twice in one program

The binding does not matter. Writing the deep reference as a temporary in the call itself - (&&&&&Foo).foo() in a crate with a recursion limit of 4 - drew exactly one E0055 in the probed shape, with the span on the method name just as in the index example:

Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
 --> fail_temporary.rs:5:16
  |
5 |     (&&&&&Foo).foo();
  |                ^^^ deref recursion limit reached
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "8"]` attribute to your crate (`fail_temporary`)

error: aborting due to 1 previous error

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

The limit is the other half of the shape. At a recursion limit of 2, a call behind only three reference layers drew exactly one E0055 in the probed shape, and the help line doubled that limit in its suggestion, proposing 4:

Rust
#![recursion_limit="2"]
struct Foo;
impl Foo { fn foo(&self) {} }
fn main() {
    let ref_foo = &&&Foo;
    ref_foo.foo();
}
Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
 --> fail_limit2.rs:6:13
  |
6 |     ref_foo.foo();
  |             ^^^ deref recursion limit reached
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "4"]` attribute to your crate (`fail_limit2`)

error: aborting due to 1 previous error

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

And the error is per call site. A program that wrote the index call twice, on the same deep reference, drew exactly two E0055 errors in the probed shape, one at each call, ending with "aborting due to 2 previous errors" - fixing the depth fixes both, because both walks fail for the same reason.

The shapes where a second code rides along

One layer deeper, the output changes. A call behind six reference layers at a limit of 4 drew E0055 and E0599 together in the probed shape: the E0055 header named &Foo rather than Foo, and the E0599 after it reported "no method named foo found for reference &&&&&&Foo" - past a certain depth the compiler both hits the deref limit and fails to resolve the method, so it reports both. Check for the second code before assuming a raised limit is the whole fix.

A call to a method that does not exist, behind the index example's five layers, also drew two codes in the probed shape - E0055 first, then E0599, "no method named bar found for reference &&&&&Foo":

Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
 --> neighbour_wrong_method.rs:6:13
  |
6 |     ref_foo.bar();
  |             ^^^ deref recursion limit reached
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "8"]` attribute to your crate (`neighbour_wrong_method`)

error[E0599]: no method named `bar` found for reference `&&&&&Foo` in the current scope
 --> neighbour_wrong_method.rs:6:13
  |
6 |     ref_foo.bar();
  |             ^^^ method not found in `&&&&&Foo`

error: aborting due to 2 previous errors

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

Raising the limit would clear the E0055 in that shape and leave the E0599 standing - the method name is a separate problem that the deref walk was masking.

A chain of boxes is the same walk through a different type. Calling the method on a value behind five nested boxes at a limit of 4 drew E0055 and E0320 together in the probed shape - the E0320 reported "overflow while adding drop-check rules" for the nested box type. The deref chain is the shared cause; the second code names the other compile-time walk that the same nesting overflowed.

A trait method reached through the chain behaved the same way. A call to a trait method implemented for the five-layer reference type itself drew E0055 and E0275 together in the probed shape, the E0275 reporting an overflow while evaluating a requirement for the reference type. And the mismatched binding from the diagnostic section - binding the five-layer reference to a u8 variable - drew E0055 and E0308 together, the E0308 carrying the span and the expected and found types. In every probed ride-along shape, E0055 came first and the companion code named a second, distinct problem or a second overflowed walk.

There is also a shape at this limit that is not E0055 at all. A recursion limit of 4 is below what an ordinary binary needs elsewhere: in the probed shapes, programs at that limit whose method calls were shallow - two reference layers, a direct call on an owned value - passed the method-call check and then failed with an uncoded error, "queries overflow the depth limit!", pointing into the standard library's runtime start code, with the same help line proposing a limit of 8. The same shallow programs compiled cleanly as library crates at the same limit, and compiled and ran as binaries at a limit of 8. If the output has no E0055 in it, the limit is failing a different walk - raising it is still the fix, but this guide's error is not the one in the output.

The boundary at a recursion limit of 8

How deep is too deep depends on the limit, and the probed boundary at a limit of 8 was exact. Method calls behind five, six, seven, and eight reference layers each compiled and ran in the probed shapes, printing called from the method and then ran:

Rust
#![recursion_limit="8"]
struct Foo;
impl Foo { fn foo(&self) { println!("called"); } }
fn main() {
    let ref_foo = &&&&&&&&Foo;
    ref_foo.foo();
    println!("ran");
}
Output
called
ran

Nine reference layers at the same limit drew exactly one E0055, and nothing else:

Output
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
 --> boundary8_refs9.rs:6:13
  |
6 |     ref_foo.foo();
  |             ^^^ deref recursion limit reached
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "16"]` attribute to your crate (`boundary8_refs9`)

error: aborting due to 1 previous error

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

So the boundary is not a fixed number of layers: five layers overflow a limit of 4, eight layers fit inside a limit of 8, and nine overflow it. Count the layers in the failing call against the limit in the crate before deciding which side to change.

For a method that cannot be found on a type, the neighboring code is E0599. For a value whose type does not match the type a binding or expression requires, the neighboring code is E0308. For an overflow while the compiler evaluates a trait requirement, check E0275's shape before reaching for this guide's fix.

The repairs

Every repair below starts from the same observation: the dereference walk the call needs is longer than the recursion limit in force, so either the limit rises to fit the walk, or the walk gets shorter.

Raise the limit to the value the help line proposes. Changing the index shape's limit from 4 to 8 - the exact value its help line suggested - compiled and ran in the probed shape, printing called and then ran for the same five-layer call:

Rust
#![recursion_limit="8"]
struct Foo;
impl Foo { fn foo(&self) { println!("called"); } }
fn main() {
    let foo = Foo;
    let ref_foo = &&&&&Foo;
    ref_foo.foo();
    println!("ran");
}
Output
called
ran

Raise the limit well past the deepest chain when the depth is real. A call behind twelve reference layers compiled and ran in the probed shape at a recursion limit of 256, printing called and then ran - the limit is a ceiling on compile-time depth, and setting it generously costs nothing at runtime.

Remove the limit attribute when nothing else in the crate needs it. The index shape with the attribute deleted - so the default limit of 128 from the Reference applies - compiled and ran in the probed shape, printing called and then ran. A low recursion_limit is sometimes copied in from an example or set for an unrelated reason; if no other compile-time recursion in the crate needs capping, deleting it is the smallest repair.

Use fewer reference layers. References to references usually accumulate one layer at a time - a function takes a reference to a value that is already a reference, a helper forwards what it was given. Calling the method behind two layers instead of five compiled and ran at a limit of 8 in the probed binary shape, printing called and then ran, and the same two-layer call compiled at a limit of 4 in the probed library-crate shape. Each layer removed is a step the automatic walk no longer has to take.

Dereference explicitly to a shallow reference before the call. Explicit dereferences written in the code are not the automatic walk the limit caps: binding the five-layer reference down to a two-layer reference with three explicit dereferences, then calling the method on that binding, compiled and ran at a limit of 8 in the probed shape, printing called and then ran, and compiled at a limit of 4 in the probed library-crate shape:

Rust
#![recursion_limit="8"]
struct Foo;
impl Foo { fn foo(&self) { println!("called"); } }
fn main() {
    let ref_foo = &&&&&Foo;
    let shallow: &&Foo = ***ref_foo;
    shallow.foo();
    println!("ran");
}
Output
called
ran

Binding all the way down to a single reference works the same way: a binding of the five-layer reference to a &Foo through four explicit dereferences compiled and ran at a limit of 8 in the probed shape, and the method call on that binding printed called. And calling the method on the owned value directly, where the code has it, compiled at a limit of 4 in the probed library-crate shape - no chain, no walk, no limit to hit.

Fixes in reach order

First, read the limit in force and count the layers in the failing call. In the probed shapes, E0055 is the walk outrunning the limit: five layers overflowed a limit of 4, eight layers fit a limit of 8, and nine overflowed it. The header names the type at the bottom of the chain, and the help line proposes a doubled limit.

Second, check whether a second code rides along. In the probed shapes, E0599 meant the method itself was missing or unresolvable at that depth, E0308 meant the expression's type was wrong, and E0320 and E0275 meant a second compile-time walk overflowed on the same nesting. A raised limit clears the E0055; it does not clear a missing method or a mismatched type.

Third, if the deep chain is intended, raise the limit - to the help line's proposed value for a small fix, or well past the deepest chain when the depth is structural, in the probed shapes. If the low limit serves nothing else in the crate, remove the attribute and take the default.

Fourth, if the chain is deeper than the code needs, shorten the walk instead: pass fewer layers, bind the value down with explicit dereferences, or call the method on the owned value, in the probed shapes.

Last, if the output contains no E0055 at all, look at which walk actually failed. In the probed shapes, a limit of 4 also produced an uncoded query-depth overflow on shallow programs built as binaries - the same raised limit fixes it, but it is a different failure from this one.

Decision summary

E0055 fired on its own in the probed shapes for a method call behind five reference layers at a recursion limit of 4 (the index example, exactly one E0055, plus a warning about an unused binding that an allow attribute removed without changing the error), for the same call written on a temporary (exactly one E0055), for a call behind three layers at a limit of 2 (exactly one E0055), twice in one program that wrote the call twice (exactly two E0055 errors, one per call), and for a call behind nine layers at a limit of 8 (exactly one E0055). It rode along with a second code for a call behind six layers at a limit of 4 (E0599 alongside), for a call to a missing method behind five layers (E0599 alongside), for a call behind five nested boxes (E0320 alongside), for a trait method reached through five layers (E0275 alongside), and for a binding of the five-layer reference to a mismatched type (E0308 alongside, with the E0055 carrying no span). It did not fire for calls behind five to eight layers at a limit of 8, which compiled and ran, for shallow calls compiled as library crates at a limit of 4, which compiled, or for the index shape with the limit raised or removed. Programs built as binaries at a limit of 4 whose calls were shallow drew an uncoded query-depth overflow instead, not E0055. The repairs that compiled and ran were raising the limit to 8 for the five-layer call (printing called and ran), raising it to 256 for a twelve-layer call (printing called and ran), removing the attribute so the default applied (printing called and ran), using two reference layers in place of five, and dereferencing explicitly to a shallow reference or a single reference before the call (printing called and ran in the probed binary shapes at a limit of 8, and compiling in the probed library-crate shapes at a limit of 4).

Checklist

  • E0055 is a depth problem, in the probed shapes: the method and the type are right, and the automatic dereference walk outran the recursion limit before it reached them.
  • The limit and the layers decide together, in the probed shapes: five layers overflowed a limit of 4, eight layers fit a limit of 8, and nine overflowed it - count both sides before changing either.
  • The help line proposes a doubled limit, in the probed shapes: 4 produced a suggestion of 8, 2 produced 4, and 8 produced 16.
  • The error count follows the call sites, in the probed shapes: one deep call drew one E0055, and the same call written twice drew two.
  • A second code in the output is a second fact, in the probed shapes: E0599, E0308, E0320, and E0275 each rode along in a different shape, and each needs its own reading before the limit is raised.
  • Explicit dereferences are not the automatic walk, in the probed shapes: binding a deep reference down to a shallow one before the call cleared the error without raising the limit.
  • A very low limit can fail other walks first, in the probed shapes: shallow binary programs at a limit of 4 drew an uncoded query-depth overflow and no E0055, while the same programs compiled as library crates.

Sources

  • Rust error codes index, E0055 - during a method call a value is automatically dereferenced as many times as needed to match the method's receiver, the compiler only attempts dereferencing up to the recursion limit set via the recursion_limit attribute, one fix may be to increase the recursion limit, and it is possible to create an infinite recursion of dereferencing, in which case the only fix is to break the recursion; the erroneous example sets a recursion limit of 4 and calls a method on a value behind five reference layers.
  • The Rust Reference, Limits - the recursion_limit attribute may be applied at the crate level to set the maximum depth for potentially infinitely-recursive compile-time operations like macro expansion or auto-dereference, and the default in rustc is 128.
  • Rust error codes index, E0599 - no method of the given name was found on the type; the neighboring code drawn in the probed shapes by a call behind six reference layers and by a call to a missing method behind five layers.
  • Rust error codes index, E0308 - a type did not match the expected type; the neighboring code drawn in the probed shape by binding a five-layer reference to a variable of a mismatched type.
  • Rust error codes index, E0320 - an overflow while the compiler was adding drop-check rules; the neighboring code drawn in the probed shape by a method call behind five nested boxes.
  • Rust error codes index, E0275 - an overflow while evaluating a trait requirement; the neighboring code drawn in the probed shape by a trait method reached through five reference layers.

Keep Exploring