Skip to content

Commit 76ddc8b

Browse files
committed
feat: solve interior-mut3-fail.rs
1 parent 2f576dc commit 76ddc8b

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

kmir/src/kmir/kdist/mir-semantics/rt/data.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ A variant `#forceSetLocal` is provided for setting the local value without check
180180
</locals>
181181
requires 0 <=Int I andBool I <Int size(LOCALS)
182182
andBool isTypedValue(LOCALS[I])
183-
andBool mutabilityOf(getLocal(LOCALS, I)) ==K mutabilityMut
183+
andBool (mutabilityOf(getLocal(LOCALS, I)) ==K mutabilityMut
184+
orBool #allowsInteriorMutation(lookupTy(tyOfLocal(getLocal(LOCALS, I)))))
184185
[preserves-definedness] // valid list indexing checked
185186
186187
rule <k> #setLocalValue(place(local(I), .ProjectionElems), VAL) => .K ... </k>

kmir/src/kmir/kdist/mir-semantics/rt/types.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ requires "value.md"
99
module RT-TYPES
1010
imports BOOL
1111
imports INT
12+
imports STRING
1213
imports MAP
1314
imports K-EQUAL
1415
@@ -90,6 +91,14 @@ Pointers to arrays/slices are compatible with pointers to the element type
9091
9192
rule #structOffsets(someLayoutShape(layoutShape(fieldsShapeArbitrary(mk(OFFSETS)), _, _, _, _))) => OFFSETS
9293
rule #structOffsets(_) => .MachineSizes [owise]
94+
95+
syntax Bool ::= #allowsInteriorMutation(TypeInfo) [function, total]
96+
97+
rule #allowsInteriorMutation(typeInfoStructType(mirString(NAME), _, _, _))
98+
=> findString(NAME, "UnsafeCell", 0) =/=Int -1
99+
rule #allowsInteriorMutation(typeInfoStructType(NAME:String, _, _, _))
100+
=> findString(NAME, "UnsafeCell", 0) =/=Int -1
101+
rule #allowsInteriorMutation(_) => false [owise]
93102
```
94103

95104
## Determining types of places with projection

kmir/src/tests/integration/data/prove-rs/interior-mut3-fail.rs renamed to kmir/src/tests/integration/data/prove-rs/interior-mut3.rs

File renamed without changes.

kmir/src/tests/integration/test_integration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
}
4040
PROVE_RS_SHOW_SPECS = [
4141
'interior-mut-fail',
42-
'interior-mut3-fail',
4342
'interior-mut-refcell-fail',
4443
'assert_eq_exp',
4544
'bitwise-not-shift',

0 commit comments

Comments
 (0)