Moved value with drop gets borrowed on reassignment #82656
Labels
A-borrow-checker
Area: The borrow checker
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
In the following example,
Dropper
contains a mutable reference and a destructor that uses that reference. The compiler thinks thatDropper
's drop code runs when reassigning to the variablev
. But since here the value is already moved andv
is basically just an empty slot, that shouldn't haben and as such I would expect that I can reuse the variable.It works if I create a new let binding, but in my actual use case that doesn't work because I want to reassign in a loop.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: