Skip to content

Commit d6afad8

Browse files
authored
Rollup merge of #149194 - chirizxc:patch-1, r=Noratrieb
Move safe computation out of unsafe block
2 parents 0b7e900 + 3386da8 commit d6afad8

File tree

1 file changed

+4
-4
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+4
-4
lines changed

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,11 +2479,11 @@ impl<T, A: Allocator> VecDeque<T, A> {
24792479
let other_len = len - at;
24802480
let mut other = VecDeque::with_capacity_in(other_len, self.allocator().clone());
24812481

2482-
unsafe {
2483-
let (first_half, second_half) = self.as_slices();
2482+
let (first_half, second_half) = self.as_slices();
2483+
let first_len = first_half.len();
2484+
let second_len = second_half.len();
24842485

2485-
let first_len = first_half.len();
2486-
let second_len = second_half.len();
2486+
unsafe {
24872487
if at < first_len {
24882488
// `at` lies in the first half.
24892489
let amount_in_first = first_len - at;

0 commit comments

Comments
 (0)