Rust

E0614 Cannot Dereference Fix

The * operator follows a pointer to the value behind it - and a plain value has nothing behind it. E0614 is the compiler saying the operand was already the value: an integer, a count, a flag, a struct, a tuple. This guide separates the five shapes that produce it and matches each one to its repair: use the value as it stands, take the field that was meant, or give the wrapper type the Deref implementation that makes it pointer-like on purpose.

Written November 24, 2026 · Tested with Rust 1.99.1 · 19 min read

By the end of this guide
  • The rule underneath: only references, raw pointers, and Deref types can be dereferenced
  • How to read the diagnostic
  • The first failure: dereferencing a plain integer
  • The second failure: dereferencing a count returned by Vec::len

Written November 24, 2026

Tested with Rust 1.99.1

What this guide is

Error E0614 is a dereference applied to a value that cannot be dereferenced. The error codes index defines it in one sentence: an attempt was made to dereference a variable which cannot be dereferenced, and its example is a single *y where y is a u32. The header names the operand's type - "type i32 cannot be dereferenced", "type bool cannot be dereferenced" - and that type is the whole diagnosis: whatever stands after the * is already a value, not something that points at a value.

The forms in this guide each reproduce E0614 with a small, complete program, and each puts the stray * on a different kind of value. A plain i32 variable. A usize count returned by Vec::len. A bool used as an if condition. A plain struct that does not implement Deref. And a tuple, where a field was wanted and a dereference was written instead. The fixes fall into three shapes: drop the * and use the value as it stands, take the field that was meant, or - in the one family where a wrapper type is genuinely meant to behave like a pointer - implement Deref for it and show the implementation in full.

Several neighboring results are not E0614 and are worked only in the traps and the checklist. Dereferencing a & reference compiles, because a reference is the basic dereferenceable type. Dereferencing a Box compiles, and dereferencing a raw pointer compiles inside unsafe. Assigning through a &mut reference - *r = 5 - compiles, because a mutable dereference is a place that can be assigned to. Assigning through a shared & reference is not E0614: it is E0594. And moving a non-Copy value out of a dereference behind a shared reference is not E0614 either: it is E0507.

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

The rule underneath: only references, raw pointers, and Deref types can be dereferenced

The error index states the positive form of the rule: only types implementing std::ops::Deref can be dereferenced, such as &T. The Rust Reference's operator expressions page gives the full picture. The * dereference operator is a unary prefix operator; applied to a pointer or a Box, it denotes the pointed-to location, and dereferencing a raw pointer requires unsafe. On non-pointer types, *x is equivalent to *std::ops::Deref::deref(&x) in an immutable context and to the DerefMut form in a mutable context - which is why a type with no Deref implementation has no meaning for * to use, and why the compiler stops at the operator instead of guessing.

The Deref trait documentation describes what implementing the trait means: Deref is used for immutable dereferencing operations, like *v, and types that implement Deref or DerefMut are often called smart pointers. The same page carries the caution that belongs with the fourth family's fix: the compiler silently inserts calls to Deref::deref in many circumstances, so Deref should be implemented only when deref coercion is desirable - when the type transparently behaves like the value it points at. DerefMut is the mutable counterpart, used for mutable dereferencing operations such as *v = 1, and it requires Deref as a supertrait.

One more part of the Reference rule matters for the traps. When the expression is of type &mut T, *mut T, or Box<T> and is a mutable place expression, the location the dereference denotes can be assigned to. That is the line that separates two of the traps: *r = 5 through a &mut compiles, while the same assignment through a & fails - with E0594, not E0614, because the dereference itself was legal there and only the assignment was not.

How to read the diagnostic

Every failure in the five families prints the same shape of output. The first family's, in full:

Terminal
$ rustc --edition 2021 fail_int.rs -o fail_int
error[E0614]: type `i32` cannot be dereferenced
 --> fail_int.rs:3:13
  |
3 |     let y = *x;
  |             ^^ can't be dereferenced

error: aborting due to 1 previous error

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

Read it in order. The header names the type of the operand, not the variable: i32 here, usize, bool, Meter, and the tuple type in the families below. The caret span underlines the whole dereference expression - the * together with its operand - and its note is the header restated at the span: "can't be dereferenced". There are no secondary spans, because there is no second party to this error: no borrow is held, no other use is involved, and nothing elsewhere in the program needs to move. The repair is always local to the underlined expression, and it is chosen by asking what the * was for. If the value itself was meant, the * goes. If a field or an element was meant, the field access replaces it. If a reference was meant, the borrow has to be created first - with & or &mut - and then dereferenced, as the first trap shows. And if the type was meant to be pointer-like, it needs the Deref implementation the fourth family shows.

That locality is also the fastest way to tell this error from its neighbors. When the dereference itself is legal but something is done with its result that the rules forbid - assigning through a shared reference, moving a non-Copy value out from behind one - the header names that defect instead, E0594 or E0507, and the traps work each of those.

The first failure: dereferencing a plain integer

A program that dereferences an i32 variable:

Rust
fn main() {
    let x: i32 = 42;
    let y = *x;
    println!("{}", y);
}
Terminal
$ rustc --edition 2021 fail_int.rs -o fail_int
error[E0614]: type `i32` cannot be dereferenced
 --> fail_int.rs:3:13
  |
3 |     let y = *x;
  |             ^^ can't be dereferenced

error: aborting due to 1 previous error

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

The caret span covers *x, and the header names i32. An integer is a value, complete in itself: it does not point at another value, and it implements no Deref. The shape appears in code translated from a language where values arrive through pointers, and in code where a variable that once held a reference was changed to hold the value directly and one dereference survived the change.

The fix drops the *, because the value itself was meant:

Rust
fn main() {
    let x: i32 = 42;
    let y = x;
    println!("{}", y);
}
Terminal
$ rustc --edition 2021 fix_int.rs -o fix_int
$ ./fix_int
42

The output is 42. If a reference genuinely was meant here, the repair runs the other way: keep the *, and change what it applies to - let r = &x; followed by *r - which is the first trap below. Choosing between the two is a question about the rest of the program: a copy of the value, or a view of the original that later writes would show through.

The second failure: dereferencing a count returned by Vec::len

A program that dereferences the usize returned by len:

Rust
fn main() {
    let v = vec![10, 20, 30];
    let n = v.len();
    let m = *n;
    println!("{}", m);
}
Terminal
$ rustc --edition 2021 fail_len.rs -o fail_len
error[E0614]: type `usize` cannot be dereferenced
 --> fail_len.rs:4:13
  |
4 |     let m = *n;
  |             ^^ can't be dereferenced

error: aborting due to 1 previous error

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

len returns a usize by value. It does not return a reference to a count stored somewhere, so there is nothing for a dereference to follow - n already is the count. The shape appears when a method's return is assumed to be borrowed because other methods on the same type do return references: first and last on a vector hand back references to elements, while len hands back a number. The header's type name is the tell: it says usize, the value type, not a reference type.

The fix drops the *:

Rust
fn main() {
    let v = vec![10, 20, 30];
    let n = v.len();
    let m = n;
    println!("{}", m);
}
Terminal
$ rustc --edition 2021 fix_len.rs -o fix_len
$ ./fix_len
3

The output is 3, the number of elements. A usize is a Copy value, so copying it into m leaves n usable as well - no borrow was ever needed to read a count twice.

The third failure: dereferencing a bool condition

A program that dereferences a bool in an if condition:

Rust
fn main() {
    let flag = true;
    if *flag {
        println!("on");
    }
}
Terminal
$ rustc --edition 2021 fail_bool.rs -o fail_bool
error[E0614]: type `bool` cannot be dereferenced
 --> fail_bool.rs:3:8
  |
3 |     if *flag {
  |        ^^^^^ can't be dereferenced

error: aborting due to 1 previous error

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

The span here is wider - five carets under *flag - because the whole dereference expression is the condition. A condition needs a bool, and flag already is one. The shape appears when a flag is stored behind a reference in one part of a program - where *flag is correct - and the same expression is written where the flag is held directly. It also appears in translations from languages where a settings or options value is always reached through a pointer.

The fix drops the *:

Rust
fn main() {
    let flag = true;
    if flag {
        println!("on");
    }
}
Terminal
$ rustc --edition 2021 fix_bool.rs -o fix_bool
$ ./fix_bool
on

The output is on. Where the flag really does arrive as a &bool - as a function parameter, for example - *flag is the correct condition and no fix is needed; the error arises only when the operand's own type, the type named in the header, is the plain bool.

The fourth failure: dereferencing a plain struct

A program that dereferences a struct value that implements no Deref:

Rust
struct Meter {
    value: i32,
}

fn main() {
    let p = Meter { value: 7 };
    let v = *p;
    println!("{}", v);
}
Terminal
$ rustc --edition 2021 fail_struct.rs -o fail_struct
error[E0614]: type `Meter` cannot be dereferenced
 --> fail_struct.rs:7:13
  |
7 |     let v = *p;
  |             ^^ can't be dereferenced

error: aborting due to 1 previous error

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

The header names Meter itself. A struct value is not a pointer to its fields: p is the whole Meter, held directly, and with no Deref implementation there is no target type for *p to mean. This is the one family where two different intents hide behind the same error. If a field was meant, the fix is a field access - p.value - and no dereference belongs in the code at all. If the type is a wrapper that is meant to be used the way Box is used - created, passed around, and read through - then the type is missing the implementation that says so, and the fix is to write it.

The fix implements Deref for Meter, with i32 as its target:

Rust
use std::ops::Deref;

struct Meter {
    value: i32,
}

impl Deref for Meter {
    type Target = i32;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

fn main() {
    let p = Meter { value: 7 };
    let v = *p;
    println!("{}", v);
}
Terminal
$ rustc --edition 2021 fix_struct.rs -o fix_struct
$ ./fix_struct
7

The output is 7. The deref method returns a reference to the wrapped field, and *p now follows it to the i32. This is the only family in this guide whose fix adds an implementation, and it earns its place only under the condition the Deref documentation sets: the wrapper transparently behaves like the value it wraps, so the compiler inserting deref calls implicitly - in method calls and coercions, not just at an explicit * - will not surprise anyone using the type. A struct that merely holds a field it sometimes exposes does not meet that condition; for such a type p.value, or a named accessor method, is the fix, and adding Deref to silence this one error gives every other use of the type a hidden behavior it did not ask for.

The fifth failure: dereferencing a tuple

A program that dereferences a tuple to get at its first element:

Rust
fn main() {
    let pair = (3, 4);
    let first = *pair;
    println!("{}", first);
}
Terminal
$ rustc --edition 2021 fail_tuple.rs -o fail_tuple
error[E0614]: type `({integer}, {integer})` cannot be dereferenced
 --> fail_tuple.rs:3:17
  |
3 |     let first = *pair;
  |                 ^^^^^ can't be dereferenced

error: aborting due to 1 previous error

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

The header names the tuple type - shown here with its element types still being inferred as {integer} at the point of the error. A tuple is a value that holds its elements directly; it is not a pointer to its first element, and no Deref connects the two ideas. The shape appears when a pair returned from a function is treated the way an iterator's or a pointer's result would be - as something to be opened with * before use - when what the code actually wants is one numbered field of the pair.

The fix takes the field by its index:

Rust
fn main() {
    let pair = (3, 4);
    let first = pair.0;
    println!("{}", first);
}
Terminal
$ rustc --edition 2021 fix_tuple.rs -o fix_tuple
$ ./fix_tuple
3

The output is 3. Tuple fields are reached with .0, .1, and so on, or by destructuring - let (first, second) = pair; - when both elements are wanted. Neither route passes through a dereference, because the elements were never behind a pointer.

The fixes in reach order

  • Read the type named in the header. That type is the operand as the compiler sees it, and it decides the repair - not the variable's name, and not how similar code elsewhere is written.
  • A plain scalar - an integer, a count, a bool - was meant as the value itself: drop the *.
  • A field or an element was meant: replace the dereference with the field access, the tuple index, or the indexing that names it.
  • A reference was meant: create the borrow first with & or &mut, then dereference the borrow - the first trap's shape.
  • A wrapper type was meant to act as a pointer: implement Deref for it, in full, and only when the type transparently behaves like its target - the fourth family's fix, and the only fix in this guide that adds code to the type.
  • The dereference compiles but a use of its result fails: the error is a different one - read its header, E0594 or E0507 in the traps, and repair that defect instead.

Traps

  • Dereferencing a shared reference compiles - a reference is the basic case the operator exists for. Here &x is created first, and *r reads through it:
Rust
fn main() {
    let x = 42;
    let r = &x;
    println!("{}", *r);
}
Terminal
$ rustc --edition 2021 trap_ref.rs -o trap_ref
$ ./trap_ref
42
Trap
The output is 42. Nothing about the * changed between this program and the first failure - the operand's type did. r has type &i32, and a reference implements the dereference directly. When E0614 appears on code that looks like this, the operand's declared type is where to look: somewhere between the borrow and the dereference, the value itself replaced the reference. - Dereferencing a Box compiles - a Box is a pointer type with a Deref implementation of its own. Here the box is read through:
Rust
fn main() {
    let b = Box::new(7);
    println!("{}", *b);
}
Terminal
$ rustc --edition 2021 trap_box.rs -o trap_box
$ ./trap_box
7

The output is 7. Box<T> dereferences to T, which is why a boxed value can be used almost everywhere the value itself can. The contrast with the fourth family is the implementation: Box ships with one, written for exactly this purpose, while a plain struct has none until its author writes one deliberately. - Assigning through a mutable reference compiles - the dereference of a &mut is a place that can be written to. Here a value is replaced through the reference:

Rust
fn main() {
    let mut x = 1;
    let r = &mut x;
    *r = 5;
    println!("{}", r);
}
Terminal
$ rustc --edition 2021 trap_mut_assign.rs -o trap_mut_assign
$ ./trap_mut_assign
5

The output is 5, printed through the same reference after the assignment. The Reference rule is the one stated earlier: an expression of type &mut T that is a mutable place expression denotes a location that can be assigned to. Writing *r = 5 is the standard way to change a value the caller owns through a borrow - and it needs the &mut, as the next trap shows. - Dereferencing a raw pointer compiles inside unsafe - raw pointers are dereferenceable, and the unsafe block is the price of reading through one. Here a *const i32 is formed from a reference and read:

Rust
fn main() {
    let x = 9;
    let p = &x as *const i32;
    unsafe {
        println!("{}", *p);
    }
}
Terminal
$ rustc --edition 2021 trap_raw.rs -o trap_raw
$ ./trap_raw
9

The output is 9. Forming the raw pointer is safe; dereferencing it is not, because the compiler cannot check that a raw pointer is valid - that guarantee is the programmer's, which is what the unsafe block records. A raw pointer is never the fix for an E0614 on a plain value: converting a value that was never a pointer into one, in order to dereference it, adds an unchecked operation to repair a needless *. - Assigning through a shared reference fails - with E0594, not E0614. Here the assignment from the previous trap is attempted through a &:

Rust
fn main() {
    let x = 1;
    let r = &x;
    *r = 2;
    println!("{}", x);
}
Terminal
$ rustc --edition 2021 trap_shared_assign.rs -o trap_shared_assign
error[E0594]: cannot assign to `*r`, which is behind a `&` reference
 --> trap_shared_assign.rs:4:5
  |
4 |     *r = 2;
  |     ^^^^^^ `r` is a `&` reference, so it cannot be written to
  |
help: consider changing this to be a mutable reference
  |
3 |     let r = &mut x;
  |              +++

error: aborting due to 1 previous error

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

The dereference *r is legal - reading through it would compile, as the first trap shows. What fails is the assignment: a place behind a shared reference cannot be written to, because a shared reference promises its holder that the value will not change through it. The diagnostic even prints the repair as a help span: make the borrow a &mut one, which also requires the original variable to be declared mut. Reading the code in the header keeps the two errors apart - E0614 says the operand cannot be dereferenced at all; E0594 says it can, but cannot be assigned through. - Moving out of a dereference behind a shared reference fails - with E0507, not E0614. Here a String is moved out of *r, where r is a &String:

Rust
fn main() {
    let s = String::from("hi");
    let r = &s;
    let t = *r;
    println!("{}", t);
}
Terminal
$ rustc --edition 2021 trap_move_ref.rs -o trap_move_ref
error[E0507]: cannot move out of `*r` which is behind a shared reference
 --> trap_move_ref.rs:4:13
  |
4 |     let t = *r;
  |             ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
  |
help: consider removing the dereference here
  |
4 -     let t = *r;
4 +     let t = r;
  |
help: consider cloning the value if the performance cost is acceptable
  |
4 -     let t = *r;
4 +     let t = r.clone();
  |

error: aborting due to 1 previous error

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

Again the dereference itself is legal - *r names the String behind the reference. Moving it out would leave the owner's value taken away through a borrow that only promised to read it, so the compiler refuses, and the note under the span gives the reason: String does not implement Copy. For a Copy type the same shape compiles, because reading the value copies it and nothing is moved. The repairs are the two the help spans print: bind the reference itself and use it as a reference, or clone the value when an owned copy is genuinely needed. Neither repair touches the * as E0614's repairs do - the operator was never the defect.

Checklist

  • The type named in the E0614 header read as the operand's real type - a value type, not a reference, raw pointer, Box, or Deref type.
  • A scalar operand - integer, usize count, bool, char - used as the value itself, with the * dropped.
  • A struct operand checked for intent: a field access where a field was meant, a Deref implementation only where the type transparently behaves like its target.
  • A tuple operand read by index or destructuring, never by dereference.
  • A meant reference created with & or &mut before any dereference of it.
  • No raw pointer introduced to repair an E0614 - an unchecked dereference is not a fix for a needless *.
  • An assignment failure through a dereference read as E0594 and a move-out failure read as E0507, each repaired by its own rule, not by removing the *.
  • The fixed program run, and its output checked against what the program was meant to print.

Sources

  • Rust, Error codes index: E0614 — for the definition of the error as an attempt to dereference a variable which cannot be dereferenced, its u32 example, and the statement that only types implementing std::ops::Deref can be dereferenced, such as &T.
  • The Rust Reference, Operator expressions — for the dereference operator denoting the pointed-to location when applied to a pointer or a Box, for dereferencing a raw pointer requiring unsafe, for *x on non-pointer types being equivalent to a Deref or DerefMut call, and for a dereference of a &mut T, *mut T, or Box<T> place expression being assignable.
  • Rust, std::ops::Deref — for Deref being used for immutable dereferencing operations like *v, for types implementing Deref or DerefMut being called smart pointers, and for the advice to implement Deref only when deref coercion is desirable.
  • Rust, std::ops::DerefMut — for DerefMut being used for mutable dereferencing operations like *v = 1, for mutable deref coercion, and for DerefMut requiring Deref as a supertrait.

Keep Exploring