@@ -416,9 +416,7 @@ mod _conversions {
416
416
{
417
417
/// Converts a `Ptr` an unaligned `T` into a `Ptr` to an aligned
418
418
/// `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 > > {
422
420
// SAFETY:
423
421
// - This cast preserves provenance.
424
422
// - This cast preserves address. `Unalign<T>` promises to have the
@@ -436,7 +434,7 @@ mod _conversions {
436
434
// SAFETY: `Unalign<T>` promises to have alignment 1, and so it is
437
435
// trivially aligned.
438
436
let ptr = unsafe { ptr. assume_alignment :: < Aligned > ( ) } ;
439
- ptr
437
+ ptr. unify_invariants ( )
440
438
}
441
439
}
442
440
}
@@ -461,7 +459,7 @@ mod _transitions {
461
459
#[ inline]
462
460
pub ( crate ) fn into_exclusive_or_post_monomorphization_error (
463
461
self ,
464
- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
462
+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
465
463
// NOTE(https://github.com/rust-lang/rust/issues/131625): We do this
466
464
// rather than just having `Aliasing::IS_EXCLUSIVE` have the panic
467
465
// behavior because doing it that way causes rustdoc to fail while
@@ -521,7 +519,7 @@ mod _transitions {
521
519
#[ inline]
522
520
pub ( crate ) const unsafe fn assume_aliasing < A : Aliasing > (
523
521
self ,
524
- ) -> Ptr < ' a , T , ( A , I :: Alignment , I :: Validity ) > {
522
+ ) -> Ptr < ' a , T , I :: WithAliasing < A > > {
525
523
// SAFETY: The caller promises that `self` satisfies the aliasing
526
524
// requirements of `A`.
527
525
unsafe { self . assume_invariants ( ) }
@@ -538,7 +536,7 @@ mod _transitions {
538
536
#[ inline]
539
537
pub ( crate ) const unsafe fn assume_exclusive (
540
538
self ,
541
- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
539
+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
542
540
// SAFETY: The caller promises that `self` satisfies the aliasing
543
541
// requirements of `Exclusive`.
544
542
unsafe { self . assume_aliasing :: < Exclusive > ( ) }
@@ -554,7 +552,7 @@ mod _transitions {
554
552
#[ inline]
555
553
pub ( crate ) const unsafe fn assume_alignment < A : Alignment > (
556
554
self ,
557
- ) -> Ptr < ' a , T , ( I :: Aliasing , A , I :: Validity ) > {
555
+ ) -> Ptr < ' a , T , I :: WithAlignment < A > > {
558
556
// SAFETY: The caller promises that `self`'s referent is
559
557
// well-aligned for `T` if required by `A` .
560
558
unsafe { self . assume_invariants ( ) }
@@ -564,7 +562,7 @@ mod _transitions {
564
562
/// on success.
565
563
pub ( crate ) fn bikeshed_try_into_aligned (
566
564
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 > >
568
566
where
569
567
T : Sized ,
570
568
{
@@ -582,9 +580,7 @@ mod _transitions {
582
580
#[ inline]
583
581
// TODO(#859): Reconsider the name of this method before making it
584
582
// 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 > >
588
584
where
589
585
T : crate :: Unaligned ,
590
586
{
@@ -603,9 +599,7 @@ mod _transitions {
603
599
#[ doc( hidden) ]
604
600
#[ must_use]
605
601
#[ 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 > > {
609
603
// SAFETY: The caller promises that `self`'s referent conforms to
610
604
// the validity requirement of `V`.
611
605
unsafe { self . assume_invariants ( ) }
@@ -620,9 +614,7 @@ mod _transitions {
620
614
#[ doc( hidden) ]
621
615
#[ must_use]
622
616
#[ 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 > > {
626
618
// SAFETY: The caller has promised to uphold the safety
627
619
// preconditions.
628
620
unsafe { self . assume_validity :: < Initialized > ( ) }
@@ -637,7 +629,7 @@ mod _transitions {
637
629
#[ doc( hidden) ]
638
630
#[ must_use]
639
631
#[ 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 > > {
641
633
// SAFETY: The caller has promised to uphold the safety
642
634
// preconditions.
643
635
unsafe { self . assume_validity :: < Valid > ( ) }
@@ -649,7 +641,7 @@ mod _transitions {
649
641
#[ inline]
650
642
// TODO(#859): Reconsider the name of this method before making it
651
643
// 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 > >
653
645
where
654
646
T : crate :: FromBytes ,
655
647
I : Invariants < Validity = Initialized > ,
@@ -676,7 +668,7 @@ mod _transitions {
676
668
#[ inline]
677
669
pub ( crate ) fn try_into_valid (
678
670
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 > >
680
672
where
681
673
T : TryFromBytes ,
682
674
I :: Aliasing : Reference ,
@@ -685,7 +677,7 @@ mod _transitions {
685
677
// This call may panic. If that happens, it doesn't cause any soundness
686
678
// issues, as we have not generated any invalid state which we need to
687
679
// 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 ( ) ) {
689
681
// SAFETY: If `T::is_bit_valid`, code may assume that `self`
690
682
// contains a bit-valid instance of `Self`.
691
683
Ok ( unsafe { self . assume_valid ( ) } )
@@ -698,7 +690,7 @@ mod _transitions {
698
690
#[ doc( hidden) ]
699
691
#[ must_use]
700
692
#[ 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 > > {
702
694
// SAFETY: `Any` is less restrictive than `Aligned`.
703
695
unsafe { self . assume_invariants ( ) }
704
696
}
0 commit comments