Why does compilation not fail when a member of a moved value is assigned to?

What really happens

fn main() {
    let mut point: Point = Point { x: 0.3, y: 0.4 };
    println!("point coordinates: ({}, {})", point.x, point.y);

    drop(point);

    {
        let mut point: Point;
        point.x = 0.5;
    }

    println!(" x is {}", point.x);
}

It turns out that it’s already known as issue #21232.

Leave a Comment