diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-06-05 01:14:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-05 01:14:29 -0700 |
| commit | 9ccc7b78ec7e8dc9784718212e4dafe60454b97d (patch) | |
| tree | d5f985ef9626868a2ba69507ae3e0908d89defe9 /library/portable-simd | |
| parent | a330e49593ee890f9197727a3a558b6e6b37f843 (diff) | |
| parent | a5a60d75a87881f79deea115d7cd002ce3373fd5 (diff) | |
| download | rust-9ccc7b78ec7e8dc9784718212e4dafe60454b97d.tar.gz rust-9ccc7b78ec7e8dc9784718212e4dafe60454b97d.zip | |
Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude (Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.) Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it.
Diffstat (limited to 'library/portable-simd')
| -rw-r--r-- | library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs | 2 | ||||
| -rw-r--r-- | library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs b/library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs index 0f1719206c9..cbffbc564cf 100644 --- a/library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs +++ b/library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs @@ -96,7 +96,7 @@ where fn cast<U>(self) -> Self::CastPtr<U> { // SimdElement currently requires zero-sized metadata, so this should never fail. // If this ever changes, `simd_cast_ptr` should produce a post-mono error. - use core::{mem::size_of, ptr::Pointee}; + use core::ptr::Pointee; assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0); assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0); diff --git a/library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs b/library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs index 7ba996d149c..6bc6ca3ac42 100644 --- a/library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs +++ b/library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs @@ -93,7 +93,7 @@ where fn cast<U>(self) -> Self::CastPtr<U> { // SimdElement currently requires zero-sized metadata, so this should never fail. // If this ever changes, `simd_cast_ptr` should produce a post-mono error. - use core::{mem::size_of, ptr::Pointee}; + use core::ptr::Pointee; assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0); assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0); |
