Skip to content

Commit 04f4ff5

Browse files
committed
Remove redundant imports of size_of
1 parent 878cb3d commit 04f4ff5

File tree

98 files changed

+79
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+79
-96
lines changed

compiler/rustc_index/src/vec/tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ crate::newtype_index! {
99

1010
#[test]
1111
fn index_size_is_optimized() {
12-
use std::mem::size_of;
13-
1412
assert_eq!(size_of::<MyIdx>(), 4);
1513
// Uses 0xFFFF_FFFB
1614
assert_eq!(size_of::<Option<MyIdx>>(), 4);

compiler/rustc_middle/src/query/erase.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::traits;
44
use crate::ty::adjustment::CoerceUnsizedInfo;
55
use crate::ty::{self, Ty};
66
use std::intrinsics::transmute_unchecked;
7-
use std::mem::{size_of, MaybeUninit};
7+
use std::mem::MaybeUninit;
88

99
#[derive(Copy, Clone)]
1010
pub struct Erased<T: Copy> {

library/alloc/src/boxed/thin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use core::ptr::{self, NonNull};
2525
/// let five = ThinBox::new(5);
2626
/// let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
2727
///
28-
/// use std::mem::{size_of, size_of_val};
2928
/// let size_of_ptr = size_of::<*const ()>();
3029
/// assert_eq!(size_of_ptr, size_of_val(&five));
3130
/// assert_eq!(size_of_ptr, size_of_val(&thin_slice));

library/alloc/src/raw_vec/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::*;
2-
use core::mem::size_of;
32
use std::cell::Cell;
43

54
#[test]

library/alloc/src/rc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ use core::intrinsics::abort;
257257
#[cfg(not(no_global_oom_handling))]
258258
use core::iter;
259259
use core::marker::{PhantomData, Unsize};
260-
#[cfg(not(no_global_oom_handling))]
261-
use core::mem::size_of_val;
262260
use core::mem::{self, align_of_val_raw, forget, ManuallyDrop};
263261
use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver};
264262
use core::panic::{RefUnwindSafe, UnwindSafe};

library/alloc/src/sync.rs

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ use core::intrinsics::abort;
1818
#[cfg(not(no_global_oom_handling))]
1919
use core::iter;
2020
use core::marker::{PhantomData, Unsize};
21-
#[cfg(not(no_global_oom_handling))]
22-
use core::mem::size_of_val;
2321
use core::mem::{self, align_of_val_raw};
2422
use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, Receiver};
2523
use core::panic::{RefUnwindSafe, UnwindSafe};

library/alloc/tests/thin_box.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::fmt::Debug;
2-
use core::mem::size_of;
32
use std::boxed::ThinBox;
43

54
#[test]

library/alloc/tests/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fmt::Debug;
1111
use std::hint;
1212
use std::iter::InPlaceIterable;
1313
use std::mem;
14-
use std::mem::{size_of, swap};
14+
use std::mem::swap;
1515
use std::ops::Bound::*;
1616
use std::panic::{catch_unwind, AssertUnwindSafe};
1717
use std::rc::Rc;

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
use crate::cmp::Ordering;
239239
use crate::fmt::{self, Debug, Display};
240240
use crate::marker::{PhantomData, Unsize};
241-
use crate::mem::{self, size_of};
241+
use crate::mem::self;
242242
use crate::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn};
243243
use crate::ptr::{self, NonNull};
244244

library/core/src/mem/maybe_uninit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ use crate::slice;
212212
/// `MaybeUninit<T>` is guaranteed to have the same size, alignment, and ABI as `T`:
213213
///
214214
/// ```rust
215-
/// use std::mem::{MaybeUninit, size_of, align_of};
215+
/// use std::mem::{MaybeUninit, align_of};
216216
/// assert_eq!(size_of::<MaybeUninit<u64>>(), size_of::<u64>());
217217
/// assert_eq!(align_of::<MaybeUninit<u64>>(), align_of::<u64>());
218218
/// ```
@@ -224,7 +224,7 @@ use crate::slice;
224224
/// optimizations, potentially resulting in a larger size:
225225
///
226226
/// ```rust
227-
/// # use std::mem::{MaybeUninit, size_of};
227+
/// # use std::mem::MaybeUninit;
228228
/// assert_eq!(size_of::<Option<bool>>(), 1);
229229
/// assert_eq!(size_of::<Option<MaybeUninit<bool>>>(), 2);
230230
/// ```

library/core/src/num/dec2flt/fpu.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub use fpu_precision::set_precision;
2222
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
2323
mod fpu_precision {
2424
use core::arch::asm;
25-
use core::mem::size_of;
2625

2726
/// A structure used to preserve the original value of the FPU control word, so that it can be
2827
/// restored when the structure is dropped.

library/core/src/num/nonzero.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ impl_zeroable_primitive!(
107107
///
108108
/// ```
109109
/// #![feature(generic_nonzero)]
110-
/// use core::mem::size_of;
111110
///
112111
/// assert_eq!(size_of::<Option<core::num::NonZero<u32>>>(), size_of::<u32>());
113112
/// ```
@@ -467,7 +466,6 @@ macro_rules! nonzero_integer {
467466
#[doc = concat!("For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:")]
468467
///
469468
/// ```rust
470-
/// use std::mem::size_of;
471469
#[doc = concat!("assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int), ">());")]
472470
/// ```
473471
///
@@ -483,7 +481,7 @@ macro_rules! nonzero_integer {
483481
/// are guaranteed to have the same size and alignment:
484482
///
485483
/// ```
486-
/// # use std::mem::{size_of, align_of};
484+
/// # use std::mem::align_of;
487485
#[doc = concat!("use std::num::", stringify!($Ty), ";")]
488486
///
489487
#[doc = concat!("assert_eq!(size_of::<", stringify!($Ty), ">(), size_of::<Option<", stringify!($Ty), ">>());")]

library/core/src/ptr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ use crate::intrinsics;
392392
use crate::marker::FnPtr;
393393
use crate::ub_checks;
394394

395-
use crate::mem::{self, align_of, size_of, MaybeUninit};
395+
use crate::mem::{self, align_of, MaybeUninit};
396396

397397
mod alignment;
398398
#[unstable(feature = "ptr_alignment_type", issue = "102070")]

library/core/src/ptr/non_null.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use crate::ub_checks::assert_unsafe_precondition;
5151
/// are guaranteed to have the same size and alignment:
5252
///
5353
/// ```
54-
/// # use std::mem::{size_of, align_of};
54+
/// # use std::mem::align_of;
5555
/// use std::ptr::NonNull;
5656
///
5757
/// assert_eq!(size_of::<NonNull<i16>>(), size_of::<Option<NonNull<i16>>>());

library/core/src/slice/raw.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Free functions to create `&[T]` and `&mut [T]`.
22
33
use crate::array;
4-
use crate::mem::{align_of, size_of};
4+
use crate::mem::align_of;
55
use crate::ops::Range;
66
use crate::ptr;
77
use crate::ub_checks;

library/core/tests/alloc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::alloc::Layout;
2-
use core::mem::size_of;
32
use core::ptr::{self, NonNull};
43

54
#[test]

library/core/tests/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ fn atomic_access_bool() {
248248

249249
#[test]
250250
fn atomic_alignment() {
251-
use std::mem::{align_of, size_of};
251+
use std::mem::align_of;
252252

253253
#[cfg(target_has_atomic = "8")]
254254
assert_eq!(align_of::<AtomicBool>(), size_of::<AtomicBool>());

library/core/tests/nonzero.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core::num::{IntErrorKind, NonZero};
22
use core::option::Option::None;
3-
use std::mem::size_of;
43

54
#[test]
65
fn test_create_nonzero_instance() {

library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
fn cast<U>(self) -> Self::CastPtr<U> {
9797
// SimdElement currently requires zero-sized metadata, so this should never fail.
9898
// 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;
100100
assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0);
101101
assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0);
102102

library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ where
9393
fn cast<U>(self) -> Self::CastPtr<U> {
9494
// SimdElement currently requires zero-sized metadata, so this should never fail.
9595
// 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;
9797
assert_eq!(size_of::<<T as Pointee>::Metadata>(), 0);
9898
assert_eq!(size_of::<<U as Pointee>::Metadata>(), 0);
9999

library/proc_macro/src/bridge/fxhash.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use std::collections::HashMap;
88
use std::hash::BuildHasherDefault;
99
use std::hash::Hasher;
10-
use std::mem::size_of;
1110
use std::ops::BitXor;
1211

1312
/// Type alias for a hashmap using the `fx` hash algorithm.

library/std/src/io/error/repr_bitpacked.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
105105
use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage};
106106
use core::marker::PhantomData;
107-
use core::mem::{align_of, size_of};
107+
use core::mem::align_of;
108108
use core::ptr::{self, NonNull};
109109

110110
// The 2 least-significant bits are used as tag.

library/std/src/io/error/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr, SimpleMes
22
use crate::assert_matches::assert_matches;
33
use crate::error;
44
use crate::fmt;
5-
use crate::mem::size_of;
65
use crate::sys::decode_error_kind;
76
use crate::sys::os::error_string;
87

library/std/src/os/fd/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn test_fd() {
3636
#[cfg(any(unix, target_os = "wasi"))]
3737
#[test]
3838
fn test_niche_optimizations() {
39-
use crate::mem::size_of;
4039
#[cfg(unix)]
4140
use crate::os::unix::io::{BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
4241
#[cfg(target_os = "wasi")]

library/std/src/os/unix/io/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::mem::size_of;
21
use crate::os::unix::io::RawFd;
32

43
#[test]

library/std/src/os/unix/net/ancillary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use super::{sockaddr_un, SocketAddr};
44
use crate::io::{self, IoSlice, IoSliceMut};
55
use crate::marker::PhantomData;
6-
use crate::mem::{size_of, zeroed};
6+
use crate::mem::zeroed;
77
use crate::os::unix::io::RawFd;
88
use crate::path::Path;
99
use crate::ptr::{eq, read_unaligned};

library/std/src/os/wasi/io/fd/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::mem::size_of;
21
use crate::os::wasi::io::RawFd;
32

43
#[test]

library/std/src/os/windows/io/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#[test]
22
fn test_niche_optimizations_socket() {
3-
use crate::mem::size_of;
43
use crate::os::windows::io::{
54
BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket,
65
};

library/std/src/sys/pal/uefi/args.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::env::current_exe;
55
use crate::ffi::OsString;
66
use crate::fmt;
77
use crate::iter::Iterator;
8-
use crate::mem::size_of;
98
use crate::vec;
109

1110
pub struct Args {

library/std/src/sys/pal/uefi/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use r_efi::protocols::{device_path, device_path_to_text};
1414

1515
use crate::ffi::OsString;
1616
use crate::io::{self, const_io_error};
17-
use crate::mem::{size_of, MaybeUninit};
17+
use crate::mem::MaybeUninit;
1818
use crate::os::uefi::{self, env::boot_services, ffi::OsStringExt};
1919
use crate::ptr::NonNull;
2020
use crate::slice;

library/std/src/sys/pal/windows/fs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ impl<'a> DirBuffIter<'a> {
749749
impl<'a> Iterator for DirBuffIter<'a> {
750750
type Item = (Cow<'a, [u16]>, bool);
751751
fn next(&mut self) -> Option<Self::Item> {
752-
use crate::mem::size_of;
753752
let buffer = &self.buffer?[self.cursor..];
754753

755754
// Get the name and next entry from the buffer.

library/std/src/sys/pal/windows/io.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::marker::PhantomData;
2-
use crate::mem::size_of;
32
use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle};
43
use crate::slice;
54
use crate::sys::c;

src/tools/clippy/clippy_lints/src/size_of_in_element_count.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare_clippy_lint! {
2121
/// ### Example
2222
/// ```rust,no_run
2323
/// # use std::ptr::copy_nonoverlapping;
24+
/// # #[allow(unused_imports)]
2425
/// # use std::mem::size_of;
2526
/// const SIZE: usize = 128;
2627
/// let x = [2u8; SIZE];

src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
22
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
33

4+
#[allow(unused_imports)]
45
use std::mem::{size_of, size_of_val};
56
use std::ops::Deref;
67

src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
22
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
33

4+
#[allow(unused_imports)]
45
use std::mem::{size_of, size_of_val};
56
use std::ops::Deref;
67

src/tools/clippy/tests/ui/manual_bits.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
clippy::unnecessary_cast
99
)]
1010

11+
#[allow(unused_imports)]
1112
use std::mem::{size_of, size_of_val};
1213

1314
fn main() {

src/tools/clippy/tests/ui/manual_bits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
clippy::unnecessary_cast
99
)]
1010

11+
#[allow(unused_imports)]
1112
use std::mem::{size_of, size_of_val};
1213

1314
fn main() {

src/tools/clippy/tests/ui/manual_slice_size_calculation.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
extern crate proc_macros;
66

7+
#[allow(unused_imports)]
78
use core::mem::{align_of, size_of};
89
use proc_macros::external;
910

src/tools/clippy/tests/ui/manual_slice_size_calculation.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
extern crate proc_macros;
66

7+
#[allow(unused_imports)]
78
use core::mem::{align_of, size_of};
89
use proc_macros::external;
910

src/tools/clippy/tests/ui/size_of_in_element_count/expressions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(clippy::size_of_in_element_count)]
22
#![allow(clippy::ptr_offset_with_cast)]
33

4+
#[allow(unused_imports)]
45
use std::mem::{size_of, size_of_val};
56
use std::ptr::{copy, copy_nonoverlapping, write_bytes};
67

src/tools/clippy/tests/ui/size_of_in_element_count/functions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(clippy::size_of_in_element_count)]
22
#![allow(clippy::ptr_offset_with_cast)]
33

4+
#[allow(unused_imports)]
45
use std::mem::{size_of, size_of_val};
56
use std::ptr::{
67
copy, copy_nonoverlapping, slice_from_raw_parts, slice_from_raw_parts_mut, swap_nonoverlapping, write_bytes,

src/tools/clippy/tests/ui/size_of_ref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(unused)]
22
#![warn(clippy::size_of_ref)]
33

4+
#[allow(unused_imports)]
45
use std::mem::size_of_val;
56

67
fn main() {

src/tools/clippy/tests/ui/transmute_undefined_repr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use core::any::TypeId;
55
use core::ffi::c_void;
6+
#[allow(unused_imports)]
67
use core::mem::{size_of, transmute, MaybeUninit};
78
use core::ptr::NonNull;
89

src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![warn(clippy::transmute_ptr_to_ptr)]
66
#![allow(unused, clippy::borrow_as_ptr)]
77

8+
#[allow(unused_imports)]
89
use std::mem::{size_of, transmute};
910

1011
// rustc_hir_analysis::check::cast contains documentation about when a cast `e as U` is

src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![warn(clippy::transmute_ptr_to_ptr)]
66
#![allow(unused, clippy::borrow_as_ptr)]
77

8+
#[allow(unused_imports)]
89
use std::mem::{size_of, transmute};
910

1011
// rustc_hir_analysis::check::cast contains documentation about when a cast `e as U` is

src/tools/compiletest/src/raise_fd_limit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
pub unsafe fn raise_fd_limit() {
1010
use std::cmp;
1111
use std::io;
12-
use std::mem::size_of_val;
1312
use std::ptr::null_mut;
1413

1514
static CTL_KERN: libc::c_int = 1;

0 commit comments

Comments
 (0)