Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
utaal opened this issue Jun 30, 2020 · 0 comments
Open

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

utaal opened this issue Jun 30, 2020 · 0 comments

Comments

@utaal
Copy link
Contributor

utaal commented Jun 30, 2020

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)

@utaal utaal changed the title Move errors: add rule to report partial assignments to moved variables Move errors: add rule to report partial assignment to moved variables Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant