Refactor underlying data of map_windows::Buffer into RawBuffer#156533
Refactor underlying data of map_windows::Buffer into RawBuffer#156533Paladynee wants to merge 2 commits into
Conversation
|
r? @scottmcm rustbot has assigned @scottmcm. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
r? @nia-e |
This comment has been minimized.
This comment has been minimized.
Refactor the liveness and access invariants of Buffer into RawBuffer. This lets us initialize a Buffer without dropping it if it panics transiently. Fixes rust-lang#156501.
bb69c9d to
4fad2ca
Compare
|
|
I think this would make optimizing away the copy just as hard for the optimizer as with #156517. |
do you mean is |
|
With this PR there is first a copy during the clone. Then a copy into new_raw, a copy for Self::new and finally a copy into the return area. The copy during clone is unavoidable. The copy into new_raw can probably be folded into the clone copy and the copy into the return area can probably be folded into creating the output of For the other PR there is first a copy during the clone. Then a copy into buffer and finally a copy to the return area. Again the copy to the return area will probably be optimized away. The copy into buffer might not be.
It isn't. The ManuallyDrop would just be to suppress the Drop impl that is causing the unsoundness. To be clear I haven't checked if my suggestion actually helps. |
I can replace the calls to |
|
|
|
I'm not convinced that this level of overhaul is really necessary for this. The bug can probably be addressed much more simply by implementing bjorn3's suggestion from the other PR; this is a lot of churn in a very delicate part of the codebase. I'll take another look at an overhaul like this if a simple fix isn't possible, but I'd like to see the reasoning there first. |
Refactor the liveness and access invariants of Buffer into RawBuffer. This lets us initialize a Buffer without dropping any uninitialized data if anything panics transiently.
Fixes #156501.