@@ -138,14 +138,17 @@ impl Alignment {
138
138
/// #![feature(ptr_mask)]
139
139
/// use std::ptr::{Alignment, NonNull};
140
140
///
141
- /// let one = <NonNull<u8>>::dangling().as_ptr();
142
- /// let four = <NonNull<u32>>::dangling().as_ptr();
141
+ /// #[repr(align(1))] struct Align1(u8);
142
+ /// #[repr(align(2))] struct Align2(u16);
143
+ /// #[repr(align(4))] struct Align4(u32);
144
+ /// let one = <NonNull<Align1>>::dangling().as_ptr();
145
+ /// let two = <NonNull<Align2>>::dangling().as_ptr();
146
+ /// let four = <NonNull<Align4>>::dangling().as_ptr();
143
147
///
144
- /// assert_eq!(four.mask(Alignment::of::<u8>().mask()), four);
145
- /// assert_eq!(four.mask(Alignment::of::<u16>().mask()), four);
146
- /// assert_eq!(four.mask(Alignment::of::<u32>().mask()), four);
147
- /// assert_ne!(four.mask(Alignment::of::<u64>().mask()), four);
148
- /// assert_ne!(one.mask(Alignment::of::<u64>().mask()), one);
148
+ /// assert_eq!(four.mask(Alignment::of::<Align1>().mask()), four);
149
+ /// assert_eq!(four.mask(Alignment::of::<Align2>().mask()), four);
150
+ /// assert_eq!(four.mask(Alignment::of::<Align4>().mask()), four);
151
+ /// assert_ne!(one.mask(Alignment::of::<Align4>().mask()), one);
149
152
/// ```
150
153
#[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
151
154
#[ rustc_const_unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
0 commit comments