Skip to content

Commit 1d840e2

Browse files
committed
Force alignment so this test isn't platform-independent
1 parent 5dda0c9 commit 1d840e2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

library/core/src/ptr/alignment.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,17 @@ impl Alignment {
138138
/// #![feature(ptr_mask)]
139139
/// use std::ptr::{Alignment, NonNull};
140140
///
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();
143147
///
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);
149152
/// ```
150153
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
151154
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]

0 commit comments

Comments
 (0)