Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unused_qualifications lints with 1.80 #81

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/types/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::core::{
SizeValue, WriteInto, Writer,
};

use core::mem::{size_of, MaybeUninit};

pub struct ArrayMetadata {
pub stride: SizeValue,
pub el_padding: u64,
Expand Down Expand Up @@ -68,8 +70,7 @@ where
fn write_into<B: BufferMut>(&self, writer: &mut Writer<B>) {
if_pod_and_little_endian!(if pod_and_little_endian {
let ptr = self.as_ptr() as *const u8;
let byte_slice: &[u8] =
unsafe { core::slice::from_raw_parts(ptr, core::mem::size_of::<Self>()) };
let byte_slice: &[u8] = unsafe { core::slice::from_raw_parts(ptr, size_of::<Self>()) };
writer.write_slice(byte_slice);
} else {
for elem in self {
Expand All @@ -89,7 +90,7 @@ where
if_pod_and_little_endian!(if pod_and_little_endian {
let ptr = self.as_mut_ptr() as *mut u8;
let byte_slice: &mut [u8] =
unsafe { core::slice::from_raw_parts_mut(ptr, core::mem::size_of::<Self>()) };
unsafe { core::slice::from_raw_parts_mut(ptr, size_of::<Self>()) };
reader.read_slice(byte_slice);
} else {
for elem in self {
Expand All @@ -107,11 +108,11 @@ where
#[inline]
fn create_from<B: BufferRef>(reader: &mut Reader<B>) -> Self {
if_pod_and_little_endian!(if pod_and_little_endian {
let mut me = core::mem::MaybeUninit::zeroed();
let ptr: *mut core::mem::MaybeUninit<Self> = &mut me;
let mut me = MaybeUninit::zeroed();
let ptr: *mut MaybeUninit<Self> = &mut me;
let ptr = ptr.cast::<u8>();
let byte_slice: &mut [u8] =
unsafe { core::slice::from_raw_parts_mut(ptr, core::mem::size_of::<Self>()) };
unsafe { core::slice::from_raw_parts_mut(ptr, size_of::<Self>()) };
reader.read_slice(byte_slice);
// SAFETY: All values were properly initialized by reading the bytes.
unsafe { me.assume_init() }
Expand Down