Skip to content

Commit

Permalink
Force alignment so this test isn't platform-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed Oct 15, 2023
1 parent 5dda0c9 commit 1d840e2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions library/core/src/ptr/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ impl Alignment {
/// #![feature(ptr_mask)]
/// use std::ptr::{Alignment, NonNull};
///
/// let one = <NonNull<u8>>::dangling().as_ptr();
/// let four = <NonNull<u32>>::dangling().as_ptr();
/// #[repr(align(1))] struct Align1(u8);
/// #[repr(align(2))] struct Align2(u16);
/// #[repr(align(4))] struct Align4(u32);
/// let one = <NonNull<Align1>>::dangling().as_ptr();
/// let two = <NonNull<Align2>>::dangling().as_ptr();
/// let four = <NonNull<Align4>>::dangling().as_ptr();
///
/// assert_eq!(four.mask(Alignment::of::<u8>().mask()), four);
/// assert_eq!(four.mask(Alignment::of::<u16>().mask()), four);
/// assert_eq!(four.mask(Alignment::of::<u32>().mask()), four);
/// assert_ne!(four.mask(Alignment::of::<u64>().mask()), four);
/// assert_ne!(one.mask(Alignment::of::<u64>().mask()), one);
/// assert_eq!(four.mask(Alignment::of::<Align1>().mask()), four);
/// assert_eq!(four.mask(Alignment::of::<Align2>().mask()), four);
/// assert_eq!(four.mask(Alignment::of::<Align4>().mask()), four);
/// assert_ne!(one.mask(Alignment::of::<Align4>().mask()), one);
/// ```
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
Expand Down

0 comments on commit 1d840e2

Please sign in to comment.