Commit 9d919c5
fix(borrow): whole-place assignment clears move-record (Refs #177)
`x = e` where LHS is a `PlaceVar` is a *write*, not a read. Pre-fix,
StmtAssign called `check_use` on the LHS, which fired `UseAfterMove`
whenever `x` had been moved earlier — spuriously rejecting `let mut x;
drop(x); x = …; use(x)`. This is the assignment-clears-move imprecision
called out in the deferred-items comment at lib/borrow.ml:1483, the
StmtAssign half of the Slice C' pairing.
Whole-place writes now skip `find_move` (keeping the exclusive-borrow
aliasing check) and drop any overlapping move-record after the RHS is
validated, reviving the place for subsequent uses. Sub-place writes
(`x.f =`, `x[i] =`) keep `check_use` because they navigate through a
parent that must still be live.
Anti-regression preserved:
- borrow_nll_still_rejects_live_borrow.affine (Slice A): assignment
to a place with a live shared borrow still errors MoveWhileBorrowed.
- slice_c_body_move_persists.affine (Slice C): a moved local that is
NOT reassigned still errors UseAfterMove on later reads.
- 327 prior tests, all green (328/328 with the new case).
Loop-soundness (Slice C' StmtWhile/StmtFor) can now proceed
independently — comment at lib/borrow.ml:1496 updated accordingly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f6782c4 commit 9d919c5
3 files changed
Lines changed: 67 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
1355 | | - | |
1356 | | - | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
1357 | 1376 | | |
1358 | 1377 | | |
1359 | 1378 | | |
| |||
1386 | 1405 | | |
1387 | 1406 | | |
1388 | 1407 | | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1389 | 1412 | | |
1390 | 1413 | | |
1391 | 1414 | | |
| |||
1543 | 1566 | | |
1544 | 1567 | | |
1545 | 1568 | | |
1546 | | - | |
1547 | | - | |
1548 | | - | |
1549 | | - | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
1550 | 1573 | | |
1551 | 1574 | | |
1552 | 1575 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4454 | 4454 | | |
4455 | 4455 | | |
4456 | 4456 | | |
| 4457 | + | |
| 4458 | + | |
| 4459 | + | |
| 4460 | + | |
| 4461 | + | |
| 4462 | + | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
| 4466 | + | |
| 4467 | + | |
| 4468 | + | |
| 4469 | + | |
| 4470 | + | |
| 4471 | + | |
4457 | 4472 | | |
4458 | 4473 | | |
4459 | 4474 | | |
| |||
4495 | 4510 | | |
4496 | 4511 | | |
4497 | 4512 | | |
| 4513 | + | |
| 4514 | + | |
4498 | 4515 | | |
4499 | 4516 | | |
4500 | 4517 | | |
| |||
0 commit comments