File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -40,19 +40,8 @@ impl_is_zero!(char, |x| x == '\0');
4040impl_is_zero ! ( f32 , |x: f32 | x. to_bits( ) == 0 ) ;
4141impl_is_zero ! ( f64 , |x: f64 | x. to_bits( ) == 0 ) ;
4242
43- unsafe impl < T > IsZero for * const T {
44- #[ inline]
45- fn is_zero ( & self ) -> bool {
46- ( * self ) . is_null ( )
47- }
48- }
49-
50- unsafe impl < T > IsZero for * mut T {
51- #[ inline]
52- fn is_zero ( & self ) -> bool {
53- ( * self ) . is_null ( )
54- }
55- }
43+ // `IsZero` cannot be soundly implemented for pointers because of provenance
44+ // (see #135338).
5645
5746unsafe impl < T : IsZero , const N : usize > IsZero for [ T ; N ] {
5847 #[ inline]
Original file line number Diff line number Diff line change @@ -2742,3 +2742,13 @@ fn max_swap_remove() {
27422742 let mut v = vec ! [ 0 ] ;
27432743 v. swap_remove ( usize:: MAX ) ;
27442744}
2745+
2746+ // Regression test for #135338
2747+ #[ test]
2748+ fn vec_null_ptr_roundtrip ( ) {
2749+ let ptr = std:: ptr:: from_ref ( & 42 ) ;
2750+ let zero = ptr. with_addr ( 0 ) ;
2751+ let roundtripped = vec ! [ zero; 1 ] . pop ( ) . unwrap ( ) ;
2752+ let new = roundtripped. with_addr ( ptr. addr ( ) ) ;
2753+ unsafe { new. read ( ) } ;
2754+ }
You can’t perform that action at this time.
0 commit comments