@@ -707,6 +707,8 @@ impl_known_layout!(
707
707
T : ?Sized => PhantomData <T >,
708
708
T => Wrapping <T >,
709
709
T => MaybeUninit <T >,
710
+ T : ?Sized => * const T ,
711
+ T : ?Sized => * mut T ,
710
712
) ;
711
713
impl_known_layout ! ( const N : usize , T => [ T ; N ] ) ;
712
714
@@ -1865,6 +1867,22 @@ safety_comment! {
1865
1867
unsafe_impl!( T : AsBytes => AsBytes for [ T ] ) ;
1866
1868
unsafe_impl!( T : Unaligned => Unaligned for [ T ] ) ;
1867
1869
}
1870
+ safety_comment ! {
1871
+ /// SAFETY:
1872
+ /// - `FromZeroes`: For thin pointers (note that `T: Sized`), the zero
1873
+ /// pointer is considered "null". [1] No operations which require
1874
+ /// provenance are legal on null pointers, so this is not a footgun.
1875
+ ///
1876
+ /// NOTE(#170): Implementing `FromBytes` and `AsBytes` for raw pointers
1877
+ /// would be sound, but carries provenance footguns. We want to support
1878
+ /// `FromBytes` and `AsBytes` for raw pointers eventually, but we are
1879
+ /// holding off until we can figure out how to address those footguns.
1880
+ ///
1881
+ /// [1] TODO(https://github.com/rust-lang/rust/pull/116988): Cite the
1882
+ /// documentation once this PR lands.
1883
+ unsafe_impl!( T => FromZeroes for * const T ) ;
1884
+ unsafe_impl!( T => FromZeroes for * mut T ) ;
1885
+ }
1868
1886
1869
1887
// SIMD support
1870
1888
//
@@ -5384,6 +5402,13 @@ mod tests {
5384
5402
assert_impls ! ( [ u8 ; 1 ] : KnownLayout , FromZeroes , FromBytes , AsBytes , Unaligned ) ;
5385
5403
assert_impls ! ( [ NotZerocopy ; 1 ] : KnownLayout , !FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5386
5404
5405
+ assert_impls ! ( * const NotZerocopy : KnownLayout , FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5406
+ assert_impls ! ( * mut NotZerocopy : KnownLayout , FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5407
+ assert_impls ! ( * const [ NotZerocopy ] : KnownLayout , !FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5408
+ assert_impls ! ( * mut [ NotZerocopy ] : KnownLayout , !FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5409
+ assert_impls ! ( * const dyn Debug : KnownLayout , !FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5410
+ assert_impls ! ( * mut dyn Debug : KnownLayout , !FromZeroes , !FromBytes , !AsBytes , !Unaligned ) ;
5411
+
5387
5412
#[ cfg( feature = "simd" ) ]
5388
5413
{
5389
5414
#[ allow( unused_macros) ]
0 commit comments