@@ -401,9 +401,7 @@ mod _conversions {
401
401
{
402
402
/// Converts a `Ptr` an unaligned `T` into a `Ptr` to an aligned
403
403
/// `Unalign<T>`.
404
- pub ( crate ) fn into_unalign (
405
- self ,
406
- ) -> Ptr < ' a , crate :: Unalign < T > , ( I :: Aliasing , Aligned , I :: Validity ) > {
404
+ pub ( crate ) fn into_unalign ( self ) -> Ptr < ' a , crate :: Unalign < T > , I :: WithAlignment < Aligned > > {
407
405
// SAFETY:
408
406
// - This cast preserves provenance.
409
407
// - This cast preserves address. `Unalign<T>` promises to have the
@@ -421,7 +419,7 @@ mod _conversions {
421
419
// SAFETY: `Unalign<T>` promises to have alignment 1, and so it is
422
420
// trivially aligned.
423
421
let ptr = unsafe { ptr. assume_alignment :: < Aligned > ( ) } ;
424
- ptr
422
+ ptr. unify_invariants ( )
425
423
}
426
424
}
427
425
}
@@ -446,7 +444,7 @@ mod _transitions {
446
444
#[ inline]
447
445
pub ( crate ) fn into_exclusive_or_post_monomorphization_error (
448
446
self ,
449
- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
447
+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
450
448
// NOTE(https://github.com/rust-lang/rust/issues/131625): We do this
451
449
// rather than just having `Aliasing::IS_EXCLUSIVE` have the panic
452
450
// behavior because doing it that way causes rustdoc to fail while
@@ -506,7 +504,7 @@ mod _transitions {
506
504
#[ inline]
507
505
pub ( crate ) const unsafe fn assume_aliasing < A : Aliasing > (
508
506
self ,
509
- ) -> Ptr < ' a , T , ( A , I :: Alignment , I :: Validity ) > {
507
+ ) -> Ptr < ' a , T , I :: WithAliasing < A > > {
510
508
// SAFETY: The caller promises that `self` satisfies the aliasing
511
509
// requirements of `A`.
512
510
unsafe { self . assume_invariants ( ) }
@@ -523,7 +521,7 @@ mod _transitions {
523
521
#[ inline]
524
522
pub ( crate ) const unsafe fn assume_exclusive (
525
523
self ,
526
- ) -> Ptr < ' a , T , ( Exclusive , I :: Alignment , I :: Validity ) > {
524
+ ) -> Ptr < ' a , T , I :: WithAliasing < Exclusive > > {
527
525
// SAFETY: The caller promises that `self` satisfies the aliasing
528
526
// requirements of `Exclusive`.
529
527
unsafe { self . assume_aliasing :: < Exclusive > ( ) }
@@ -539,7 +537,7 @@ mod _transitions {
539
537
#[ inline]
540
538
pub ( crate ) const unsafe fn assume_alignment < A : Alignment > (
541
539
self ,
542
- ) -> Ptr < ' a , T , ( I :: Aliasing , A , I :: Validity ) > {
540
+ ) -> Ptr < ' a , T , I :: WithAlignment < A > > {
543
541
// SAFETY: The caller promises that `self`'s referent is
544
542
// well-aligned for `T` if required by `A` .
545
543
unsafe { self . assume_invariants ( ) }
@@ -549,7 +547,7 @@ mod _transitions {
549
547
/// on success.
550
548
pub ( crate ) fn bikeshed_try_into_aligned (
551
549
self ,
552
- ) -> Result < Ptr < ' a , T , ( I :: Aliasing , Aligned , I :: Validity ) > , AlignmentError < Self , T > >
550
+ ) -> Result < Ptr < ' a , T , I :: WithAlignment < Aligned > > , AlignmentError < Self , T > >
553
551
where
554
552
T : Sized ,
555
553
{
@@ -567,9 +565,7 @@ mod _transitions {
567
565
#[ inline]
568
566
// TODO(#859): Reconsider the name of this method before making it
569
567
// public.
570
- pub ( crate ) const fn bikeshed_recall_aligned (
571
- self ,
572
- ) -> Ptr < ' a , T , ( I :: Aliasing , Aligned , I :: Validity ) >
568
+ pub ( crate ) const fn bikeshed_recall_aligned ( self ) -> Ptr < ' a , T , I :: WithAlignment < Aligned > >
573
569
where
574
570
T : crate :: Unaligned ,
575
571
{
@@ -588,9 +584,7 @@ mod _transitions {
588
584
#[ doc( hidden) ]
589
585
#[ must_use]
590
586
#[ inline]
591
- pub const unsafe fn assume_validity < V : Validity > (
592
- self ,
593
- ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , V ) > {
587
+ pub const unsafe fn assume_validity < V : Validity > ( self ) -> Ptr < ' a , T , I :: WithValidity < V > > {
594
588
// SAFETY: The caller promises that `self`'s referent conforms to
595
589
// the validity requirement of `V`.
596
590
unsafe { self . assume_invariants ( ) }
@@ -605,9 +599,7 @@ mod _transitions {
605
599
#[ doc( hidden) ]
606
600
#[ must_use]
607
601
#[ inline]
608
- pub const unsafe fn assume_initialized (
609
- self ,
610
- ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Initialized ) > {
602
+ pub const unsafe fn assume_initialized ( self ) -> Ptr < ' a , T , I :: WithValidity < Initialized > > {
611
603
// SAFETY: The caller has promised to uphold the safety
612
604
// preconditions.
613
605
unsafe { self . assume_validity :: < Initialized > ( ) }
@@ -622,7 +614,7 @@ mod _transitions {
622
614
#[ doc( hidden) ]
623
615
#[ must_use]
624
616
#[ inline]
625
- pub const unsafe fn assume_valid ( self ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) > {
617
+ pub const unsafe fn assume_valid ( self ) -> Ptr < ' a , T , I :: WithValidity < Valid > > {
626
618
// SAFETY: The caller has promised to uphold the safety
627
619
// preconditions.
628
620
unsafe { self . assume_validity :: < Valid > ( ) }
@@ -634,7 +626,7 @@ mod _transitions {
634
626
#[ inline]
635
627
// TODO(#859): Reconsider the name of this method before making it
636
628
// public.
637
- pub const fn bikeshed_recall_valid ( self ) -> Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) >
629
+ pub const fn bikeshed_recall_valid ( self ) -> Ptr < ' a , T , I :: WithValidity < Valid > >
638
630
where
639
631
T : crate :: FromBytes ,
640
632
I : Invariants < Validity = Initialized > ,
@@ -661,7 +653,7 @@ mod _transitions {
661
653
#[ inline]
662
654
pub ( crate ) fn try_into_valid (
663
655
mut self ,
664
- ) -> Result < Ptr < ' a , T , ( I :: Aliasing , I :: Alignment , Valid ) > , ValidityError < Self , T > >
656
+ ) -> Result < Ptr < ' a , T , I :: WithValidity < Valid > > , ValidityError < Self , T > >
665
657
where
666
658
T : TryFromBytes ,
667
659
I :: Aliasing : Reference ,
@@ -670,7 +662,7 @@ mod _transitions {
670
662
// This call may panic. If that happens, it doesn't cause any soundness
671
663
// issues, as we have not generated any invalid state which we need to
672
664
// fix before returning.
673
- if T :: is_bit_valid ( self . reborrow ( ) . forget_aligned ( ) ) {
665
+ if T :: is_bit_valid ( self . reborrow ( ) . forget_aligned ( ) . unify_invariants ( ) ) {
674
666
// SAFETY: If `T::is_bit_valid`, code may assume that `self`
675
667
// contains a bit-valid instance of `Self`.
676
668
Ok ( unsafe { self . assume_valid ( ) } )
@@ -683,7 +675,7 @@ mod _transitions {
683
675
#[ doc( hidden) ]
684
676
#[ must_use]
685
677
#[ inline]
686
- pub const fn forget_aligned ( self ) -> Ptr < ' a , T , ( I :: Aliasing , Any , I :: Validity ) > {
678
+ pub const fn forget_aligned ( self ) -> Ptr < ' a , T , I :: WithAlignment < Any > > {
687
679
// SAFETY: `Any` is less restrictive than `Aligned`.
688
680
unsafe { self . assume_invariants ( ) }
689
681
}
0 commit comments