-
Notifications
You must be signed in to change notification settings - Fork 1
Fix enum-drop of aggregate mutable-reference fields #167
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
Open
coord-e
wants to merge
1
commit into
main
Choose a base branch
from
claude/review-commit-d44c6b8-hy774d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−68
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //@error-in-other-file: Unsat | ||
| //@compile-flags: -C debug-assertions=off | ||
|
|
||
| // Companion to `pass/enum_tuple_mut_drop.rs`: the enum-drop path must not lose a | ||
| // packed prophecy. Dropping resolves both references to identity, so `*a` is 10, | ||
| // not 11, and this assertion must be rejected. | ||
| #[allow(dead_code)] | ||
| enum Pair<'a> { | ||
| Two((&'a mut i32, &'a mut i32)), | ||
| None, | ||
| } | ||
|
|
||
| #[thrust::callable] | ||
| fn check(a: &mut i32, b: &mut i32) { | ||
| *a = 10; | ||
| *b = 20; | ||
| { | ||
| let _p = Pair::Two((a, b)); | ||
| } | ||
| // wrong: `*a` is 10, not 11 | ||
| assert!(*a == 11); | ||
| } | ||
|
|
||
| fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //@check-pass | ||
| //@compile-flags: -C debug-assertions=off | ||
|
|
||
| // Regression test: dropping an enum whose variant field is a *tuple of mutable | ||
| // references* used to panic in `refine/env.rs` (`assert!(assumption_existentials | ||
| // .is_empty())`) because the drop assumption for the aggregate field introduced | ||
| // existentials the enum-drop path did not expect. Dropping such a value must | ||
| // resolve every packed prophecy to identity. | ||
| #[allow(dead_code)] | ||
| enum Pair<'a> { | ||
| Two((&'a mut i32, &'a mut i32)), | ||
| None, | ||
| } | ||
|
|
||
| #[thrust::callable] | ||
| fn check(a: &mut i32, b: &mut i32) { | ||
| *a = 10; | ||
| *b = 20; | ||
| { | ||
| // Construct and drop the enum without mutating through the packed references. | ||
| let _p = Pair::Two((a, b)); | ||
| } | ||
| // Dropping resolves both prophecies to identity, so the values are unchanged. | ||
| assert!(*a == 10); | ||
| assert!(*b == 20); | ||
| } | ||
|
|
||
| fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the dropped value has a refined aggregate element (for example a generic enum or tuple element whose type argument is
{v: &mut i64 | ...}), this recurses on onlyelem.tyand never substitutesterm.tuple_proj(i)for the element'sValueinelem.refinement. The previouspath_type(...).tuple_proj()path went throughsubsume_rty, which added those nested refinements before emitting the prophecy-equality constraints. Dropping such an aggregate now produces a weaker CHC clause and can accept bad postconditions whenever the refined field is dropped without being projected elsewhere.Useful? React with 👍 / 👎.