Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu ยท model-checking/verify-rust-std@80cee25 (original) (raw)
File tree
15 files changed
lines changed
- portable-simd/crates/core_simd/src/simd/ptr
15 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -257,8 +257,6 @@ use core::intrinsics::abort; | ||
257 | 257 | #[cfg(not(no_global_oom_handling))] |
258 | 258 | use core::iter; |
259 | 259 | use core:๐:{PhantomData, Unsize}; |
260 | -#[cfg(not(no_global_oom_handling))] | |
261 | -use core::mem::size_of_val; | |
262 | 260 | use core::mem::{self, align_of_val_raw, forget, ManuallyDrop}; |
263 | 261 | use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver}; |
264 | 262 | use core::panic::{RefUnwindSafe, UnwindSafe}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,8 +18,6 @@ use core::intrinsics::abort; | ||
18 | 18 | #[cfg(not(no_global_oom_handling))] |
19 | 19 | use core::iter; |
20 | 20 | use core:๐:{PhantomData, Unsize}; |
21 | -#[cfg(not(no_global_oom_handling))] | |
22 | -use core::mem::size_of_val; | |
23 | 21 | use core::mem::{self, align_of_val_raw}; |
24 | 22 | use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, Receiver}; |
25 | 23 | use core::panic::{RefUnwindSafe, UnwindSafe}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -253,7 +253,7 @@ | ||
253 | 253 | use crate::cmp::Ordering; |
254 | 254 | use crate::fmt::{self, Debug, Display}; |
255 | 255 | use crate:๐:{PhantomData, Unsize}; |
256 | -use crate::mem::{self, size_of}; | |
256 | +use crate::mem; | |
257 | 257 | use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn}; |
258 | 258 | use crate::ptr::{self, NonNull}; |
259 | 259 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -65,7 +65,6 @@ | ||
65 | 65 | |
66 | 66 | use crate:๐:DiscriminantKind; |
67 | 67 | use crate:๐:Tuple; |
68 | -use crate::mem::align_of; | |
69 | 68 | use crate::ptr; |
70 | 69 | use crate::ub_checks; |
71 | 70 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -14,6 +14,9 @@ pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; | ||
14 | 14 | #[stable(feature = "core_prelude", since = "1.4.0")] |
15 | 15 | #[doc(no_inline)] |
16 | 16 | pub use crate::mem::drop; |
17 | +#[stable(feature = "size_of_prelude", since = "CURRENT_RUSTC_VERSION")] | |
18 | +#[doc(no_inline)] | |
19 | +pub use crate::mem::{align_of, align_of_val, size_of, size_of_val}; | |
17 | 20 | |
18 | 21 | // Re-exported types and traits |
19 | 22 | #[stable(feature = "core_prelude", since = "1.4.0")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -415,7 +415,7 @@ use crate::intrinsics; | ||
415 | 415 | use crate:๐:FnPtr; |
416 | 416 | use crate::ub_checks; |
417 | 417 | |
418 | -use crate::mem::{self, align_of, size_of, MaybeUninit}; | |
418 | +use crate::mem::{self, MaybeUninit}; | |
419 | 419 | |
420 | 420 | mod alignment; |
421 | 421 | #[unstable(feature = "ptr_alignment_type", issue = "102070")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
1 | 1 | //! Free functions to create `&[T]` and `&mut [T]`. |
2 | 2 | |
3 | 3 | use crate::array; |
4 | -use crate::mem::{align_of, size_of}; | |
5 | 4 | use crate::ops::Range; |
6 | 5 | use crate::ptr; |
7 | 6 | use crate::ub_checks; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1296,7 +1296,6 @@ impl AtomicPtr { | ||
1296 | 1296 | #[cfg(target_has_atomic_equal_alignment = "ptr")] |
1297 | 1297 | #[unstable(feature = "atomic_from_mut", issue = "76314")] |
1298 | 1298 | pub fn from_mut(v: &mut *mut T) -> &mut Self { |
1299 | -use crate::mem::align_of; | |
1300 | 1299 | let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()]; |
1301 | 1300 | // SAFETY: |
1302 | 1301 | // - the mutable reference guarantees unique ownership. |
@@ -2286,7 +2285,6 @@ macro_rules! atomic_int { | ||
2286 | 2285 | #[$cfg_align] |
2287 | 2286 | #[unstable(feature = "atomic_from_mut", issue = "76314")] |
2288 | 2287 | pub fn from_mut(v: &mut $int_type) -> &mut Self { |
2289 | -use crate::mem::align_of; | |
2290 | 2288 | let [] = [(); align_of::<Self>() - align_of::<$int_type>()]; |
2291 | 2289 | // SAFETY: |
2292 | 2290 | // - the mutable reference guarantees unique ownership. |
@@ -2354,7 +2352,6 @@ macro_rules! atomic_int { | ||
2354 | 2352 | #[$cfg_align] |
2355 | 2353 | #[unstable(feature = "atomic_from_mut", issue = "76314")] |
2356 | 2354 | pub fn from_mut_slice(v: &mut [$int_type]) -> &mut [Self] { |
2357 | -use crate::mem::align_of; | |
2358 | 2355 | let [] = [(); align_of::<Self>() - align_of::<$int_type>()]; |
2359 | 2356 | // SAFETY: |
2360 | 2357 | // - the mutable reference guarantees unique ownership. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -96,7 +96,7 @@ where | ||
96 | 96 | fn cast<U>(self) -> Self::CastPtr<U> { |
97 | 97 | // SimdElement currently requires zero-sized metadata, so this should never fail. |
98 | 98 | // If this ever changes, `simd_cast_ptr` should produce a post-mono error. |
99 | -use core::{mem::size_of, ptr::Pointee}; | |
99 | +use core::ptr::Pointee; | |
100 | 100 | assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0); |
101 | 101 | assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0); |
102 | 102 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -93,7 +93,7 @@ where | ||
93 | 93 | fn cast<U>(self) -> Self::CastPtr<U> { |
94 | 94 | // SimdElement currently requires zero-sized metadata, so this should never fail. |
95 | 95 | // If this ever changes, `simd_cast_ptr` should produce a post-mono error. |
96 | -use core::{mem::size_of, ptr::Pointee}; | |
96 | +use core::ptr::Pointee; | |
97 | 97 | assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0); |
98 | 98 | assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0); |
99 | 99 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -7,7 +7,6 @@ | ||
7 | 7 | use std::collections::HashMap; |
8 | 8 | use std::hash::BuildHasherDefault; |
9 | 9 | use std::hash::Hasher; |
10 | -use std::mem::size_of; | |
11 | 10 | use std::ops::BitXor; |
12 | 11 | |
13 | 12 | /// Type alias for a hashmap using the `fx` hash algorithm. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -104,7 +104,6 @@ | ||
104 | 104 | |
105 | 105 | use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; |
106 | 106 | use core:๐:PhantomData; |
107 | -use core::mem::{align_of, size_of}; | |
108 | 107 | use core::ptr::{self, NonNull}; |
109 | 108 | |
110 | 109 | // The 2 least-significant bits are used as tag. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,7 +3,7 @@ | ||
3 | 3 | use super::{sockaddr_un, SocketAddr}; |
4 | 4 | use crate::io::{self, IoSlice, IoSliceMut}; |
5 | 5 | use crate:๐:PhantomData; |
6 | -use crate::mem::{size_of, zeroed}; | |
6 | +use crate::mem::zeroed; | |
7 | 7 | use crate::os::unix::io::RawFd; |
8 | 8 | use crate::path::Path; |
9 | 9 | use crate::ptr::{eq, read_unaligned}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -14,6 +14,9 @@ pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; | ||
14 | 14 | #[stable(feature = "rust1", since = "1.0.0")] |
15 | 15 | #[doc(no_inline)] |
16 | 16 | pub use crate::mem::drop; |
17 | +#[stable(feature = "size_of_prelude", since = "CURRENT_RUSTC_VERSION")] | |
18 | +#[doc(no_inline)] | |
19 | +pub use crate::mem::{align_of, align_of_val, size_of, size_of_val}; | |
17 | 20 | |
18 | 21 | // Re-exported types and traits |
19 | 22 | #[stable(feature = "rust1", since = "1.0.0")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -36,6 +36,10 @@ | ||
36 | 36 | //! operations for both destructors and overloading `()`. |
37 | 37 | //! * [std::mem]::[drop] , a convenience function for explicitly |
38 | 38 | //! dropping a value. |
39 | +//! * [std::mem]::{[size_of], [size_of_val]} , to get the size of |
|
40 | +//! a type or value. | |
41 | +//! * [std::mem]::{[align_of], [align_of_val]} , to get the |
|
42 | +//! alignment of a type or value. | |
39 | 43 | //! * [std::boxed]::[Box] , a way to allocate values on the heap. |
40 | 44 | //! * [std::borrow]::[ToOwned] , the conversion trait that defines |
41 | 45 | //! [`to_owned`], the generic method for creating an owned type from a |