aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/rust/alloc/vec/set_len_on_drop.rs
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2024-05-28 22:21:34 +0200
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2024-05-28 22:21:34 +0200
commitf73a058be5d70dd81a43f16b2bbff4b1576a7af8 (patch)
treeb7959c01cf7a5d95c7c4d5b61929ff9123370322 /rust/alloc/vec/set_len_on_drop.rs
parentdma-buf: handle testing kthreads creation failure (diff)
parentMerge tag 'drm-misc-fixes-2024-05-23' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes (diff)
downloadwireguard-linux-f73a058be5d70dd81a43f16b2bbff4b1576a7af8.tar.xz
wireguard-linux-f73a058be5d70dd81a43f16b2bbff4b1576a7af8.zip
Merge remote-tracking branch 'drm/drm-fixes' into drm-misc-fixes
v6.10-rc1 is released, forward from v6.9 Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Diffstat (limited to 'rust/alloc/vec/set_len_on_drop.rs')
-rw-r--r--rust/alloc/vec/set_len_on_drop.rs35
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;
- }
-}