Skip to content

Remove some unsafe impls #3565

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

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
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
46 changes: 1 addition & 45 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,7 @@ s_no_extra_traits! {
pub absflat: [::__s32; ABS_CNT],
}

/// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
/// type are unsound and will be removed in the future.
#[deprecated(
note = "this struct has unsafe trait implementations that will be \
removed in the future",
since = "0.2.80"
)]
#[allow(missing_debug_implementations)]
pub struct af_alg_iv {
pub ivlen: u32,
pub iv: [::c_uchar; 0],
Expand Down Expand Up @@ -1032,44 +1026,6 @@ cfg_if! {
}
}

#[allow(deprecated)]
impl af_alg_iv {
fn as_slice(&self) -> &[u8] {
unsafe {
::core::slice::from_raw_parts(
self.iv.as_ptr(),
self.ivlen as usize
)
}
}
}

#[allow(deprecated)]
impl PartialEq for af_alg_iv {
fn eq(&self, other: &af_alg_iv) -> bool {
*self.as_slice() == *other.as_slice()
}
}

#[allow(deprecated)]
impl Eq for af_alg_iv {}

#[allow(deprecated)]
impl ::fmt::Debug for af_alg_iv {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("af_alg_iv")
.field("ivlen", &self.ivlen)
.finish()
}
}

#[allow(deprecated)]
impl ::hash::Hash for af_alg_iv {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.as_slice().hash(state);
}
}

impl PartialEq for prop_info {
fn eq(&self, other: &prop_info) -> bool {
self.__name == other.__name &&
Expand Down
46 changes: 1 addition & 45 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,7 @@ s_no_extra_traits! {
pub absflat: [::__s32; ABS_CNT],
}

/// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
/// type are unsound and will be removed in the future.
#[deprecated(
note = "this struct has unsafe trait implementations that will be \
removed in the future",
since = "0.2.80"
)]
#[allow(missing_debug_implementations)]
pub struct af_alg_iv {
pub ivlen: u32,
pub iv: [::c_uchar; 0],
Expand Down Expand Up @@ -1347,44 +1341,6 @@ cfg_if! {
}
}

#[allow(deprecated)]
impl af_alg_iv {
fn as_slice(&self) -> &[u8] {
unsafe {
::core::slice::from_raw_parts(
self.iv.as_ptr(),
self.ivlen as usize
)
}
}
}

#[allow(deprecated)]
impl PartialEq for af_alg_iv {
fn eq(&self, other: &af_alg_iv) -> bool {
*self.as_slice() == *other.as_slice()
}
}

#[allow(deprecated)]
impl Eq for af_alg_iv {}

#[allow(deprecated)]
impl ::fmt::Debug for af_alg_iv {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("af_alg_iv")
.field("ivlen", &self.ivlen)
.finish()
}
}

#[allow(deprecated)]
impl ::hash::Hash for af_alg_iv {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.as_slice().hash(state);
}
}

impl PartialEq for mq_attr {
fn eq(&self, other: &mq_attr) -> bool {
self.mq_flags == other.mq_flags &&
Expand Down