Rust

Assign to Non-Place Expression E0070 Fix

E0070 is the compiler refusing an assignment whose left-hand side is not a place: a constant, a literal, a function call, and a computed value all produce values, but none of them names a memory location, so there is nowhere for the assigned value to go. The diagnostic underlines the whole left-hand side, points its caret at the equals sign, and labels the target 'cannot assign to this expression'. This guide shows the error on the shapes that draw it, the repairs that give the assignment a real place to write to, and the neighboring codes the same line draws when the operator or the target changes.

Written December 1, 2026 · Tested with Rust 1.99.1 · 14 min read

By the end of this guide
  • The rule underneath: the left-hand side must be a place expression
  • How to read the diagnostic
  • The first failure: assigning to a constant
  • The same error across the target shapes

Written December 1, 2026

Tested with Rust 1.99.1

What this guide is

Error E0070 is about the target of an assignment, not the value being assigned. The error codes index opens: "An assignment operator was used on a non-place expression." Its erroneous examples assign to a constant, to the literal 1, to a function call, and through a struct's name - four different-looking lines with one shared defect: the left-hand side produces a value but owns no storage.

The practical payoff is that the repair is always the same move, even though the lines look unrelated. Give the assignment a place - a mutable variable, a field of one, an element of one, or a dereference of a mutable reference - and move the value through that place. Neighboring codes in this area are E0067, the same invalid target under a compound operator such as +=, and E0384, reassigning a variable that was never declared mutable; both are covered as boundaries below, because telling them apart from E0070 is most of the diagnosis.

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: the left-hand side must be a place expression

An assignment writes a value into a memory location, so its left-hand side has to denote one. The index states the rule directly: "The left-hand side of an assignment operator must be a place expression. A place expression represents a memory location and can be a variable (with optional namespacing), a dereference, an indexing expression or a field reference." The Reference divides expressions the same way: a place expression represents a memory location, while a value expression - a literal, a constant, a call, an arithmetic result - computes a value and has no location of its own.

That division explains why each failing shape fails. A const is a value substituted wherever its name appears; it has no address and no storage, so there is nothing to overwrite. A literal is a value with no name at all. A function call produces a fresh value at the moment it runs; assigning to the call would mean writing into a result that is discarded immediately. And a computed expression such as a + b is a value derived from two places without being a place itself. In every case the value on the right is fine and the operator is fine - the target is what does not exist.

How to read the diagnostic

In the probed set, an E0070 failure is a single error with no help block. The header states the rule: "invalid left-hand side of assignment". One span is marked: dashes under the entire left-hand side expression, a caret under the = sign, and the label "cannot assign to this expression" beneath. There is no suggested replacement, because the compiler cannot know which real location the value was meant for - choosing the place is the programmer's part of the repair.

Read the underlined span as the whole diagnosis: whatever sits under the dashes is a value, not a location. If your diagnostic instead offers to add mut, or names E0067 or E0599, you are in one of the neighboring situations covered in the boundary sections below, and the repair is different.

The first failure: assigning to a constant

The smallest shape is the index's first mistake - a program that tries to change a constant's value in place:

Rust
const SOME_CONST: i32 = 12;
fn main() {
    SOME_CONST = 14;
    println!("{}", SOME_CONST);
}
Output
error[E0070]: invalid left-hand side of assignment
 --> fail_const.rs:3:16
  |
3 |     SOME_CONST = 14;
  |     ---------- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

Nothing is wrong with 14, with the assignment operator, or with reading SOME_CONST in the println! below. The one defect is the target: a constant is not storage. If the program needs a value that starts at the constant and then changes, the constant supplies the starting value and a mutable local holds the changes - that repair is shown running below.

The same error across the target shapes

A literal is the same defect with even less around it. There is no name, no declaration, and nothing a mut could attach to:

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

error: aborting due to 1 previous error

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

A function call fails the same way. The call runs and produces a value - here the unit value of a function with no return - and the assignment tries to write into that fleeting result:

Rust
fn some_other_func() {}
fn main() {
    some_other_func() = 4;
}
Output
error[E0070]: invalid left-hand side of assignment
 --> fail_call.rs:3:23
  |
3 |     some_other_func() = 4;
  |     ----------------- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

A call that returns a real value is no different. The returned i32 is a value the caller receives, not a location inside the callee, so assigning to the call cannot send 4 back into make:

Rust
fn make() -> i32 {
    41
}
fn main() {
    make() = 4;
    println!("{}", make());
}
Output
error[E0070]: invalid left-hand side of assignment
 --> fail_return_value.rs:5:12
  |
5 |     make() = 4;
  |     ------ ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

And a computed expression fails even though both of its operands are places. Reading a and b is fine; their sum is a new value with no location, so it cannot receive one:

Rust
fn main() {
    let a = 1;
    let b = 2;
    a + b = 3;
}
Output
error[E0070]: invalid left-hand side of assignment
 --> fail_expr.rs:4:11
  |
4 |     a + b = 3;
  |     ----- ^
  |     |
  |     cannot assign to this expression

error: aborting due to 1 previous error

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

In every probed failing shape the diagnostic is identical apart from the span: a constant, a literal, a call, a call's return value, and a sum. The failing family is one shape - a plain = whose left-hand side is a value expression instead of a place expression.

The repair: copy the constant into a mutable local

A constant cannot change, but a local initialized from it can. Copying SOME_CONST into a let mut binding gives the assignment a place, and the constant itself keeps its original value for every other reader:

Rust
const SOME_CONST: i32 = 12;
fn main() {
    let mut local = SOME_CONST;
    println!("{}", local);
    local = 14;
    println!("{} {}", SOME_CONST, local);
}
Output
12
12 14

The first line prints the copied starting value, 12; after the assignment, the second line prints 12 14 - the constant unchanged, the local holding the new value. This is the general repair for every read-only source: constants, literals, and configuration values all enter mutable code by being copied or bound into a mutable place first, never by being assigned to directly.

The repair: bind a call result before assigning to it

When the intent is to adjust a value a function returns, the call result has to land in a place first. Binding it with let mut and then assigning to the binding compiles and runs:

Rust
fn make() -> i32 {
    41
}
fn main() {
    let mut value = make();
    println!("{}", value);
    value = 4;
    println!("{}", value);
}
Output
41
4

The output shows the value's whole path: 41 as returned, then 4 after the assignment to the binding. Note what this repair does not do: it does not write back into make, and no form of words can - a function that callers are meant to update state through takes a mutable reference or returns a place-owning type, which is a change to the function's signature, not to this line. Where the goal is only to work with the returned value, the binding is the complete fix.

The places that accept assignment

The index's working examples assign through the four place forms, and all four run in one program here - a struct field, a second field, an array index, and a dereference of a mutable reference:

Rust
struct SomeStruct {
    x: i32,
    y: i32,
}
fn some_func(x: &mut i32) {
    *x = 12;
}
fn main() {
    let mut s = SomeStruct { x: 0, y: 0 };
    s.x = 3;
    s.y = 4;
    let mut v = vec![1, 2, 3];
    v[0] = 9;
    let mut n = 1;
    some_func(&mut n);
    println!("{} {} {} {}", s.x, s.y, v[0], n);
}
Output
3 4 9 12

Each assigned value reads back in the output: field x holds 3, field y holds 4, element v[0] holds 9, and n holds 12, written through the dereference *x inside some_func. Together with a plain mutable variable - local and value in the two repairs above - these are the targets E0070 accepts: if the left-hand side resolves to a variable, a field of one, an index into one, or a dereference, the assignment has somewhere to go.

The boundary: a compound operator on the same target is E0067

Change only the operator and the code changes with it. The constant from the first failure, assigned with += instead of =, draws E0067 - the compound-assignment code - with the same header wording and the same "cannot assign to this expression" label:

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

error: aborting due to 1 previous error

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

The literal shape behaves the same way: 12 += 1; also draws E0067. So the split between the two codes is the operator, not the target - plain = on a non-place is E0070, a compound operator (+=, -=, and the rest) on a non-place is E0067. The repair is the same in both: give the operation a mutable place. The E0067 guide covers the compound side in full.

The boundary: an immutable variable is E0384, not E0070

A plain variable is a place, so assigning to one never draws E0070 - but a variable declared without mut refuses assignment for the opposite reason. Here the target exists and cannot be written:

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

warning: value assigned to `x` is never read
 --> fail_immutable.rs:2:13
  |
2 |     let x = 3;
  |             ^ this value is reassigned later and never used
3 |     x = 5;
  |     ----- `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 contrast is the fastest way to separate the two codes in real output. E0384 names the variable, marks the first assignment, and offers a concrete repair - add mut. E0070 names no variable, because there is none: its span covers an expression, and no mut exists that could fix it. When the diagnostic offers mut, take it; when it only says "cannot assign to this expression", the target itself has to change. The E0384 guide covers the immutable side in full.

The boundary: the index's struct-name shape now draws E0599

One of the index's four erroneous examples no longer produces E0070 on the current compiler. Assigning through a struct's name, as if the type were a variable holding its fields, is refused earlier - as a failed name lookup:

Rust
struct SomeStruct {
    x: i32,
    y: i32,
}
fn main() {
    SomeStruct::x = 12;
}
Output
error[E0599]: no associated function or constant named `x` found for struct `SomeStruct` in the current scope
 --> fail_struct_name.rs:6:17
  |
1 | struct SomeStruct {
  | ----------------- associated function or constant `x` not found for this struct
...
6 |     SomeStruct::x = 12;
  |                 ^ associated function or constant not found in `SomeStruct`

error: aborting due to 1 previous error

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

The intent behind the line is still repaired the place way: fields are assigned on an instance, as s.x = 3 in the places program above, never through the type's name. But the code to search for, when this exact line is in front of you, is E0599 - the compiler resolves SomeStruct::x as an associated item before assignment is ever considered, and finds no such item. Treat the index's example list as shapes of the same intent, and the emitted code as the authority for the line you actually have.

Fixes in reach order

First, read the span. If the dashes cover a variable name and the diagnostic offers to add mut, the code is E0384 and the one-word repair is correct. If the dashes cover anything else - a constant, a literal, a call, a computed expression - no mut applies, and the target itself must change.

Second, decide where the value was meant to live, and bind it there. A changing copy of a constant goes in a let mut local initialized from the constant. A call result you need to adjust goes in a let mut binding first. A computed result likewise: evaluate it into a named mutable variable, then assign to the variable. In the probed set, each of these took its failing shape to compiling and running with no other change.

Third, if the value was meant to live inside an existing structure, assign through that structure's place: the field (s.x), the index (v[0]), or a dereference (*x) of a mutable reference passed for the purpose. A function that is supposed to write into its caller's variable takes &mut and assigns through the dereference, as some_func does above.

Last, check the operator before re-reading the target. The same non-place target under += or another compound operator is E0067, not E0070 - the repair is identical, but searching the wrong code wastes the first step.

Decision summary

E0070, in this guide's probed set, fired exactly when a plain = assignment's left-hand side was a value expression rather than a place expression: a constant, the literal 1, a function call, a call returning i32, and the sum a + b. Every diagnostic was a single error headed "invalid left-hand side of assignment", dashes under the whole left-hand side, a caret under the =, and the label "cannot assign to this expression", with no help block. Compiling and running were: a mutable local copied from the constant, a call result bound to a mutable variable before assignment, and assignments through a variable, two struct fields, an array index, and a dereference. The same constant and the same literal under += drew E0067; reassigning an immutable variable drew E0384 with a mut suggestion; and the index's struct-name example drew E0599 on the current compiler.

Checklist

  • Read the underlined span: E0070 underlines an expression, E0384 underlines a variable and offers mut.
  • A constant has no storage - copy it into a let mut local and assign to the local.
  • A call result has no caller-side location - bind it with let mut before assigning to it.
  • A computed expression is a value, not a place - evaluate it into a named variable first.
  • Assign through real places: a mutable variable, its fields, its indexes, or a dereference of &mut.
  • Check the operator: a non-place under += or another compound operator is E0067, with the same repair.

Sources

  • Rust error codes index, E0070 - an assignment operator was used on a non-place expression; the erroneous examples assigning to a constant, a literal, a function call, and a struct name; the statement that the left-hand side must be a place expression representing a memory location - a variable, a dereference, an indexing expression, or a field reference; and the working examples assigning through a struct field and a dereference.
  • The Rust Reference, Expressions - expressions divided into place expressions and value expressions, where a place expression represents a memory location and a value expression computes a value.
  • Rust error codes index, E0067 - an invalid left-hand side was used on an assignment operation, shown on a compound assignment to a literal, and repaired by assigning to a mutable variable instead.

Keep Exploring