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

Rust: &(mut) x is neither a read nor a write #17655

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 3, 2024

Taking the address of a variable x via &(mut) x neither reads nor writes the variable, so the access to x should neither be a VariableReadAccess nor a VariableWriteAccess. This also includes implicit references in compound assignments x += y which really means (&mut x).add_assign(y).

Note that once we implement SSA support, then (some) variable references will be modeled as uncertain variable writes.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 3, 2024
@hvitved hvitved force-pushed the rust/variable-mut branch from 40b82f7 to e7f09e6 Compare October 3, 2024 17:57
@hvitved hvitved force-pushed the rust/variable-mut branch from e7f09e6 to a9cf33c Compare October 3, 2024 18:21
@hvitved hvitved changed the title Rust: Consider all &mut x references to be writes Rust: &(mut) x is neither a read nor a write Oct 3, 2024
@hvitved hvitved marked this pull request as ready for review October 3, 2024 18:28
@hvitved hvitved requested a review from geoffw0 October 4, 2024 09:52
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Results and approach LGTM, we might need to refine the implementation of CompoundAssignmentExpr.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@hvitved hvitved merged commit 04a4fb2 into github:main Oct 4, 2024
14 checks passed
@hvitved hvitved deleted the rust/variable-mut branch October 4, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants