Skip to content

Commit 7aa75b3

Browse files
authored
Merge branch 'master' into jh/fix-thunk-projection
2 parents 0630d4e + a7c87bc commit 7aa75b3

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test: test-unit test-integration smir-parse-tests
2121
stable-mir-json: CARGO_BUILD_OPTS =
2222
stable-mir-json:
2323
cd deps/stable-mir-json && cargo build ${CARGO_BUILD_OPTS}
24+
cd deps/stable-mir-json && cargo build --release ${CARGO_BUILD_OPTS}
2425
cd deps/stable-mir-json && cargo run --bin cargo_stable_mir_json -- ${TOP_DIR}/deps/stable-mir-json ${TOP_DIR}/deps
2526
${TOP_DIR}/deps/.stable-mir-json/release.sh --version || ${TOP_DIR}/deps/.stable-mir-json/debug.sh --version
2627

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,23 @@ In contrast to regular write operations, the value does not have to be _mutable_
177177
### Setting Local Variables
178178

179179
The `#setLocalValue` operation writes a `Value` value to a given `Place` within the `List` of local variables currently on top of the stack.
180-
This may fail because a local may not be accessible or not mutable.
181180
If we are setting a value at a `Place` which has `Projection`s in it, then we must first traverse the projections before setting the value.
182181
A variant `#forceSetLocal` is provided for setting the local value without checking the mutability of the location.
183182

183+
**Note on mutability:** The Rust compiler validates assignment legality and may reuse immutable locals in MIR (e.g., loop variables), so `#setLocalValue` does not guard on mutability.
184+
185+
TODO: `#forceSetLocal` is now functionally identical to `#setLocalValue` and may be removed.
186+
184187
```k
185188
syntax KItem ::= #setLocalValue( Place, Evaluation ) [strict(2)]
186189
| #forceSetLocal ( Local , Evaluation ) [strict(2)]
187190
188191
rule <k> #setLocalValue(place(local(I), .ProjectionElems), VAL) => .K ... </k>
189192
<locals>
190-
LOCALS => LOCALS[I <- typedValue(VAL, tyOfLocal(getLocal(LOCALS, I)), mutabilityMut)]
193+
LOCALS => LOCALS[I <- typedValue(VAL, tyOfLocal(getLocal(LOCALS, I)), mutabilityOf(getLocal(LOCALS, I)))]
191194
</locals>
192195
requires 0 <=Int I andBool I <Int size(LOCALS)
193196
andBool isTypedValue(LOCALS[I])
194-
andBool mutabilityOf(getLocal(LOCALS, I)) ==K mutabilityMut
195197
[preserves-definedness] // valid list indexing checked
196198
197199
rule <k> #setLocalValue(place(local(I), .ProjectionElems), VAL) => .K ... </k>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn main() {
2+
let _ = repro();
3+
}
4+
5+
fn repro() -> usize {
6+
let mut out = [0usize; 2];
7+
for i in 0usize..2usize {
8+
out[i] = i;
9+
}
10+
out[1]
11+
}

kmir/src/tests/integration/data/prove-rs/show/interior-mut3-fail.main.expected

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@
4949
│ #execBlockIdx ( basicBlockIdx ( 7 ) ) ~> .K
5050
│ function: main
5151
52-
│ (17 steps)
53-
└─ 11 (stuck, leaf)
54-
#setLocalValue ( place ( ... local: local ( 1 ) , projection: .ProjectionElems )
55-
function: main
56-
span: 79
57-
52+
│ (66 steps)
53+
├─ 11 (terminal)
54+
│ #EndProgram ~> .K
55+
│ function: main
56+
57+
┊ constraint: true
58+
┊ subst: ...
59+
└─ 2 (leaf, target, terminal)
60+
#EndProgram ~> .K
5861

59-
┌─ 2 (root, leaf, target, terminal)
60-
│ #EndProgram ~> .K
6162

6263

0 commit comments

Comments
 (0)