@@ -416,9 +416,7 @@ mod _conversions {
416416 {
417417 /// Converts a `Ptr` an unaligned `T` into a `Ptr` to an aligned
418418 /// `Unalign<T>`.
419- pub ( crate ) fn into_unalign (
420- self ,
421- ) -> Ptr < ' a , crate :: Unalign < T > , ( I :: Aliasing , Aligned , I :: Validity ) > {
419+ pub ( crate ) fn into_unalign ( self ) -> Ptr < ' a , crate :: Unalign < T > , I :: WithAlignment < Aligned > > {
422420 // SAFETY:
423421 // - This cast preserves provenance.
424422 // - This cast preserves address. `Unalign<T>` promises to have the
@@ -436,7 +434,7 @@ mod _conversions {
436434 // SAFETY: `Unalign<T>` promises to have alignment 1, and so it is
437435 // trivially aligned.
438436 let ptr = unsafe { ptr. assume_alignment :: < Aligned > ( ) } ;
439- ptr
437+ ptr. unify_invariants ( )
440438 }
441439 }
442440}
@@ -461,7 +459,7 @@ mod _transitions {
461459 #[ inline]
462460 pub ( crate ) fn into_exclusive_or_post_monomorphization_error (
463461 self ,
464- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
462+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
465463 // NOTE(https://github.com/rust-lang/rust/issues/131625): We do this
466464 // rather than just having `Aliasing::IS_EXCLUSIVE` have the panic
467465 // behavior because doing it that way causes rustdoc to fail while
@@ -521,7 +519,7 @@ mod _transitions {
521519 #[ inline]
522520 pub ( crate ) const unsafe fn assume_aliasing < A : Aliasing > (
523521 self ,
524- ) -> Ptr < ' a , T , ( A , I :: Alignment , I :: Validity ) > {
522+ ) -> Ptr < ' a , T , I :: WithAliasing < A > > {
525523 // SAFETY: The caller promises that `self` satisfies the aliasing
526524 // requirements of `A`.
527525 unsafe { self . assume_invariants ( ) }
@@ -538,7 +536,7 @@ mod _transitions {
538536 #[ inline]
539537 pub ( crate ) const unsafe fn assume_exclusive (
540538 self ,
541- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
539+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
542540 // SAFETY: The caller promises that `self` satisfies the aliasing
543541 // requirements of `Exclusive`.
544542 unsafe { self . assume_aliasing :: < Exclusive > ( ) }
@@ -554,7 +552,7 @@ mod _transitions {
554552 #[ inline]
555553 pub ( crate ) const unsafe fn assume_alignment < A : Alignment > (
556554 self ,
557- ) -> Ptr < ' a , T , ( I :: Aliasing , A , I :: Validity ) > {
555+ ) -> Ptr < ' a , T , I :: WithAlignment < A > > {
558556 // SAFETY: The caller promises that `self`'s referent is
559557 // well-aligned for `T` if required by `A` .
560558 unsafe { self . assume_invariants ( ) }
@@ -564,7 +562,7 @@ mod _transitions {
564562 /// on success.
565563 pub ( crate ) fn bikeshed_try_into_aligned (
566564 self ,
567- ) -> Result < Ptr < ' a , T , ( I :: Aliasing , Aligned , I :: Validity ) > , AlignmentError < Self , T > >
565+ ) -> Result < Ptr < ' a , T , I :: WithAlignment < Aligned > > , AlignmentError < Self , T > >
568566 where
569567 T : Sized ,
570568 {
@@ -582,9 +580,7 @@ mod _transitions {
582580 #[ inline]
583581 // TODO(#859): Reconsider the name of this method before making it
584582 // public.
585- pub ( crate ) const fn bikeshed_recall_aligned (
586- self ,
587- ) -> Ptr < ' a , T , ( I :: Aliasing , Aligned , I :: Validity ) >
583+ pub ( crate ) const fn bikeshed_recall_aligned ( self ) -> Ptr < ' a , T , I :: WithAlignment < Aligned > >
588584 where
589585 T : crate :: Unaligned ,
590586 {
@@ -603,9 +599,7 @@ mod _transitions {
603599 #[ doc( hidden) ]
604600 #[ must_use]
605601 #[ inline]
606- pub const unsafe fn assume_validity < V : Validity > (
607- self ,
608- ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , V ) > {
602+ pub const unsafe fn assume_validity < V : Validity > ( self ) -> Ptr < ' a , T , I :: WithValidity < V > > {
609603 // SAFETY: The caller promises that `self`'s referent conforms to
610604 // the validity requirement of `V`.
611605 unsafe { self . assume_invariants ( ) }
@@ -620,9 +614,7 @@ mod _transitions {
620614 #[ doc( hidden) ]
621615 #[ must_use]
622616 #[ inline]
623- pub const unsafe fn assume_initialized (
624- self ,
625- ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Initialized ) > {
617+ pub const unsafe fn assume_initialized ( self ) -> Ptr < ' a , T , I :: WithValidity < Initialized > > {
626618 // SAFETY: The caller has promised to uphold the safety
627619 // preconditions.
628620 unsafe { self . assume_validity :: < Initialized > ( ) }
@@ -637,7 +629,7 @@ mod _transitions {
637629 #[ doc( hidden) ]
638630 #[ must_use]
639631 #[ inline]
640- pub const unsafe fn assume_valid ( self ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) > {
632+ pub const unsafe fn assume_valid ( self ) -> Ptr < ' a , T , I :: WithValidity < Valid > > {
641633 // SAFETY: The caller has promised to uphold the safety
642634 // preconditions.
643635 unsafe { self . assume_validity :: < Valid > ( ) }
@@ -649,7 +641,7 @@ mod _transitions {
649641 #[ inline]
650642 // TODO(#859): Reconsider the name of this method before making it
651643 // public.
652- pub const fn bikeshed_recall_valid ( self ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) >
644+ pub const fn bikeshed_recall_valid ( self ) -> Ptr < ' a , T , I :: WithValidity < Valid > >
653645 where
654646 T : crate :: FromBytes ,
655647 I : Invariants < Validity = Initialized > ,
@@ -676,7 +668,7 @@ mod _transitions {
676668 #[ inline]
677669 pub ( crate ) fn try_into_valid (
678670 mut self ,
679- ) -> Result < Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) > , ValidityError < Self , T > >
671+ ) -> Result < Ptr < ' a , T , I :: WithValidity < Valid > > , ValidityError < Self , T > >
680672 where
681673 T : TryFromBytes ,
682674 I :: Aliasing : Reference ,
@@ -685,7 +677,7 @@ mod _transitions {
685677 // This call may panic. If that happens, it doesn't cause any soundness
686678 // issues, as we have not generated any invalid state which we need to
687679 // fix before returning.
688- if T :: is_bit_valid ( self . reborrow ( ) . forget_aligned ( ) ) {
680+ if T :: is_bit_valid ( self . reborrow ( ) . forget_aligned ( ) . unify_invariants ( ) ) {
689681 // SAFETY: If `T::is_bit_valid`, code may assume that `self`
690682 // contains a bit-valid instance of `Self`.
691683 Ok ( unsafe { self . assume_valid ( ) } )
@@ -698,7 +690,7 @@ mod _transitions {
698690 #[ doc( hidden) ]
699691 #[ must_use]
700692 #[ inline]
701- pub const fn forget_aligned ( self ) -> Ptr < ' a , T , ( I :: Aliasing , Any , I :: Validity ) > {
693+ pub const fn forget_aligned ( self ) -> Ptr < ' a , T , I :: WithAlignment < Any > > {
702694 // SAFETY: `Any` is less restrictive than `Aligned`.
703695 unsafe { self . assume_invariants ( ) }
704696 }
0 commit comments