Skip to content

Commit 582c5cf

Browse files
committed
Auto merge of #1703 - eduardosm:remove-af_alg_iv-as_slice, r=JohnTitor
Add deprecation notice to `af_alg_iv::as_slice` and trait implementations that depend on it These trait implementations exposed an unsound API (see #1501).
2 parents 2d044d9 + d73e8a3 commit 582c5cf

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ macro_rules! s_no_extra_traits {
114114
$(#[$attr])*
115115
pub struct $i { $($field)* }
116116
}
117+
#[allow(deprecated)]
117118
impl ::Copy for $i {}
119+
#[allow(deprecated)]
118120
impl ::Clone for $i {
119121
fn clone(&self) -> $i { *self }
120122
}

src/unix/linux_like/android/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ s_no_extra_traits! {
306306
pub salg_name: [::c_uchar; 64],
307307
}
308308

309+
/// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
310+
/// type are unsound and will be removed in the future.
311+
#[deprecated(
312+
note = "this struct has unsafe trait implementations that will be \
313+
removed in the future",
314+
since = "0.2.80"
315+
)]
309316
pub struct af_alg_iv {
310317
pub ivlen: u32,
311318
pub iv: [::c_uchar; 0],
@@ -591,6 +598,7 @@ cfg_if! {
591598
}
592599
}
593600

601+
#[allow(deprecated)]
594602
impl af_alg_iv {
595603
fn as_slice(&self) -> &[u8] {
596604
unsafe {
@@ -602,22 +610,26 @@ cfg_if! {
602610
}
603611
}
604612

613+
#[allow(deprecated)]
605614
impl PartialEq for af_alg_iv {
606615
fn eq(&self, other: &af_alg_iv) -> bool {
607616
*self.as_slice() == *other.as_slice()
608617
}
609618
}
610619

620+
#[allow(deprecated)]
611621
impl Eq for af_alg_iv {}
612622

623+
#[allow(deprecated)]
613624
impl ::fmt::Debug for af_alg_iv {
614625
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
615626
f.debug_struct("af_alg_iv")
616-
.field("iv", &self.as_slice())
627+
.field("ivlen", &self.ivlen)
617628
.finish()
618629
}
619630
}
620631

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

src/unix/linux_like/linux/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,13 @@ s_no_extra_traits! {
538538
pub salg_name: [::c_uchar; 64],
539539
}
540540

541+
/// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
542+
/// type are unsound and will be removed in the future.
543+
#[deprecated(
544+
note = "this struct has unsafe trait implementations that will be \
545+
removed in the future",
546+
since = "0.2.80"
547+
)]
541548
pub struct af_alg_iv {
542549
pub ivlen: u32,
543550
pub iv: [::c_uchar; 0],
@@ -781,6 +788,7 @@ cfg_if! {
781788
}
782789
}
783790

791+
#[allow(deprecated)]
784792
impl af_alg_iv {
785793
fn as_slice(&self) -> &[u8] {
786794
unsafe {
@@ -792,22 +800,26 @@ cfg_if! {
792800
}
793801
}
794802

803+
#[allow(deprecated)]
795804
impl PartialEq for af_alg_iv {
796805
fn eq(&self, other: &af_alg_iv) -> bool {
797806
*self.as_slice() == *other.as_slice()
798807
}
799808
}
800809

810+
#[allow(deprecated)]
801811
impl Eq for af_alg_iv {}
802812

813+
#[allow(deprecated)]
803814
impl ::fmt::Debug for af_alg_iv {
804815
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
805816
f.debug_struct("af_alg_iv")
806-
.field("iv", &self.as_slice())
817+
.field("ivlen", &self.ivlen)
807818
.finish()
808819
}
809820
}
810821

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

0 commit comments

Comments
 (0)