We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
RawVec
1 parent 303ee3f commit 46b547cCopy full SHA for 46b547c
library/alloc/src/raw_vec.rs
@@ -3,6 +3,7 @@
3
4
use core::alloc::LayoutErr;
5
use core::cmp;
6
+use core::intrinsics;
7
use core::mem::{self, ManuallyDrop, MaybeUninit};
8
use core::ops::Drop;
9
use core::ptr::{NonNull, Unique};
@@ -495,7 +496,11 @@ where
495
496
497
let memory = if let Some((ptr, old_layout)) = current_memory {
498
debug_assert_eq!(old_layout.align(), new_layout.align());
- unsafe { alloc.grow(ptr, old_layout, new_layout) }
499
+ unsafe {
500
+ // The allocator checks for alignment equality
501
+ intrinsics::assume(old_layout.align() == new_layout.align());
502
+ alloc.grow(ptr, old_layout, new_layout)
503
+ }
504
} else {
505
alloc.alloc(new_layout)
506
};
0 commit comments