Skip to content

Move errors: add rule to report partial assignment to moved variables #152

@utaal

Description

@utaal

From what I can see, Polonius currently computes move errors for points where an uninitialized (moved) path is accessed, but not for points where a path is assigned (like in the example above).

I prototyped a new rule here: master...utaal:partial-move-errors
The branch is an attempt to compute errors for partial assignments to uninitialized variables, which are currently handled by a separate rustc pass.

As an example, with this branch you get a partial_move_error fact for:

struct Lin { v: u64 }

fn main() {
    let mut a: Lin = Lin { v: 3 };
    take(a);
    a.v = 7; // <- this assignment
}

fn take<V>(_v: V) { }

cc @lqd @AlbinS (also see the conversation on Zulip, https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions