1
Fork 0

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
This commit is contained in:
Matthias Krüger 2025-02-19 01:30:14 +01:00 committed by GitHub
commit e51fae58da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -556,13 +556,13 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
/// * `std::iter::ExactSizeIterator::len` /// * `std::iter::ExactSizeIterator::len`
/// * `std::iter::Iterator::__iterator_get_unchecked` /// * `std::iter::Iterator::__iterator_get_unchecked`
/// * `std::iter::TrustedRandomAccessNoCoerce::size` /// * `std::iter::TrustedRandomAccessNoCoerce::size`
/// 5. If `T` is a subtype of `Self`, then `self` is allowed to be coerced /// 5. If `Self` is a subtype of `T`, then `self` is allowed to be coerced
/// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already /// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already
/// been called, then no methods except for the ones listed under 4. are allowed to be called /// been called, then no methods except for the ones listed under 4. are allowed to be called
/// on the resulting value of type `T`, either. Multiple such coercion steps are allowed. /// on the resulting value of type `T`, either. Multiple such coercion steps are allowed.
/// Regarding 2. and 3., the number of times `__iterator_get_unchecked(idx)` or `next_back()` is /// Regarding 2. and 3., the number of times `__iterator_get_unchecked(idx)` or `next_back()` is
/// called on `self` and the resulting value of type `T` (and on further coercion results with /// called on `self` and the resulting value of type `T` (and on further coercion results with
/// sub-subtypes) are added together and their sums must not exceed the specified bounds. /// super-supertypes) are added together and their sums must not exceed the specified bounds.
/// ///
/// Further, given that these conditions are met, it must guarantee that: /// Further, given that these conditions are met, it must guarantee that:
/// ///
@ -570,7 +570,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
/// * It must be safe to call the methods listed above on `self` after calling /// * It must be safe to call the methods listed above on `self` after calling
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented. /// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`. /// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`. /// * If `Self` is a subtype of `T`, then it must be safe to coerce `self` to `T`.
// //
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner` // FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
// after `__iterator_get_unchecked` is supposed to be allowed. // after `__iterator_get_unchecked` is supposed to be allowed.
@ -580,7 +580,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {} pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {}
/// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around /// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around
/// coercions to subtypes after `__iterator_get_unchecked` (they arent allowed here!), and /// coercions to supertypes after `__iterator_get_unchecked` (they arent allowed here!), and
/// without the requirement that subtypes / supertypes implement `TrustedRandomAccessNoCoerce`. /// without the requirement that subtypes / supertypes implement `TrustedRandomAccessNoCoerce`.
/// ///
/// This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions. /// This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions.