E1096: aggregate assigned to itself

View source

A struct is moved by assignment, not copied.

A struct is moved by assignment, not copied. x = x would move the value out of x and into x in one step, which has no meaning, so the compiler rejects it for a struct. A plain number is copied and is not checked. The message names the binding. The error points at the assignment.

Example

actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: 1, };
    p = p;
}

Fix

Remove the assignment, or assign another value.

actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: 1, };
    erg q: Point = Point { x: 2, };
    p = q;
}

Run actus explain E1096 in your terminal to read this entry offline. Browse Ownership & types or all error codes.