From 3386da8f6fd77206acfa135c99727395a427bd2e Mon Sep 17 00:00:00 2001 From: chiri Date: Fri, 21 Nov 2025 22:52:19 +0300 Subject: [PATCH] Move safe computation out of unsafe block --- library/alloc/src/collections/vec_deque/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 52e079d3ae8e6..ea9d5b128ebe4 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2479,11 +2479,11 @@ impl VecDeque { let other_len = len - at; let mut other = VecDeque::with_capacity_in(other_len, self.allocator().clone()); - unsafe { - let (first_half, second_half) = self.as_slices(); + let (first_half, second_half) = self.as_slices(); + let first_len = first_half.len(); + let second_len = second_half.len(); - let first_len = first_half.len(); - let second_len = second_half.len(); + unsafe { if at < first_len { // `at` lies in the first half. let amount_in_first = first_len - at;