rust-lang / rust-lang/polonius
Move errors: add rule to report partial assignment to moved variables
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/rust-lang/polonius/compare/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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the master branch with the linked partial-move-errors prototype and trace how move errors are computed for the shown assignment to a.v. Review the linked Zulip conversation for context, then verify that the example produces a partial_move_error fact for the assignment without regressing existing move-error behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100