@@ -1427,7 +1427,7 @@ pub unsafe trait TryFromBytes {
1427
1427
#[ inline]
1428
1428
fn try_mut_from ( bytes : & mut [ u8 ] ) -> Result < & mut Self , TryCastError < & mut [ u8 ] , Self > >
1429
1429
where
1430
- Self : KnownLayout + Immutable , // TODO(#251): Remove the `Immutable` bound.
1430
+ Self : KnownLayout ,
1431
1431
{
1432
1432
util:: assert_dst_is_not_zst :: < Self > ( ) ;
1433
1433
match Ptr :: from_mut ( bytes) . try_cast_into_no_leftover :: < Self , BecauseExclusive > ( ) {
@@ -1532,7 +1532,7 @@ pub unsafe trait TryFromBytes {
1532
1532
candidate : & mut [ u8 ] ,
1533
1533
) -> Result < ( & mut Self , & mut [ u8 ] ) , TryCastError < & mut [ u8 ] , Self > >
1534
1534
where
1535
- Self : KnownLayout + Immutable ,
1535
+ Self : KnownLayout ,
1536
1536
{
1537
1537
util:: assert_dst_is_not_zst :: < Self > ( ) ;
1538
1538
try_mut_from_prefix_suffix ( candidate, CastType :: Prefix )
@@ -1619,7 +1619,7 @@ pub unsafe trait TryFromBytes {
1619
1619
candidate : & mut [ u8 ] ,
1620
1620
) -> Result < ( & mut [ u8 ] , & mut Self ) , TryCastError < & mut [ u8 ] , Self > >
1621
1621
where
1622
- Self : KnownLayout + Immutable ,
1622
+ Self : KnownLayout ,
1623
1623
{
1624
1624
util:: assert_dst_is_not_zst :: < Self > ( ) ;
1625
1625
try_mut_from_prefix_suffix ( candidate, CastType :: Suffix ) . map ( swap)
@@ -2535,7 +2535,7 @@ pub unsafe trait FromBytes: FromZeros {
2535
2535
#[ inline]
2536
2536
fn mut_from ( bytes : & mut [ u8 ] ) -> Result < & mut Self , CastError < & mut [ u8 ] , Self > >
2537
2537
where
2538
- Self : IntoBytes + KnownLayout + Immutable ,
2538
+ Self : IntoBytes + KnownLayout ,
2539
2539
{
2540
2540
util:: assert_dst_is_not_zst :: < Self > ( ) ;
2541
2541
match Ptr :: from_mut ( bytes) . try_cast_into_no_leftover :: < _ , BecauseExclusive > ( ) {
@@ -2610,7 +2610,7 @@ pub unsafe trait FromBytes: FromZeros {
2610
2610
bytes : & mut [ u8 ] ,
2611
2611
) -> Result < ( & mut Self , & mut [ u8 ] ) , CastError < & mut [ u8 ] , Self > >
2612
2612
where
2613
- Self : IntoBytes + KnownLayout + Immutable ,
2613
+ Self : IntoBytes + KnownLayout ,
2614
2614
{
2615
2615
util:: assert_dst_is_not_zst :: < Self > ( ) ;
2616
2616
let ( slf, suffix) = Ptr :: from_mut ( bytes)
@@ -2679,7 +2679,7 @@ pub unsafe trait FromBytes: FromZeros {
2679
2679
bytes : & mut [ u8 ] ,
2680
2680
) -> Result < ( & mut [ u8 ] , & mut Self ) , CastError < & mut [ u8 ] , Self > >
2681
2681
where
2682
- Self : IntoBytes + KnownLayout + Immutable ,
2682
+ Self : IntoBytes + KnownLayout ,
2683
2683
{
2684
2684
util:: assert_dst_is_not_zst :: < Self > ( ) ;
2685
2685
let ( slf, prefix) = Ptr :: from_mut ( bytes)
@@ -3483,7 +3483,7 @@ pub unsafe trait IntoBytes {
3483
3483
#[ inline( always) ]
3484
3484
fn as_mut_bytes ( & mut self ) -> & mut [ u8 ]
3485
3485
where
3486
- Self : FromBytes + Immutable ,
3486
+ Self : FromBytes ,
3487
3487
{
3488
3488
// Note that this method does not have a `Self: Sized` bound;
3489
3489
// `size_of_val` works for unsized values too.
@@ -3718,7 +3718,7 @@ pub unsafe trait IntoBytes {
3718
3718
#[ inline]
3719
3719
fn as_bytes_mut ( & mut self ) -> & mut [ u8 ]
3720
3720
where
3721
- Self : FromBytes + Immutable ,
3721
+ Self : FromBytes ,
3722
3722
{
3723
3723
self . as_mut_bytes ( )
3724
3724
}
@@ -5076,20 +5076,16 @@ macro_rules! transmute_mut {
5076
5076
struct AssertSrcIsSized <' a, T : :: core:: marker:: Sized >( & ' a T ) ;
5077
5077
struct AssertSrcIsFromBytes <' a, T : ?:: core:: marker:: Sized + $crate:: FromBytes >( & ' a T ) ;
5078
5078
struct AssertSrcIsIntoBytes <' a, T : ?:: core:: marker:: Sized + $crate:: IntoBytes >( & ' a T ) ;
5079
- struct AssertSrcIsImmutable <' a, T : ?:: core:: marker:: Sized + $crate:: Immutable >( & ' a T ) ;
5080
5079
struct AssertDstIsSized <' a, T : :: core:: marker:: Sized >( & ' a T ) ;
5081
5080
struct AssertDstIsFromBytes <' a, T : ?:: core:: marker:: Sized + $crate:: FromBytes >( & ' a T ) ;
5082
5081
struct AssertDstIsIntoBytes <' a, T : ?:: core:: marker:: Sized + $crate:: IntoBytes >( & ' a T ) ;
5083
- struct AssertDstIsImmutable <' a, T : ?:: core:: marker:: Sized + $crate:: Immutable >( & ' a T ) ;
5084
5082
5085
5083
if true {
5086
5084
let _ = AssertSrcIsSized ( & * e) ;
5087
5085
} else if true {
5088
5086
let _ = AssertSrcIsFromBytes ( & * e) ;
5089
- } else if true {
5090
- let _ = AssertSrcIsIntoBytes ( & * e) ;
5091
5087
} else {
5092
- let _ = AssertSrcIsImmutable ( & * e) ;
5088
+ let _ = AssertSrcIsIntoBytes ( & * e) ;
5093
5089
}
5094
5090
5095
5091
if true {
@@ -5100,13 +5096,9 @@ macro_rules! transmute_mut {
5100
5096
#[ allow( unused, unreachable_code) ]
5101
5097
let u = AssertDstIsFromBytes ( loop { } ) ;
5102
5098
& mut * u. 0
5103
- } else if true {
5104
- #[ allow( unused, unreachable_code) ]
5105
- let u = AssertDstIsIntoBytes ( loop { } ) ;
5106
- & mut * u. 0
5107
5099
} else {
5108
5100
#[ allow( unused, unreachable_code) ]
5109
- let u = AssertDstIsImmutable ( loop { } ) ;
5101
+ let u = AssertDstIsIntoBytes ( loop { } ) ;
5110
5102
& mut * u. 0
5111
5103
}
5112
5104
} else if false {
@@ -5129,11 +5121,6 @@ macro_rules! transmute_mut {
5129
5121
& mut u
5130
5122
} else {
5131
5123
// SAFETY: For source type `Src` and destination type `Dst`:
5132
- // - We know that `Src: FromBytes + IntoBytes + Immutable` and `Dst:
5133
- // FromBytes + IntoBytes + Immutable` thanks to the uses of
5134
- // `AssertSrcIsFromBytes`, `AssertSrcIsIntoBytes`,
5135
- // `AssertSrcIsImmutable`, `AssertDstIsFromBytes`,
5136
- // `AssertDstIsIntoBytes`, and `AssertDstIsImmutable` above.
5137
5124
// - We know that `size_of::<Src>() == size_of::<Dst>()` thanks to
5138
5125
// the use of `assert_size_eq!` above.
5139
5126
// - We know that `align_of::<Src>() >= align_of::<Dst>()` thanks to
0 commit comments