Comment

Comment by waynecochran

    the Rust compiler is able to infer that allowing two mutable borrows 
    is safe as long as one of them is never used
This (i.e. proving a variable is never used) is impossible in general since it is equivalent to the halting problem. There are many cases where it can be solved, so the compiler lets the programmer get away with this in the cases where one of the mutable borrows is provably not used. Now imagine re-factoring the code so that the compiler could no longer produce the proof. Now an error is generated and the programmer is left scratching their head wondering where this new error came from.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton