std's mut imported under two names lends under both: no false missing-mut, no missed aliased-mut #150
Loading…
Reference in a new issue
No description provided.
Delete branch "mut-aliases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While checking whether
mut(x)is inlined by the build (it is: the transform erases it), one case slipped through: a file that imports std'smutunder two names,import { mut, mut as lend }. The loan collector kept only one local name, taken from aHashMapin no fixed order, and calls through the other name weren't loans at all:aliased-mutdidn't see them, sotransfer(mut(account), lend(account))passed;missing-mutreported a call that did lend and offeredmut(mut(account))as the fix.Now the collector keeps every name for
mutand formutEach, sorted. Fixes still writemutwhen the file has that name.Tests: new fixture
mut_two_names(fails before this change with the falsemissing-mutand the missedaliased-mut), andmut_under_two_names_is_erased_by_bothintests/transform.rs. Fast profile:cargo nextest run --workspace412/412 (the emit tests need the addon built first),npm run test:std455/455,npm run test:soundnessunchanged (16 of 110 escape).Not in this PR: several other checks still match the callee by the literal name
"mut"(lifetime.rs,superseded.rs,shifted.rs,left_behind.rs,borrow.rs:283), so a file whose only name for it ismut as lendskips those rules. Erasure and the loan checks are fine in that case. That needs its own change.Created with Claude Opus 5.5 in Claude Code.
`import { mut, mut as lend }`: the loan collector kept one local name, picked from a HashMap in no fixed order. The other name's calls were no loans: they stayed in the emitted code, `aliased-mut` didn't see them, and `missing-mut` reported a call that did lend, offering `mut(mut(account))`. It now keeps every name (sorted), for `mutEach` too; fixes write `mut` when the file has it. Co-Authored-By: Claude Opus 5.5 <[email protected]>