diff options
author | Wedson Almeida Filho <walmeida@microsoft.com> | 2024-03-27 22:35:57 -0300 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2024-04-16 22:05:00 +0200 |
commit | 9d0441bab775d2daa51370909b8648e27d0eb47d (patch) | |
tree | 131e5b6540f803266b39e543a383f5ab8714d9d4 /rust/alloc/vec/set_len_on_drop.rs | |
parent | 11795ae4cc430192fb9aee2c1142e313cbce3ec5 (diff) |
rust: alloc: remove our fork of the `alloc` crate
It is not used anymore as `VecExt` now provides the functionality we
depend on.
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
Link: https://lore.kernel.org/r/20240328013603.206764-5-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/alloc/vec/set_len_on_drop.rs')
-rw-r--r-- | rust/alloc/vec/set_len_on_drop.rs | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/rust/alloc/vec/set_len_on_drop.rs b/rust/alloc/vec/set_len_on_drop.rs deleted file mode 100644 index d3c7297b80ec..000000000000 --- a/rust/alloc/vec/set_len_on_drop.rs +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 OR MIT - -// Set the length of the vec when the `SetLenOnDrop` value goes out of scope. -// -// The idea is: The length field in SetLenOnDrop is a local variable -// that the optimizer will see does not alias with any stores through the Vec's data -// pointer. This is a workaround for alias analysis issue #32155 -pub(super) struct SetLenOnDrop<'a> { - len: &'a mut usize, - local_len: usize, -} - -impl<'a> SetLenOnDrop<'a> { - #[inline] - pub(super) fn new(len: &'a mut usize) -> Self { - SetLenOnDrop { local_len: *len, len } - } - - #[inline] - pub(super) fn increment_len(&mut self, increment: usize) { - self.local_len += increment; - } - - #[inline] - pub(super) fn current_len(&self) -> usize { - self.local_len - } -} - -impl Drop for SetLenOnDrop<'_> { - #[inline] - fn drop(&mut self) { - *self.len = self.local_len; - } -} |