misc: use prelude size_of

size_of is part of std::prelude as of Rust 1.80 (with size_of_val,
align_of, align_of_val), and the workspace MSRV is 1.89, so qualifying
it (mem::size_of, std::mem::size_of, core::mem::size_of) is unnecessary.

Convert every qualified size_of call-site to the bare prelude form and
drop the now-redundant `use std::mem::size_of;` imports, keeping
`use std::mem;` where it still serves non-prelude items (transmute,
swap, replace, take, zeroed, MaybeUninit, offset_of). size_of is the
only one of the four currently used in the tree.

Pure refactor, no behavioural change. Follow-up to the
clippy::absolute_paths cleanup (#7670), as discussed in #8444.

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
This commit is contained in:
Henry Hrvoje Tonkovac
2026-06-24 21:18:18 +02:00
committed by Bo Chen
parent f56fa3a865
commit f720e619c1
49 changed files with 158 additions and 228 deletions

View File

@@ -3498,7 +3498,7 @@ mod unit_tests {
#[cfg(test)]
mod unit_tests {
#[cfg(feature = "kvm")]
use std::{mem, mem::offset_of};
use std::mem::offset_of;
use arch::layout;
use hypervisor::arch::aarch64::regs::MPIDR_EL1;

View File

@@ -8,7 +8,6 @@ use std::collections::HashMap;
use std::ffi::CString;
#[cfg(feature = "kvm")]
use std::iter;
use std::mem::size_of;
use std::sync::{Arc, Mutex};
use std::{ffi, io};

View File

@@ -3,7 +3,6 @@
// SPDX-License-Identifier: Apache-2.0
//
use core::mem::size_of;
use std::ffi::CString;
use std::fs::File;
use std::io::{self, Cursor, Read, Seek, SeekFrom};

View File

@@ -13,11 +13,11 @@
//! original memory mapping, so it remains compatible with VFIO device
//! passthrough and shared-memory-backed guest RAM.
use std::fmt;
use std::fs::{File, OpenOptions};
use std::io::{self, Error, Read};
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd};
use std::os::unix::fs::FileExt;
use std::{fmt, mem};
use vm_migration::protocol::{MemoryRange, Request, Response, Status};
@@ -65,7 +65,7 @@ pub(crate) struct UffdMsg {
_pad: [u8; 8],
}
const _: () = assert!(mem::size_of::<UffdMsg>() == 32);
const _: () = assert!(size_of::<UffdMsg>() == 32);
/// Try to obtain a userfaultfd via /dev/userfaultfd (Linux 6.1+).
///

View File

@@ -16,8 +16,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::ffi;
use std::fs::{File, OpenOptions};
use std::io::{self, Seek, SeekFrom, Write};
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
use std::mem::size_of;
use std::num::Wrapping;
use std::ops::Deref;
use std::os::unix::net::UnixStream;