Skip to content

Commit e51fae5

Browse files
authored
Rollup merge of #137228 - steffahn:one-coerces-to-supertypes-not-subtypes, r=the8472
Fix typo in hidden internal docs of `TrustedRandomAccess` I typoed the coercion direction here 4 years ago; fixing it now
2 parents cf8d342 + d93926c commit e51fae5

File tree

1 file changed

+4
-4
lines changed
  • library/core/src/iter/adapters

1 file changed

+4
-4
lines changed

library/core/src/iter/adapters/zip.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -556,21 +556,21 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
556556
/// * `std::iter::ExactSizeIterator::len`
557557
/// * `std::iter::Iterator::__iterator_get_unchecked`
558558
/// * `std::iter::TrustedRandomAccessNoCoerce::size`
559-
/// 5. If `T` is a subtype of `Self`, then `self` is allowed to be coerced
559+
/// 5. If `Self` is a subtype of `T`, then `self` is allowed to be coerced
560560
/// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already
561561
/// been called, then no methods except for the ones listed under 4. are allowed to be called
562562
/// on the resulting value of type `T`, either. Multiple such coercion steps are allowed.
563563
/// Regarding 2. and 3., the number of times `__iterator_get_unchecked(idx)` or `next_back()` is
564564
/// called on `self` and the resulting value of type `T` (and on further coercion results with
565-
/// sub-subtypes) are added together and their sums must not exceed the specified bounds.
565+
/// super-supertypes) are added together and their sums must not exceed the specified bounds.
566566
///
567567
/// Further, given that these conditions are met, it must guarantee that:
568568
///
569569
/// * It does not change the value returned from `size_hint`
570570
/// * It must be safe to call the methods listed above on `self` after calling
571571
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
572572
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
573-
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
573+
/// * If `Self` is a subtype of `T`, then it must be safe to coerce `self` to `T`.
574574
//
575575
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
576576
// after `__iterator_get_unchecked` is supposed to be allowed.
@@ -580,7 +580,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
580580
pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {}
581581

582582
/// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around
583-
/// coercions to subtypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
583+
/// coercions to supertypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
584584
/// without the requirement that subtypes / supertypes implement `TrustedRandomAccessNoCoerce`.
585585
///
586586
/// This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions.

0 commit comments

Comments
 (0)