Miri currently considers Copy and Move the same operation. There are some proposals in particular by @eddyb to make them not the same: it might be beneficial for optimizations to be able to rely on the data not being read again after a Move. This would correspond to replacing the data by Undef. It seems reasonable to do similar things for drop -- though that requires a precise definition of what is actually considered a drop (does that include just the Drop terminator or also calls to drop_in_place?).
(Miri concern: One reason why I am a bit hesitant about this is that this makes read have a side-effect, so we'd have to make all read methods in Miri take the interpreter context by &mut self. Reads already have a side-effect in Stacked Borrows but that is fairly local and we just use a RefCell there.)
@eddyb what would be such optimizations that benefit from this, where StorageDead is not happening so we need to rely on Move?
Potential blockers that would prevent deinit-on-move:
Reasons to do deinit-on-move:
Testcases:
Miri currently considers
CopyandMovethe same operation. There are some proposals in particular by @eddyb to make them not the same: it might be beneficial for optimizations to be able to rely on the data not being read again after aMove. This would correspond to replacing the data byUndef. It seems reasonable to do similar things for drop -- though that requires a precise definition of what is actually considered a drop (does that include just theDropterminator or also calls todrop_in_place?).(Miri concern: One reason why I am a bit hesitant about this is that this makes read have a side-effect, so we'd have to make all read methods in Miri take the interpreter context by
&mut self. Reads already have a side-effect in Stacked Borrows but that is fairly local and we just use aRefCellthere.)@eddyb what would be such optimizations that benefit from this, where
StorageDeadis not happening so we need to rely onMove?Potential blockers that would prevent deinit-on-move:
Reasons to do deinit-on-move:
Testcases: