Rust

E0067 Invalid Left-Hand Side Fix

The left side of an assignment has to name a place in memory, and a literal, a sum, a call result, and a const item name none. This guide works the invalid-left-hand-side error in its compound and plain shapes, explains the place-expression rule underneath it, and gives the repairs in the order they usually fit.

Written November 30, 2026 · Tested with Rust 1.99.1 · 11 min read

By the end of this guide
  • The rule underneath: places hold, values arrive
  • How to read the diagnostic
  • The first failure: a compound assignment to a literal
  • The same error: a call result, a const item, a computed result

Written November 30, 2026

Tested with Rust 1.99.1

What this guide is

Error E0067 is an assignment aimed at something that is not a place. The error codes index states it in one line - "An invalid left-hand side expression was used on an assignment operation" - and its erroneous example is a single statement, 12 += 1;. Its explanation is the whole rule in one sentence: "You need to have a place expression to be able to assign it something." Its corrected example binds the number first - let mut x: i8 = 12; - and then applies x += 1; to the variable.

One wrinkle decides which code a search should use. On this compiler the message "invalid left-hand side of assignment" comes in two codes that split by operator: a compound assignment (+= and its siblings) to a non-place reports E0067, while a plain = to the same kind of target reports the sibling code E0070, whose index entry reads "An assignment operator was used on a non-place expression." The wording, the underline, and the repair are the same; only the code and the operator differ. This guide covers both, because a program can draw either one from the same underlying mistake.

The practical payoff is the place rule itself. Once it is clear which expressions name a place - a mutable variable, a dereference, a field, an index - and which produce a value and stop there - a literal, an arithmetic result, a call result, a const item - the error stops looking arbitrary, and the repair is usually a one-line bind or a change of target.

The rule underneath: places hold, values arrive

Assignment writes into storage. The left-hand side therefore has to be a place expression: an expression that identifies a location the program owns. The places that appear in ordinary code are:

  • A variable declared with mut.
  • A dereference, *r, where r is a mutable reference.
  • A field of a place, such as a tuple field or a struct field, when the owning binding is mutable.
  • An index into a place, such as v[0], when the container binding is mutable.
  • A place in parentheses: (x) = 5; assigns to x, because parentheses around a place still name the same place.

Value expressions produce a result and own no storage the program can write back into. A numeric or string literal is a value. The result of x + y is a value computed on the spot. The value a function returns is a value. A const item is a value substituted wherever its name appears - it names no storage at all, which is why assigning to a const is this error and not a mutability error.

That last point separates this guide's errors from their nearest neighbors. Assigning twice to an immutable let variable is E0384, because the target is a place but the binding forbids the second write. Assigning to an immutable static item is E0594, because the target names storage that may not be written. Assigning to a const item is E0067 or E0070, because there is no storage and no binding to make mutable - mut cannot be added to a const, so the repair is a different shape of code, not a keyword.

How to read the diagnostic

The diagnostic is short - three lines and no labeled spans beyond the target itself:

  • The error line names the code, and the code tells you the operator: E0067 for a compound assignment, E0070 for a plain one.
  • The source line underlines the whole left-hand expression with dashes and the operator with carets - one caret for =, two for += - so the underline shows exactly which expression the compiler judged not to be a place.
  • The label under the dashes reads "cannot assign to this expression". There is no second span pointing elsewhere, because the defect is entirely inside the target expression.

The first failure: a compound assignment to a literal

The index's own shape, in a complete program:

Rust
fn main() {
    1 += 2;
}
Output
error[E0067]: invalid left-hand side of assignment
 --> i_compound_lit.rs:2:7
  |
2 |     1 += 2;
  |     - ^^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

The literal 1 is a value. A compound assignment reads the target, adds, and writes back - and there is nowhere to write back to. Nothing else in the program is wrong; the statement is the whole defect.

The same error: a call result, a const item, a computed result

The target's shape changes, the error does not. A function call returns a value, and applying += to the call applies it to that value:

Rust
fn get() -> i32 { 1 }
fn main() {
    get() += 1;
}
Output
error[E0067]: invalid left-hand side of assignment
 --> m_call_compound.rs:3:11
  |
3 |     get() += 1;
  |     ----- ^^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

A const item fails the same way, because a const name stands for its value, not for a location:

Rust
const MAX: i32 = 10;
fn main() {
    MAX += 1;
    println!("{}", MAX);
}
Output
error[E0067]: invalid left-hand side of assignment
 --> n_const_compound.rs:3:9
  |
3 |     MAX += 1;
  |     --- ^^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

And a computed result in parentheses is still a value - parentheses preserve a place, they do not create one:

Rust
fn main() {
    let x = 1;
    let y = 2;
    (x + y) += 3;
    println!("{}", x);
}
Output
error[E0067]: invalid left-hand side of assignment
 --> o_expr_compound.rs:4:13
  |
4 |     (x + y) += 3;
  |     ------- ^^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

The plain-assignment sibling: E0070

Replace the compound operator with = and the same targets report E0070 instead. A literal first:

Rust
fn main() {
    1 = 2;
}
Output
error[E0070]: invalid left-hand side of assignment
 --> a_literal.rs:2:7
  |
2 |     1 = 2;
  |     - ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

An arithmetic result:

Rust
fn main() {
    let x = 1;
    let y = 2;
    x + y = 3;
    println!("{}", x);
}
Output
error[E0070]: invalid left-hand side of assignment
 --> b_expr.rs:4:11
  |
4 |     x + y = 3;
  |     ----- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

A call result:

Rust
fn get() -> i32 { 1 }
fn main() {
    get() = 3;
}
Output
error[E0070]: invalid left-hand side of assignment
 --> c_call.rs:3:11
  |
3 |     get() = 3;
  |     ----- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

And a const item - the case the E0070 index entry itself uses for one of its examples:

Rust
const MAX: i32 = 10;
fn main() {
    MAX = 20;
    println!("{}", MAX);
}
Output
error[E0070]: invalid left-hand side of assignment
 --> d_const.rs:3:9
  |
3 |     MAX = 20;
  |     --- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

A string literal behaves like a numeric one: "hi" = "bye"; is E0070 with the literal underlined. The split to remember is only about the operator - compound reports E0067, plain reports E0070 - and a search for either code with the shared message text finds this same family.

The neighbors that are not this error

Two similar errors have different codes because their targets are places with a mutability problem instead of values with no place at all. An immutable variable assigned twice:

Rust
fn main() {
    let x = 1;
    x = 2;
    println!("{}", x);
}
Output
error[E0384]: cannot assign twice to immutable variable `x`
 --> e_immut.rs:3:5
  |
2 |     let x = 1;
  |         - first assignment to `x`
3 |     x = 2;
  |     ^^^^^ cannot assign twice to immutable variable
  |
help: consider making this binding mutable
  |
2 |     let mut x = 1;
  |         +++

warning: value assigned to `x` is never read
 --> e_immut.rs:2:13
  |
2 |     let x = 1;
  |             ^ this value is reassigned later and never used
3 |     x = 2;
  |     ----- `x` is overwritten here before the previous value is read
  |
  = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

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

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

The repair there is the one the compiler prints: add mut. An immutable static item is one step further along the same line - assigning to it is E0594, "cannot assign to immutable static item", and its repair is a static mut with the unsafe access that requires, or a different design. Neither repair touches E0067 or E0070, where there is no binding whose mutability could change.

Fixes in reach order

1. Bind the value to a mutable variable, then assign

This is the index's own corrected example, and it covers the literal and call-result cases. The number gets a place first:

Rust
fn main() {
    let mut x: i8 = 12;
    x += 1;
    println!("{}", x);
}
Output
13

A call result binds the same way:

Rust
fn get() -> i32 { 1 }
fn main() {
    let mut v = get();
    v += 1;
    println!("{}", v);
}
Output
2

2. If the goal was a result, store the result

Often the assignment was a misdirected computation - the code wanted a new value, not a write into the expression. Bind the computed result under its own name:

Rust
fn main() {
    let x = 1;
    let y = 2;
    let sum = x + y;
    println!("{}", sum);
}
Output
3

No mut is needed, because nothing is assigned after the binding.

3. Write through a place the program owns

When the value lives behind a reference, in a field, or in a container, the place forms of those targets accept both plain and compound assignment. Through a mutable reference, chosen between two variables:

Rust
fn main() {
    let mut x = 1;
    let mut y = 2;
    let r = if true { &mut x } else { &mut y };
    *r += 10;
    println!("{} {}", x, y);
}
Output
11 2

Into a tuple field:

Rust
fn main() {
    let mut t = (1, 2);
    t.0 = 10;
    println!("{:?}", t);
}
Output
(10, 2)

Into a vector index:

Rust
fn main() {
    let mut v = vec![1, 2, 3];
    v[0] = 10;
    println!("{:?}", v);
}
Config
[10, 2, 3]

And a place in parentheses remains the same place:

Rust
fn main() {
    let mut x = 1;
    (x) = 5;
    println!("{}", x);
}
Output
5

4. For a const item, change what the name is

A const cannot be made mutable, because it is not storage. If the value has to change at run time, it has to live in a variable - a let mut inside the function, or state owned by a struct the function receives. If the value never has to change, the assignment was the mistake: compute with the const as an input and bind the outcome, as in repair 2.

Decision summary

  • The error line says E0067 and the operator is compound, or E0070 and the operator is =: the target is not a place. Bind it, store the result, or retarget the write to a real place.
  • The target is a literal, a sum, a call result, or a parenthesized value expression: it is a value in every case; parentheses do not change that.
  • The target is a const item: no keyword fixes it; the value must move into a variable or stay an input.
  • The error line says E0384: the target is a place and the binding needs mut. E0594: the target is an immutable static. Both are mutability errors, not this one.

Checklist

  • Read the code in the error line: E0067 pairs with compound operators, E0070 with =, and the message is shared.
  • Ask of the target: does it name storage the program owns? If not, no form of the assignment works.
  • Bind a literal or a call result to a let mut variable before assigning to it.
  • Store a computed result in a new binding when the write was really a computation.
  • Write through *r, a field, or an index when the value already lives in a place.
  • Never reach for mut on a const item; move the value into a variable instead.
  • If the compiler offered a mut suggestion, the code was E0384 - a different error with a one-keyword repair.

Sources

  • Rust error codes index, E0067 - "An invalid left-hand side expression was used on an assignment operation"; its 12 += 1; example, its place-expression explanation, and its bind-then-assign correction are the source for the rule statement and repair 1.
  • Rust error codes index, E0070 - "An assignment operator was used on a non-place expression"; its examples include assigning to a const item, the source for the plain-assignment sibling and the const case.

Keep Exploring