Rust errors / Everything else
Rust compiler error · checked with rustc 1.99.0
Rust error E0067: invalid left-hand side of assignment
What it meansAn invalid left-hand side expression was used on an assignment operation.
What rustc prints
error[E0067]: invalid left-hand side of assignment
--> main.rs:3:4
|
3 | 12 += 1; // error!
| -- ^^
| |
| cannot assign to this expressionReal 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.
The compiler team's explanation
An invalid left-hand side expression was used on an assignment operation.
Erroneous code example:
12 += 1; // error!
You need to have a place expression to be able to assign it something. For example:
let mut x: i8 = 12;
x += 1; // ok!From rustc --explain E0067 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.
Related errors
- E0061this function takes N arguments but M were supplied
- E0412cannot find type in this scope
- E0515cannot return reference to local variable
- E0728await is only allowed inside async functions and blocks
- E0062field `x` specified more than once
- E0063missing field `y` in initializer of `Foo`
- E0070invalid left-hand side of assignment
- E0081discriminant value `3` assigned more than once
Up next
Often hit nextE0061: this function takes N arguments but M were suppliedA related error from the same family.Read it next →Did this answer your question?