diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/semver/src/backport.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/semver/src/backport.rs | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/vendor/semver/src/backport.rs b/vendor/semver/src/backport.rs index 4b67f56a5..b5e1d02be 100644 --- a/vendor/semver/src/backport.rs +++ b/vendor/semver/src/backport.rs @@ -18,43 +18,6 @@ pub(crate) use crate::alloc::vec::Vec; #[cfg(no_alloc_crate)] // rustc <1.36 pub(crate) mod alloc { + pub use std::alloc; pub use std::vec; - - pub mod alloc { - use std::mem; - use std::process; - - #[derive(Copy, Clone)] - pub struct Layout { - size: usize, - } - - impl Layout { - pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self { - assert_eq!(align, 2); - Layout { size } - } - } - - pub unsafe fn alloc(layout: Layout) -> *mut u8 { - let len_u16 = (layout.size + 1) / 2; - let mut vec = Vec::new(); - vec.reserve_exact(len_u16); - let ptr: *mut u16 = vec.as_mut_ptr(); - mem::forget(vec); - ptr as *mut u8 - } - - pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { - let len_u16 = (layout.size + 1) / 2; - unsafe { Vec::from_raw_parts(ptr as *mut u16, 0, len_u16) }; - } - - pub fn handle_alloc_error(_layout: Layout) -> ! { - // This is unreachable because the alloc implementation above never - // returns null; Vec::reserve_exact would already have called std's - // internal handle_alloc_error. - process::abort(); - } - } } |