From d580df6551c682766fc261da58726b786c43090e Mon Sep 17 00:00:00 2001 From: ltdk Date: Tue, 6 Oct 2026 10:31:19 -0400 Subject: [PATCH 1/2] Add unsafe attributes and impls to tidy unsafety check --- library/alloc/src/alloc.rs | 4 ++++ library/alloc/src/borrow.rs | 3 +++ library/alloc/src/boxed.rs | 6 +++++- library/alloc/src/boxed/iter.rs | 1 + library/alloc/src/boxed/thin.rs | 4 ++-- library/alloc/src/bstr.rs | 1 + library/alloc/src/collections/binary_heap/mod.rs | 6 ++++++ library/alloc/src/rcs/arc.rs | 4 ++-- library/alloc/src/rcs/rc.rs | 4 ++-- library/alloc/src/string.rs | 1 + library/alloc/src/vec/is_zero.rs | 7 +++++++ library/core/src/any.rs | 5 +++-- library/core/src/char/mod.rs | 6 +++--- library/core/src/io/error.rs | 8 ++++---- library/core/src/io/error/repr_bitpacked.rs | 3 ++- library/core/src/iter/adapters/chain.rs | 2 ++ library/core/src/iter/sources/empty.rs | 1 + library/core/src/marker.rs | 13 +++++++++++-- library/core/src/mem/manually_drop.rs | 1 + library/core/src/mem/maybe_uninit.rs | 4 ++-- library/core/src/mem/mod.rs | 1 + library/core/src/num/nonzero.rs | 9 ++++++++- library/core/src/option.rs | 6 ++++++ library/core/src/panic/location.rs | 2 ++ library/core/src/pat.rs | 2 ++ library/core/src/pin.rs | 10 +++++++--- library/core/src/ptr/non_null.rs | 1 + library/core/src/result.rs | 3 +++ library/core/src/sync/atomic.rs | 5 +++++ library/core/src/sync/sync_view.rs | 2 +- library/core/src/tuple.rs | 6 ++---- library/core/src/wtf8.rs | 1 + src/tools/tidy/src/style.rs | 5 ++++- 33 files changed, 106 insertions(+), 31 deletions(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 06bc8a589e1fc..45ce19f15d7a7 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -86,9 +86,11 @@ unsafe extern "Rust" { pub struct Global; #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// SAFETY: All clones of `Global` refer to the same global allocator. unsafe impl core::alloc::AllocatorClone for Global {} #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// SAFETY: `Global` allocations remain active unless deallocated. unsafe impl core::alloc::StaticAllocator for Global {} /// Allocates memory with the global allocator. @@ -568,6 +570,8 @@ impl Global { #[stable(feature = "allocator_api", since = "1.100.0")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +// SAFETY: The specific requirements of `Allocator` are too much to explain here, +// but we do cover all of them for `Global`. const unsafe impl Allocator for Global { #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index b6a7a1eae2a70..c3a5f93cc2dd6 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -359,12 +359,15 @@ impl Deref for Cow<'_, B> // `str` (`String as Borrow` is trusted) and `[T]` (`Vec as Borrow<[T]>` is trusted). // In the future, a `BorrowPure` trait analogous to `DerefPure` might generalize this. #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: This falls back to the `&T as Borrow` implementation, which we can trust to be stable. unsafe impl DerefPure for Cow<'_, T> {} #[cfg(not(no_global_oom_handling))] #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: This falls back to the `&String as Borrow` implementation, which we can trust to be stable. unsafe impl DerefPure for Cow<'_, str> {} #[cfg(not(no_global_oom_handling))] #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: This falls back to the `&Vec as Borrow<[T]>` implementation, which we can trust to be stable. unsafe impl DerefPure for Cow<'_, [T]> {} #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 6477858f14b83..69dc0da635f59 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1974,6 +1974,7 @@ impl Box { } #[stable(feature = "rust1", since = "1.0.0")] +// SAFETY: We explicitly do not read the `T` inside the `Box` when dropping. unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box { #[inline] fn drop(&mut self) { @@ -2301,6 +2302,7 @@ impl DerefMut for Box { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: We always return the address of the allocated pointer, which is stable. unsafe impl DerefPure for Box {} #[unstable(feature = "legacy_receiver_trait", issue = "none")] @@ -2361,6 +2363,8 @@ impl + ?Sized, A: Allocator> AsyncFn for Box #[unstable(feature = "coerce_unsized", issue = "18598")] impl, U: ?Sized, A: Allocator> CoerceUnsized> for Box {} +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// SAFETY: // A pointer can only be pin safe if it does not implement certain safe traits // maliciously. Since `Box` is fundamental, downstream crates may be able to // implement those traits for `Box`, so we must carefully check that @@ -2380,7 +2384,6 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> fo // `Clone` for `Box`, it is not problematic for the cloned box to be // wrapped in `Pin`, since the same conversion could have been carried out // safely as `Box::pin((*p).clone())`. -#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinSafePointer for Box {} // It is quite crucial that we only allow the `Global` allocator here. @@ -2491,6 +2494,7 @@ impl Error for Box { } #[stable(feature = "allocator_api", since = "1.100.0")] +// SAFETY: This just forwards to the inner allocator, whose implementation must be correct. unsafe impl Allocator for Box { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { diff --git a/library/alloc/src/boxed/iter.rs b/library/alloc/src/boxed/iter.rs index f0eccf107cade..03a08a7952e64 100644 --- a/library/alloc/src/boxed/iter.rs +++ b/library/alloc/src/boxed/iter.rs @@ -317,6 +317,7 @@ impl ExactSizeIterator for BoxedArrayIntoIter FusedIterator for BoxedArrayIntoIter {} #[stable(feature = "boxed_array_value_iter", since = "1.99.0")] +// SAFETY: We just forward to `vec::IntoIter`, which has a trustable length. unsafe impl TrustedLen for BoxedArrayIntoIter {} #[cfg(not(no_global_oom_handling))] diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 90bb2ef9b838c..e04ef384bd63a 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -42,12 +42,12 @@ pub struct ThinBox { _marker: PhantomData, } -/// `ThinBox` is `Send` if `T` is `Send` because the data is owned. #[unstable(feature = "thin_box", issue = "92791")] +// SAFETY: `ThinBox` is `Send` if `T` is `Send` because the data is owned. unsafe impl Send for ThinBox {} -/// `ThinBox` is `Sync` if `T` is `Sync` because the data is owned. #[unstable(feature = "thin_box", issue = "92791")] +// SAFETY: `ThinBox` is `Sync` if `T` is `Sync` because the data is owned. unsafe impl Sync for ThinBox {} #[unstable(feature = "thin_box", issue = "92791")] diff --git a/library/alloc/src/bstr.rs b/library/alloc/src/bstr.rs index 59909ed1db9b2..c6a273b352b86 100644 --- a/library/alloc/src/bstr.rs +++ b/library/alloc/src/bstr.rs @@ -101,6 +101,7 @@ impl DerefMut for ByteString { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: This type just wraps `Vec`, whose `Deref` implementation is stable. unsafe impl DerefPure for ByteString {} #[unstable(feature = "bstr", issue = "134915")] diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index f3698a997c925..318b08ed5656a 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -1748,6 +1748,7 @@ impl FusedIterator for IntoIter {} #[doc(hidden)] #[unstable(issue = "none", feature = "trusted_fused")] +// SAFETY: We just forward to `vec::IntoIter`, which is always fused. unsafe impl TrustedFused for IntoIter {} #[stable(feature = "default_iters", since = "1.70.0")] @@ -1768,6 +1769,7 @@ impl Default for IntoIter { // also refer to the vec::in_place_collect module documentation to get an overview #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for IntoIter { type Source = IntoIter; @@ -1779,12 +1781,14 @@ unsafe impl SourceIter for IntoIter { #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for IntoIter { const EXPAND_BY: Option> = NonZero::new(1); const MERGE_BY: Option> = NonZero::new(1); } #[cfg(not(test))] +// SAFETY: We don't mutate the contained data when returning it. unsafe impl AsVecIntoIter for IntoIter { type Item = I; @@ -1834,6 +1838,7 @@ impl ExactSizeIterator for IntoIterSorted {} impl FusedIterator for IntoIterSorted {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: We just forward to `vec::IntoIter`, which has a trustable length. unsafe impl TrustedLen for IntoIterSorted {} /// A draining iterator over the elements of a `BinaryHeap`. @@ -1960,6 +1965,7 @@ impl ExactSizeIterator for DrainSorted<'_, T, A> {} impl FusedIterator for DrainSorted<'_, T, A> {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: The length of the underlying heap is always correct. unsafe impl TrustedLen for DrainSorted<'_, T, A> {} #[stable(feature = "binary_heap_extras_15", since = "1.5.0")] diff --git a/library/alloc/src/rcs/arc.rs b/library/alloc/src/rcs/arc.rs index ffa848998e9a2..6c06ee3c95bc0 100644 --- a/library/alloc/src/rcs/arc.rs +++ b/library/alloc/src/rcs/arc.rs @@ -288,8 +288,8 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> fo #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U: ?Sized> DispatchFromDyn> for Arc {} -// SAFETY: `Arc::clone` doesn't access any `Cell`s which could contain the `Arc` being cloned. #[unstable(feature = "cell_get_cloned", issue = "145329")] +// SAFETY: `Arc::clone` doesn't access any `Cell`s which could contain the `Arc` being cloned. unsafe impl CloneFromCell for Arc {} impl Arc { @@ -371,8 +371,8 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> f #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U: ?Sized> DispatchFromDyn> for Weak {} -// SAFETY: `Weak::clone` doesn't access any `Cell`s which could contain the `Weak` being cloned. #[unstable(feature = "cell_get_cloned", issue = "145329")] +// SAFETY: `Weak::clone` doesn't access any `Cell`s which could contain the `Weak` being cloned. unsafe impl CloneFromCell for Weak {} #[stable(feature = "arc_weak", since = "1.4.0")] diff --git a/library/alloc/src/rcs/rc.rs b/library/alloc/src/rcs/rc.rs index dd5c9e0013b95..17382a57c0dd2 100644 --- a/library/alloc/src/rcs/rc.rs +++ b/library/alloc/src/rcs/rc.rs @@ -353,8 +353,8 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> for #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U: ?Sized> DispatchFromDyn> for Rc {} -// SAFETY: `Rc::clone` doesn't access any `Cell`s which could contain the `Rc` being cloned. #[unstable(feature = "cell_get_cloned", issue = "145329")] +// SAFETY: `Rc::clone` doesn't access any `Cell`s which could contain the `Rc` being cloned. unsafe impl CloneFromCell for Rc {} impl Rc { @@ -3374,8 +3374,8 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> f #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U: ?Sized> DispatchFromDyn> for Weak {} -// SAFETY: `Weak::clone` doesn't access any `Cell`s which could contain the `Weak` being cloned. #[unstable(feature = "cell_get_cloned", issue = "145329")] +// SAFETY: `Weak::clone` doesn't access any `Cell`s which could contain the `Weak` being cloned. unsafe impl CloneFromCell for Weak {} impl Weak { diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 03c07b15712bb..d2ee31cd80daa 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2904,6 +2904,7 @@ impl ops::Deref for String { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: We return a stable index for deref. unsafe impl ops::DerefPure for String {} #[stable(feature = "derefmut_for_string", since = "1.3.0")] diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs index bd016ef3ba283..b5f969f2e8a4d 100644 --- a/library/alloc/src/vec/is_zero.rs +++ b/library/alloc/src/vec/is_zero.rs @@ -149,6 +149,7 @@ impl_is_zero_option_of_nonzero_int!(u8, u16, u32, u64, u128, usize, i8, i16, i32 macro_rules! impl_is_zero_option_of_int { ($($t:ty),+ $(,)?) => {$( + // SAFETY: All-zeroes is a valid bitpattern for these primitives, and we explicitly verify that `None` uses a zero discriminant. unsafe impl IsZero for Option<$t> { #[inline] fn is_zero(&self) -> bool { @@ -165,6 +166,7 @@ macro_rules! impl_is_zero_option_of_int { impl_is_zero_option_of_int!(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, usize, isize); +// SAFETY: This is a transparent wrapper. unsafe impl IsZero for Wrapping { #[inline] fn is_zero(&self) -> bool { @@ -172,6 +174,7 @@ unsafe impl IsZero for Wrapping { } } +// SAFETY: This is a transparent wrapper. unsafe impl IsZero for Saturating { #[inline] fn is_zero(&self) -> bool { @@ -181,9 +184,13 @@ unsafe impl IsZero for Saturating { macro_rules! impl_is_zero_option_of_bool { ($($t:ty),+ $(,)?) => {$( + // SAFETY: Due to the abundant niche space, zero is always `Some(false)`. unsafe impl IsZero for $t { #[inline] fn is_zero(&self) -> bool { + const { + assert!(size_of::<$t>() == 1); + } // SAFETY: This is *not* a stable layout guarantee, but // inside `core` we're allowed to rely on the current rustc // behavior that options of bools will be one byte with diff --git a/library/core/src/any.rs b/library/core/src/any.rs index c6cb5b0f50c56..eed2b05376b7b 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -731,11 +731,12 @@ pub struct TypeId { pub(crate) data: [*const (); 16 / size_of::<*const ()>()], } -// SAFETY: the raw pointer is always an integer #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Send for TypeId {} // SAFETY: the raw pointer is always an integer +unsafe impl Send for TypeId {} + #[stable(feature = "rust1", since = "1.0.0")] +// SAFETY: the raw pointer is always an integer unsafe impl Sync for TypeId {} #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/char/mod.rs b/library/core/src/char/mod.rs index 28bd0929c1141..98d663a679536 100644 --- a/library/core/src/char/mod.rs +++ b/library/core/src/char/mod.rs @@ -448,20 +448,20 @@ macro_rules! casemappingiter_impls { } } - // SAFETY: forwards to inner `array::IntoIter` #[unstable(feature = "trusted_len", issue = "37572")] + // SAFETY: forwards to inner `array::IntoIter` unsafe impl TrustedLen for $ITER_NAME {} - // SAFETY: forwards to inner `array::IntoIter` #[doc(hidden)] #[unstable(feature = "std_internals", issue = "none")] + // SAFETY: forwards to inner `array::IntoIter` unsafe impl TrustedRandomAccessNoCoerce for $ITER_NAME { const MAY_HAVE_SIDE_EFFECT: bool = false; } - // SAFETY: this iter has no subtypes/supertypes #[doc(hidden)] #[unstable(feature = "std_internals", issue = "none")] + // SAFETY: this iter has no subtypes/supertypes unsafe impl TrustedRandomAccess for $ITER_NAME {} #[$displaystab] diff --git a/library/core/src/io/error.rs b/library/core/src/io/error.rs index c0de8822b456b..d8d0c638c1b76 100644 --- a/library/core/src/io/error.rs +++ b/library/core/src/io/error.rs @@ -594,12 +594,12 @@ pub struct Custom { outer_drop: unsafe fn(NonNull), } -// SAFETY: All members of `Custom` are `Send` #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] +// SAFETY: All members of `Custom` are `Send` or only used in the destructor. unsafe impl Send for Custom {} -// SAFETY: All members of `Custom` are `Sync` #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] +// SAFETY: All members of `Custom` are `Sync` or only used in the destructor. unsafe impl Sync for Custom {} #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] @@ -668,12 +668,12 @@ impl Custom { #[doc(hidden)] pub struct CustomOwner(NonNull); -// SAFETY: Custom is `Send` #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] +// SAFETY: Custom is `Send`. unsafe impl Send for CustomOwner {} -// SAFETY: Custom is `Sync` #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] +// SAFETY: Custom is `Sync`. unsafe impl Sync for CustomOwner {} #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] diff --git a/library/core/src/io/error/repr_bitpacked.rs b/library/core/src/io/error/repr_bitpacked.rs index 7b1c2b6902010..0ece21c434794 100644 --- a/library/core/src/io/error/repr_bitpacked.rs +++ b/library/core/src/io/error/repr_bitpacked.rs @@ -128,8 +128,9 @@ const TAG_SIMPLE: usize = 0b11; #[rustc_insignificant_dtor] pub(super) struct Repr(NonNull<()>, PhantomData>); -// All the types `Repr` stores internally are Send + Sync, and so is it. +// SAFETY: All the types `Repr` stores internally are `Send`, and so is it. unsafe impl Send for Repr {} +// SAFETY: All the types `Repr` stores internally are `Sync`, and so is it. unsafe impl Sync for Repr {} impl Repr { diff --git a/library/core/src/iter/adapters/chain.rs b/library/core/src/iter/adapters/chain.rs index d143b67fd4353..4eed939bcf9ac 100644 --- a/library/core/src/iter/adapters/chain.rs +++ b/library/core/src/iter/adapters/chain.rs @@ -297,6 +297,8 @@ where } #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: If we trust one length, and we trust the other length, +// then their powers combined are trustworthy. unsafe impl TrustedLen for Chain where A: TrustedLen, diff --git a/library/core/src/iter/sources/empty.rs b/library/core/src/iter/sources/empty.rs index 7733c2babc550..b901460722ead 100644 --- a/library/core/src/iter/sources/empty.rs +++ b/library/core/src/iter/sources/empty.rs @@ -64,6 +64,7 @@ impl ExactSizeIterator for Empty { } #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: Sure looks empty to me, boss. unsafe impl TrustedLen for Empty {} #[stable(feature = "fused", since = "1.26.0")] diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 530af0c3af656..ee01c85df1ed8 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -60,6 +60,8 @@ macro marker_impls { ( $(#[$($meta:tt)*])* $Trait:ident for ) => {}, ( $(#[$($meta:tt)*])* unsafe $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => { + // SAFETY: see safety comments on macro calls. + // FIXME: unsafe macro calls $(#[$($meta)*])* unsafe impl< $($($bounds)*)? > $Trait for $T {} marker_impls! { $(#[$($meta)*])* unsafe $Trait for $($($rest)*)? } }, @@ -98,10 +100,10 @@ impl !Send for *const T {} #[stable(feature = "rust1", since = "1.0.0")] impl !Send for *mut T {} -// Most instances arise automatically, but this instance is needed to link up `T: Sync` with +#[stable(feature = "rust1", since = "1.0.0")] +// SAFETY: Most instances arise automatically, but this instance is needed to link up `T: Sync` with // `&T: Send` (and it also removes the unsound default instance `T Send` -> `&T: Send` that would // otherwise exist). -#[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for &T {} /// Types with a constant size known at compile time. @@ -852,6 +854,7 @@ impl Clone for PhantomData { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] +// SAFETY: We can trivially clone nothing. unsafe impl TrivialClone for PhantomData {} #[stable(feature = "rust1", since = "1.0.0")] @@ -907,6 +910,9 @@ pub unsafe auto trait Freeze {} #[unstable(feature = "freeze", issue = "121675")] impl !Freeze for UnsafeCell {} + +// SAFETY: Pointers, by themselves, are not interior-mutable. +// And nothing is also immutable. marker_impls! { #[unstable(feature = "freeze", issue = "121675")] unsafe Freeze for @@ -929,6 +935,9 @@ pub unsafe auto trait UnsafeUnpin {} #[unstable(feature = "unsafe_unpin", issue = "125735")] impl !UnsafeUnpin for UnsafePinned {} + +// SAFETY: Any indirection ensures that `UnsafeUnpin` is safe to implement. +// Nothing (`PhantomData`), also, pins just fine. marker_impls! { #[unstable(feature = "unsafe_unpin", issue = "125735")] unsafe UnsafeUnpin for diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs index 3fb844c7c2927..37dadd6e195ac 100644 --- a/library/core/src/mem/manually_drop.rs +++ b/library/core/src/mem/manually_drop.rs @@ -282,4 +282,5 @@ const impl DerefMut for ManuallyDrop { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: `ManuallyDrop` has a trivial, and thus pure, `Deref` impl. unsafe impl DerefPure for ManuallyDrop {} diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 94703940baa1f..c175d64f1fb43 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -366,10 +366,10 @@ impl Clone for MaybeUninit { } } -// SAFETY: the clone implementation is a copy, see above. #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] -unsafe impl TrivialClone for MaybeUninit where MaybeUninit: Clone {} +// SAFETY: The `Copy` implementation makes this trivially correct. +unsafe impl TrivialClone for MaybeUninit {} #[stable(feature = "maybe_uninit_debug", since = "1.41.0")] impl fmt::Debug for MaybeUninit { diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index a22e52f3a3bc7..c7ec43b741ca2 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -1299,6 +1299,7 @@ impl clone::Clone for Discriminant { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] +// SAFETY: `DiscriminantKind::Discriminant` is `Copy`, which is `TrivialClone`. unsafe impl TrivialClone for Discriminant {} #[stable(feature = "discriminant_value", since = "1.21.0")] diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index c97e6f4c45395..5cf84955f27b2 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -44,6 +44,8 @@ macro_rules! impl_zeroable_primitive { reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] + // SAFETY: see safety comments on macro calls. + // FIXME: unsafe macro calls unsafe impl ZeroablePrimitive for $primitive { type NonZeroInner = super::niche_types::$NonZeroInner; } @@ -51,6 +53,7 @@ macro_rules! impl_zeroable_primitive { }; } +// SAFETY: All of these types use pattern types which disallow zero. impl_zeroable_primitive!( NonZeroU8Inner(u8), NonZeroU16Inner(u16), @@ -150,6 +153,8 @@ impl_nonzero_fmt! { macro_rules! impl_nonzero_auto_trait { (unsafe $Trait:ident) => { #[stable(feature = "nonzero", since = "1.28.0")] + // SAFETY: see safety comments on macro calls. + // FIXME: unsafe macro calls unsafe impl $Trait for NonZero where T: ZeroablePrimitive + $Trait {} }; ($Trait:ident) => { @@ -158,8 +163,9 @@ macro_rules! impl_nonzero_auto_trait { }; } -// Implement auto-traits manually based on `T` to avoid docs exposing +// We implement auto-traits manually based on `T` to avoid docs exposing // the `ZeroablePrimitive::NonZeroInner` implementation detail. +// SAFETY: The underlying pattern types are primitives, which are `Freeze`, `Send`, and `Sync`. impl_nonzero_auto_trait!(unsafe Freeze); impl_nonzero_auto_trait!(RefUnwindSafe); impl_nonzero_auto_trait!(unsafe Send); @@ -188,6 +194,7 @@ impl Copy for NonZero where T: ZeroablePrimitive {} #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] +// SAFETY: The underlying types are all trivially cloneable primitives. const unsafe impl TrivialClone for NonZero where T: ZeroablePrimitive {} #[stable(feature = "nonzero", since = "1.28.0")] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index f53eb4a294194..4603003577ae9 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2297,6 +2297,7 @@ impl crate::clone::UseCloned for Option where T: crate::clone::UseCloned { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] +// SAFETY: Enum discriminants are always trivially cloneable. const unsafe impl TrivialClone for Option where T: [const] TrivialClone + [const] Destruct {} #[stable(feature = "rust1", since = "1.0.0")] @@ -2522,6 +2523,7 @@ impl ExactSizeIterator for Item { } } impl FusedIterator for Item {} +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for Item {} /// An iterator over a reference to the [`Some`] variant of an [`Option`]. @@ -2564,6 +2566,7 @@ impl ExactSizeIterator for Iter<'_, A> {} impl FusedIterator for Iter<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -2613,6 +2616,7 @@ impl ExactSizeIterator for IterMut<'_, A> {} #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for IterMut<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in [`Some`] variant of an [`Option`]. @@ -2657,6 +2661,7 @@ impl FusedIterator for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] #[rustc_const_unstable(feature = "const_iter", issue = "92476")] +// SAFETY: An extremely trivial, trustable length. const unsafe impl TrustedLen for IntoIter {} /// The iterator produced by [`Option::into_flat_iter`]. See its documentation for more. @@ -2786,6 +2791,7 @@ impl ExactSizeIterator for OptionFlatten {} impl FusedIterator for OptionFlatten {} #[unstable(feature = "option_into_flat_iter", issue = "148441")] +// SAFETY: We forward to the inner iterator, whose length is trustworthy. unsafe impl TrustedLen for OptionFlatten {} ///////////////////////////////////////////////////////////////////////////// diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 43fbda2adf476..51919c2c22d23 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -308,6 +308,8 @@ impl fmt::Display for Location<'_> { } #[stable(feature = "panic_hooks", since = "1.10.0")] +// SAFETY: Immutable data is trivially `Send`. unsafe impl Send for Location<'_> {} #[stable(feature = "panic_hooks", since = "1.10.0")] +// SAFETY: Immutable data is trivially `Sync`. unsafe impl Sync for Location<'_> {} diff --git a/library/core/src/pat.rs b/library/core/src/pat.rs index 0cf9f10fc8c28..53c60765edc1d 100644 --- a/library/core/src/pat.rs +++ b/library/core/src/pat.rs @@ -86,6 +86,8 @@ impl, U> DispatchFromDyn for pa impl Unpin for pattern_type!(*const T is !null) {} +// SAFETY: Restricting the value of a pointer does not give it mutability powers. unsafe impl Freeze for pattern_type!(*const T is !null) {} +// SAFETY: Restricting the value of a pointer does not give it mutability powers. unsafe impl Freeze for pattern_type!(*mut T is !null) {} diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 58e63ff04af15..e6905fa9265c1 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1780,6 +1780,7 @@ where } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// SAFETY: The `Deref` implementation is a direct call to a pure deref impl, and thus is pure. unsafe impl DerefPure for Pin {} #[unstable(feature = "legacy_receiver_trait", issue = "none")] @@ -1898,6 +1899,8 @@ where /// [`Arc::get_mut`]: ../../std/sync/struct.Arc.html#method.get_mut "Arc::get_mut" pub unsafe trait PinSafePointer: Deref + Sized {} +#[stable(feature = "pin", since = "1.33.0")] +// SAFETY: // A pointer can only be pin safe if it does not implement certain safe traits // maliciously. Since `&T` is fundamental, downstream crates may be able to // implement those traits for `&LocalType`, so we must carefully check that @@ -1914,9 +1917,10 @@ pub unsafe trait PinSafePointer: Deref + Sized {} // `&LocalType` as long as `LocalType` does not implement said trait. However, // the existence of an `&&T` cannot be treated as evidence that the `T` is not // pinned, so this is not problematic. -#[stable(feature = "pin", since = "1.33.0")] unsafe impl<'a, T: ?Sized> PinSafePointer for &'a T {} +#[stable(feature = "pin", since = "1.33.0")] +// SAFETY: // A pointer can only be pin safe if it does not implement certain safe traits // maliciously. Since `&mut T` is fundamental, downstream crates may be able to // implement those traits for `&mut LocalType`, so we must carefully check that @@ -1933,9 +1937,10 @@ unsafe impl<'a, T: ?Sized> PinSafePointer for &'a T {} // for `&mut LocalType` as long as `LocalType` does not implement said trait. // However, the existence of an `&&mut T` cannot be treated as evidence that the // `T` is not pinned, so this is not problematic. -#[stable(feature = "pin", since = "1.33.0")] unsafe impl<'a, T: ?Sized> PinSafePointer for &'a mut T {} +#[stable(feature = "pin", since = "1.33.0")] +// SAFETY: // A pointer can only be pin safe if it does not implement certain safe traits // maliciously. `Pin` implements these traits by forwarding to `P`, which also // asserts that these implementations are not malicious, so the implementations @@ -1967,7 +1972,6 @@ unsafe impl<'a, T: ?Sized> PinSafePointer for &'a mut T {} // given that the implementation of `Clone` returned a `Pin

`, we know that // the target value is pinned, so this conversion is okay even if `Clone` was // implemented for `Pin

` by a downstream crate. -#[stable(feature = "pin", since = "1.33.0")] unsafe impl PinSafePointer for Pin

{} /// Constructs a [Pin]<[&mut] T>, by pinning a `value: T` locally. diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index a279c373dea4a..750795f88f434 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1630,6 +1630,7 @@ impl Copy for NonNull {} #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] +// SAFETY: Pointers are trivially cloneable regardless of value limitations. unsafe impl TrivialClone for NonNull {} #[unstable(feature = "coerce_unsized", issue = "18598")] diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 9d898df3c6d3c..ed7c76b111203 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -2005,6 +2005,7 @@ impl ExactSizeIterator for Iter<'_, T> {} impl FusedIterator for Iter<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -2054,6 +2055,7 @@ impl ExactSizeIterator for IterMut<'_, T> {} impl FusedIterator for IterMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in a [`Ok`] variant of a [`Result`]. @@ -2100,6 +2102,7 @@ impl ExactSizeIterator for IntoIter {} impl FusedIterator for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] +// SAFETY: An extremely trivial, trustable length. unsafe impl TrustedLen for IntoIter {} ///////////////////////////////////////////////////////////////////////////// diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 14e33019a45ff..7f9794c852ed2 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -304,6 +304,8 @@ macro impl_atomic_primitive { issue = "none" )] #[cfg($cfg)] + // SAFETY: see macro call safety. + // FIXME: unsafe macro calls unsafe impl $(<$T>)? AtomicPrimitive for $Primitive { type Storage = private::$Storage<$Operand>; } @@ -331,6 +333,7 @@ macro impl_atomic_primitive { }, } +// SAFETY: We explicitly gate atomics based upon whether platforms support them. impl_atomic_primitive!([] bool as Align1, size("8")); impl_atomic_primitive!([] i8 as Align1, size("8")); impl_atomic_primitive!([] u8 as Align1, size("8")); @@ -386,8 +389,10 @@ pub struct Atomic { } #[stable(feature = "rust1", since = "1.0.0")] +// SAFETY: Atomics explicitly synchronize their operations. unsafe impl Send for Atomic {} #[stable(feature = "rust1", since = "1.0.0")] +// SAFETY: Atomics explicitly synchronize their operations. unsafe impl Sync for Atomic {} // Some architectures don't have byte-sized atomics, which results in LLVM diff --git a/library/core/src/sync/sync_view.rs b/library/core/src/sync/sync_view.rs index 5c1e24125cf74..69b5270522b76 100644 --- a/library/core/src/sync/sync_view.rs +++ b/library/core/src/sync/sync_view.rs @@ -102,8 +102,8 @@ pub struct SyncView { inner: T, } -// See `SyncView`'s docs for justification. #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +// SAFETY: See `SyncView`'s docs for justification. unsafe impl Sync for SyncView {} #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] diff --git a/library/core/src/tuple.rs b/library/core/src/tuple.rs index 6dd26d3ed762d..daad22ce9cc2e 100644 --- a/library/core/src/tuple.rs +++ b/library/core/src/tuple.rs @@ -159,11 +159,9 @@ macro_rules! tuple_impls { maybe_tuple_doc! { $($T)+ @ - // SAFETY: tuples introduce no additional indirection, so they can be copied whenever T - // can. #[unstable(feature = "cell_get_cloned", issue = "145329")] - unsafe impl<$($T: CloneFromCell),+> CloneFromCell for ($($T,)+) - {} + // SAFETY: tuples introduce no additional indirection, so they can be copied whenever T can. + unsafe impl<$($T: CloneFromCell),+> CloneFromCell for ($($T,)+) {} } } } diff --git a/library/core/src/wtf8.rs b/library/core/src/wtf8.rs index bcfbd2609bf12..a8578063a4543 100644 --- a/library/core/src/wtf8.rs +++ b/library/core/src/wtf8.rs @@ -653,6 +653,7 @@ impl Hash for Wtf8 { } #[unstable(feature = "clone_to_uninit", issue = "126799")] +// SAFETY: We always initialize the [`Wtf8`] slice. unsafe impl CloneToUninit for Wtf8 { #[inline] #[cfg_attr(debug_assertions, track_caller)] diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 6d8a6371f89e3..ec507c9f1fb00 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -551,7 +551,10 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con } // Only check core & alloc for now; to be expanded to (parts of) // std in the future as well. - if trimmed.contains("unsafe {") + if (trimmed.contains("unsafe {") + || trimmed.contains("#[unsafe(") + || trimmed.contains("#![unsafe(") + || trimmed.contains("unsafe impl")) && !trimmed.starts_with("//") && !last_safety_comment && !is_test From bc54a4b6786f7305ba15332eac96e455ff236ecc Mon Sep 17 00:00:00 2001 From: ltdk Date: Wed, 7 Oct 2026 16:26:12 -0400 Subject: [PATCH 2/2] Untriaged changes --- library/alloc/src/collections/btree/borrow.rs | 2 + library/alloc/src/collections/btree/map.rs | 9 ++++ library/alloc/src/collections/btree/node.rs | 6 +++ library/alloc/src/collections/btree/set.rs | 2 + library/alloc/src/collections/linked_list.rs | 14 ++++++ .../alloc/src/collections/vec_deque/drain.rs | 2 + .../src/collections/vec_deque/into_iter.rs | 1 + .../alloc/src/collections/vec_deque/iter.rs | 3 ++ .../src/collections/vec_deque/iter_mut.rs | 3 ++ .../alloc/src/collections/vec_deque/mod.rs | 1 + library/alloc/src/raw_vec/mod.rs | 3 ++ library/alloc/src/rcs/arc.rs | 17 +++++++ library/alloc/src/rcs/rc.rs | 10 ++++ library/alloc/src/string.rs | 2 + library/alloc/src/vec/drain.rs | 3 ++ library/alloc/src/vec/into_iter.rs | 10 ++++ library/alloc/src/vec/is_zero.rs | 7 +++ library/alloc/src/vec/mod.rs | 2 + library/core/src/alloc/global.rs | 1 + library/core/src/alloc/mod.rs | 6 +++ library/core/src/array/iter.rs | 3 ++ library/core/src/array/mod.rs | 1 + library/core/src/bstr/mod.rs | 1 + library/core/src/bstr/traits.rs | 3 ++ library/core/src/cell.rs | 14 ++++++ library/core/src/clone.rs | 10 ++++ library/core/src/clone/uninit.rs | 2 + library/core/src/cmp/bytewise.rs | 1 + library/core/src/error.rs | 1 + library/core/src/ffi/c_str.rs | 2 + library/core/src/ffi/va_list.rs | 15 ++++++ library/core/src/future/mod.rs | 2 + library/core/src/index.rs | 12 +++++ library/core/src/intrinsics/bounds.rs | 9 ++++ library/core/src/io/io_slice.rs | 4 ++ .../core/src/iter/adapters/array_chunks.rs | 3 ++ library/core/src/iter/adapters/cloned.rs | 5 ++ library/core/src/iter/adapters/copied.rs | 5 ++ library/core/src/iter/adapters/enumerate.rs | 6 +++ library/core/src/iter/adapters/filter.rs | 3 ++ library/core/src/iter/adapters/filter_map.rs | 3 ++ library/core/src/iter/adapters/flatten.rs | 7 +++ library/core/src/iter/adapters/fuse.rs | 3 ++ library/core/src/iter/adapters/inspect.rs | 3 ++ library/core/src/iter/adapters/map.rs | 6 +++ library/core/src/iter/adapters/map_while.rs | 2 + library/core/src/iter/adapters/mod.rs | 2 + library/core/src/iter/adapters/peekable.rs | 2 + library/core/src/iter/adapters/rev.rs | 1 + library/core/src/iter/adapters/scan.rs | 2 + library/core/src/iter/adapters/skip.rs | 6 +++ library/core/src/iter/adapters/skip_while.rs | 3 ++ library/core/src/iter/adapters/step_by.rs | 5 ++ library/core/src/iter/adapters/take.rs | 4 ++ library/core/src/iter/adapters/take_while.rs | 3 ++ library/core/src/iter/adapters/zip.rs | 8 ++++ library/core/src/iter/range.rs | 6 +++ library/core/src/iter/sources/once.rs | 1 + library/core/src/iter/sources/once_with.rs | 1 + library/core/src/iter/sources/repeat.rs | 1 + library/core/src/iter/sources/repeat_n.rs | 1 + library/core/src/iter/sources/repeat_with.rs | 1 + library/core/src/iter/traits/marker.rs | 4 ++ library/core/src/marker/variance.rs | 1 + library/core/src/ops/deref.rs | 2 + library/core/src/pin/unsafe_pinned.rs | 1 + library/core/src/ptr/metadata.rs | 3 ++ library/core/src/ptr/unique.rs | 3 ++ library/core/src/range/iter.rs | 5 ++ library/core/src/slice/cmp.rs | 5 ++ library/core/src/slice/index.rs | 13 ++++++ library/core/src/slice/iter.rs | 46 +++++++++++++++++++ library/core/src/slice/iter/macros.rs | 1 + library/core/src/str/iter.rs | 3 ++ library/core/src/str/pattern.rs | 14 ++++++ library/core/src/str/traits.rs | 11 +++++ library/core/src/sync/sync_view.rs | 1 + library/core/src/task/wake.rs | 2 + 78 files changed, 392 insertions(+) diff --git a/library/alloc/src/collections/btree/borrow.rs b/library/alloc/src/collections/btree/borrow.rs index e848ac3f2d192..69be8f2c887ff 100644 --- a/library/alloc/src/collections/btree/borrow.rs +++ b/library/alloc/src/collections/btree/borrow.rs @@ -16,7 +16,9 @@ pub(super) struct DormantMutRef<'a, T> { _marker: PhantomData<&'a mut T>, } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> Sync for DormantMutRef<'a, T> where &'a mut T: Sync {} +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> Send for DormantMutRef<'a, T> where &'a mut T: Send {} impl<'a, T> DormantMutRef<'a, T> { diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 109beed7de947..63dd10b09f0c0 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -203,6 +203,7 @@ pub struct BTreeMap< } #[stable(feature = "btree_drop", since = "1.7.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] K, #[may_dangle] V, A: AllocatorClone> Drop for BTreeMap { fn drop(&mut self) { // Skip `into_iter` for an empty map: `dying_next` is too costly to inline, so the @@ -1799,6 +1800,7 @@ impl ExactSizeIterator for Iter<'_, K, V> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Iter<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -1876,6 +1878,7 @@ impl ExactSizeIterator for IterMut<'_, K, V> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IterMut<'_, K, V> {} #[stable(feature = "fused", since = "1.26.0")] @@ -2004,6 +2007,7 @@ impl ExactSizeIterator for IntoIter { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} #[stable(feature = "fused", since = "1.26.0")] @@ -2055,6 +2059,7 @@ impl ExactSizeIterator for Keys<'_, K, V> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Keys<'_, K, V> {} #[stable(feature = "fused", since = "1.26.0")] @@ -2113,6 +2118,7 @@ impl ExactSizeIterator for Values<'_, K, V> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Values<'_, K, V> {} #[stable(feature = "fused", since = "1.26.0")] @@ -2358,6 +2364,7 @@ impl ExactSizeIterator for ValuesMut<'_, K, V> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ValuesMut<'_, K, V> {} #[stable(feature = "fused", since = "1.26.0")] @@ -2423,6 +2430,7 @@ impl ExactSizeIterator for IntoKeys { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoKeys {} #[stable(feature = "map_into_keys_values", since = "1.54.0")] @@ -2477,6 +2485,7 @@ impl ExactSizeIterator for IntoValues { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoValues {} #[stable(feature = "map_into_keys_values", since = "1.54.0")] diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 47c3fb1d79c9d..bc64fe175b825 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -211,12 +211,18 @@ impl<'a, K: 'a, V: 'a, Type> Clone for NodeRef, K, V, Type> { } } +// ignore-tidy-undocumented-unsafe unsafe impl Sync for NodeRef {} +// ignore-tidy-undocumented-unsafe unsafe impl Send for NodeRef, K, V, Type> {} +// ignore-tidy-undocumented-unsafe unsafe impl Send for NodeRef, K, V, Type> {} +// ignore-tidy-undocumented-unsafe unsafe impl Send for NodeRef, K, V, Type> {} +// ignore-tidy-undocumented-unsafe unsafe impl Send for NodeRef {} +// ignore-tidy-undocumented-unsafe unsafe impl Send for NodeRef {} impl NodeRef { diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 2a17b0b4c43f9..6c56cfcc3d791 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1803,6 +1803,7 @@ impl ExactSizeIterator for Iter<'_, T> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Iter<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] @@ -1850,6 +1851,7 @@ impl ExactSizeIterator for IntoIter { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} #[stable(feature = "fused", since = "1.26.0")] diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 3acf4e6b18e16..0ee7fedaac636 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1190,6 +1190,7 @@ impl LinkedList { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T, A: Allocator> Drop for LinkedList { fn drop(&mut self) { struct DropGuard<'a, T, A: Allocator>(&'a mut LinkedList); @@ -1268,6 +1269,7 @@ impl ExactSizeIterator for Iter<'_, T> {} impl FusedIterator for Iter<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Iter<'_, T> {} #[stable(feature = "default_iters", since = "1.70.0")] @@ -1343,6 +1345,7 @@ impl ExactSizeIterator for IterMut<'_, T> {} impl FusedIterator for IterMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IterMut<'_, T> {} #[stable(feature = "default_iters", since = "1.70.0")] @@ -2082,6 +2085,7 @@ impl ExactSizeIterator for IntoIter {} impl FusedIterator for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} #[stable(feature = "default_iters", since = "1.70.0")] @@ -2283,31 +2287,41 @@ fn assert_covariance() { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for LinkedList {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for LinkedList {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for IterMut<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for IterMut<'_, T> {} #[unstable(feature = "linked_list_cursors", issue = "58533")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Cursor<'_, T, A> {} #[unstable(feature = "linked_list_cursors", issue = "58533")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Cursor<'_, T, A> {} #[unstable(feature = "linked_list_cursors", issue = "58533")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for CursorMut<'_, T, A> {} #[unstable(feature = "linked_list_cursors", issue = "58533")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for CursorMut<'_, T, A> {} diff --git a/library/alloc/src/collections/vec_deque/drain.rs b/library/alloc/src/collections/vec_deque/drain.rs index 38d540ab08040..11093b3b61543 100644 --- a/library/alloc/src/collections/vec_deque/drain.rs +++ b/library/alloc/src/collections/vec_deque/drain.rs @@ -87,8 +87,10 @@ impl fmt::Debug for Drain<'_, T, A> { } #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Drain<'_, T, A> {} #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Drain<'_, T, A> {} #[stable(feature = "drain", since = "1.6.0")] diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 7cac57421ac5e..e3867104c987f 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -258,4 +258,5 @@ impl ExactSizeIterator for IntoIter { impl FusedIterator for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} diff --git a/library/alloc/src/collections/vec_deque/iter.rs b/library/alloc/src/collections/vec_deque/iter.rs index 7794fb450d776..48c1e6f323d72 100644 --- a/library/alloc/src/collections/vec_deque/iter.rs +++ b/library/alloc/src/collections/vec_deque/iter.rs @@ -219,14 +219,17 @@ impl ExactSizeIterator for Iter<'_, T> { impl FusedIterator for Iter<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Iter<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Iter<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Iter<'_, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/alloc/src/collections/vec_deque/iter_mut.rs b/library/alloc/src/collections/vec_deque/iter_mut.rs index 9d7b99d765fac..e33c7d82d0d5f 100644 --- a/library/alloc/src/collections/vec_deque/iter_mut.rs +++ b/library/alloc/src/collections/vec_deque/iter_mut.rs @@ -283,14 +283,17 @@ impl ExactSizeIterator for IterMut<'_, T> { impl FusedIterator for IterMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IterMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for IterMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for IterMut<'_, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 8e4507c6fd0aa..b686f398cdce8 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -147,6 +147,7 @@ impl Drop for Dropper<'_, T> { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T, A: Allocator> Drop for VecDeque { fn drop(&mut self) { let (front, back) = self.as_mut_slices(); diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index 2f284bb4229eb..119892d984e90 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -99,7 +99,9 @@ struct RawVecInner { } // FIXME: Consider moving these impls to `RawVec`, once #162850 is resolved. +// ignore-tidy-undocumented-unsafe unsafe impl Send for RawVecInner {} +// ignore-tidy-undocumented-unsafe unsafe impl Sync for RawVecInner {} impl UnwindSafe for RawVecInner {} @@ -436,6 +438,7 @@ impl RawVec { } #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +// ignore-tidy-undocumented-unsafe const unsafe impl<#[may_dangle] T, A: [const] Allocator + [const] Destruct> Drop for RawVec { /// Frees the memory owned by the `RawVec` *without* trying to drop its contents. fn drop(&mut self) { diff --git a/library/alloc/src/rcs/arc.rs b/library/alloc/src/rcs/arc.rs index 6c06ee3c95bc0..4a2798f549800 100644 --- a/library/alloc/src/rcs/arc.rs +++ b/library/alloc/src/rcs/arc.rs @@ -272,8 +272,10 @@ pub struct Arc< } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Arc {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Arc {} #[stable(feature = "catch_unwind", since = "1.9.0")] @@ -362,8 +364,10 @@ pub struct Weak< } #[stable(feature = "arc_weak", since = "1.4.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Weak {} #[stable(feature = "arc_weak", since = "1.4.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Weak {} #[unstable(feature = "coerce_unsized", issue = "18598")] @@ -416,7 +420,9 @@ fn arcinner_layout_for_value_layout(layout: Layout) -> Layout { .pad_to_align() } +// ignore-tidy-undocumented-unsafe unsafe impl Send for ArcInner {} +// ignore-tidy-undocumented-unsafe unsafe impl Sync for ArcInner {} impl Arc { @@ -2571,9 +2577,11 @@ impl Deref for Arc { // crates cannot provide malicious implementations of any of the traits relevant // for `Pin`. #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl PinSafePointer for Arc {} #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for Arc {} #[unstable(feature = "legacy_receiver_trait", issue = "none")] @@ -2943,6 +2951,7 @@ impl Arc { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Arc { /// Drops the `Arc`. /// @@ -3619,6 +3628,7 @@ impl Default for Weak { } #[stable(feature = "arc_weak", since = "1.4.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Weak { /// Drops the `Weak` pointer. /// @@ -4544,9 +4554,11 @@ pub struct UniqueArc< } #[unstable(feature = "unique_rc_arc", issue = "112566")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] @@ -5118,6 +5130,7 @@ impl Deref for UniqueArc { // #[unstable(feature = "unique_rc_arc", issue = "112566")] #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl PinSafePointer for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] @@ -5135,9 +5148,11 @@ impl DerefMut for UniqueArc { #[unstable(feature = "unique_rc_arc", issue = "112566")] // #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for UniqueArc { fn drop(&mut self) { // See `Arc::drop_slow` which drops an `Arc` with a strong count of 0. @@ -5150,6 +5165,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for UniqueArc { } #[stable(feature = "allocator_api", since = "1.100.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Allocator for Arc { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { @@ -5205,4 +5221,5 @@ unsafe impl Allocator for Arc { impl AllocatorNightly for Arc {} #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// ignore-tidy-undocumented-unsafe unsafe impl AllocatorClone for Arc {} diff --git a/library/alloc/src/rcs/rc.rs b/library/alloc/src/rcs/rc.rs index 17382a57c0dd2..34f783f8a0cfc 100644 --- a/library/alloc/src/rcs/rc.rs +++ b/library/alloc/src/rcs/rc.rs @@ -2598,23 +2598,28 @@ impl Deref for Rc { // accordingly. Since this type is not fundamental, downstream crates cannot // provide malicious implementations of any of the traits relevant for `Pin`. #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl PinSafePointer for Rc {} //#[unstable(feature = "unique_rc_arc", issue = "112566")] #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl PinSafePointer for UniqueRc {} #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for Rc {} //#[unstable(feature = "unique_rc_arc", issue = "112566")] #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for UniqueRc {} #[unstable(feature = "legacy_receiver_trait", issue = "none")] impl LegacyReceiver for Rc {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Rc { /// Drops the `Rc`. /// @@ -2771,6 +2776,7 @@ impl RcEqIdent for Rc { } // Hack to allow specializing on `Eq` even though `Eq` has a method. +// ignore-tidy-undocumented-unsafe #[unsafe(rustc_allow_lifetime_dependent_specialization)] pub(crate) trait MarkerEq: PartialEq {} @@ -3812,6 +3818,7 @@ impl Weak { } #[stable(feature = "rc_weak", since = "1.4.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Weak { /// Drops the `Weak` pointer. /// @@ -4693,6 +4700,7 @@ impl DerefMut for UniqueRc { } #[unstable(feature = "unique_rc_arc", issue = "112566")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for UniqueRc { fn drop(&mut self) { // ignore-tidy-undocumented-unsafe @@ -4791,6 +4799,7 @@ impl Drop for UniqueRcUninit { } #[stable(feature = "allocator_api", since = "1.100.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Allocator for Rc { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { @@ -4846,4 +4855,5 @@ unsafe impl Allocator for Rc { impl AllocatorNightly for Rc {} #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// ignore-tidy-undocumented-unsafe unsafe impl AllocatorClone for Rc {} diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d2ee31cd80daa..bc842a0d52034 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -3585,8 +3585,10 @@ impl fmt::Debug for Drain<'_> { } #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Drain<'_> {} #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Drain<'_> {} #[stable(feature = "drain", since = "1.6.0")] diff --git a/library/alloc/src/vec/drain.rs b/library/alloc/src/vec/drain.rs index a4059db012c63..1393cf2d8724e 100644 --- a/library/alloc/src/vec/drain.rs +++ b/library/alloc/src/vec/drain.rs @@ -145,8 +145,10 @@ impl<'a, T, A: Allocator> AsRef<[T]> for Drain<'a, T, A> { } #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Drain<'_, T, A> {} #[stable(feature = "drain", since = "1.6.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Drain<'_, T, A> {} #[stable(feature = "drain", since = "1.6.0")] @@ -253,6 +255,7 @@ impl ExactSizeIterator for Drain<'_, T, A> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Drain<'_, T, A> {} #[stable(feature = "fused", since = "1.26.0")] diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 48b1db0d5bf49..648ffaeb21452 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -257,8 +257,10 @@ impl AsRef<[T]> for IntoIter { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")] @@ -548,9 +550,11 @@ impl FusedIterator for IntoIter {} #[doc(hidden)] #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} #[stable(feature = "default_iters", since = "1.70.0")] @@ -573,6 +577,7 @@ where #[doc(hidden)] #[unstable(issue = "none", feature = "std_internals")] +// ignore-tidy-undocumented-unsafe #[unsafe(rustc_allow_lifetime_dependent_specialization)] trait NonDrop {} @@ -585,6 +590,7 @@ impl NonDrop for T {} #[unstable(issue = "none", feature = "std_internals")] // TrustedRandomAccess (without NoCoerce) must not be implemented because // subtypes/supertypes of `T` might not be `NonDrop` +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for IntoIter where T: NonDrop, @@ -601,6 +607,7 @@ impl Clone for IntoIter { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter { fn drop(&mut self) { struct DropGuard<'a, T, A: Allocator>(&'a mut IntoIter); @@ -628,6 +635,7 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter { // also refer to the vec::in_place_collect module documentation to get an overview #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for IntoIter { const EXPAND_BY: Option> = NonZero::new(1); const MERGE_BY: Option> = NonZero::new(1); @@ -635,6 +643,7 @@ unsafe impl InPlaceIterable for IntoIter { #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for IntoIter { type Source = Self; @@ -645,6 +654,7 @@ unsafe impl SourceIter for IntoIter { } #[cfg(not(no_global_oom_handling))] +// ignore-tidy-undocumented-unsafe unsafe impl AsVecIntoIter for IntoIter { type Item = T; diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs index b5f969f2e8a4d..a9b87b208591f 100644 --- a/library/alloc/src/vec/is_zero.rs +++ b/library/alloc/src/vec/is_zero.rs @@ -12,6 +12,7 @@ pub(super) unsafe trait IsZero { macro_rules! impl_is_zero { ($t:ty, $is_zero:expr) => { + // ignore-tidy-undocumented-unsafe unsafe impl IsZero for $t { #[inline] fn is_zero(&self) -> bool { @@ -46,6 +47,7 @@ impl_is_zero!(f64, |x: f64| x.to_bits() == 0); // `IsZero` cannot be soundly implemented for pointers because of provenance // (see #135338). +// ignore-tidy-undocumented-unsafe unsafe impl IsZero for [T; N] { #[inline] default fn is_zero(&self) -> bool { @@ -57,6 +59,7 @@ unsafe impl IsZero for [T; N] { } } +// ignore-tidy-undocumented-unsafe unsafe impl IsZero for [T; N] { #[inline] fn is_zero(&self) -> bool { @@ -88,6 +91,7 @@ macro_rules! impl_is_zero_tuples { // We already have an impl for () above. }; ($first_arg:ident $(,$rest:ident)*) => { + // ignore-tidy-undocumented-unsafe unsafe impl <$first_arg: IsZero, $($rest: IsZero,)*> IsZero for ($first_arg, $($rest,)*){ #[inline] fn is_zero(&self) -> bool{ @@ -114,6 +118,7 @@ impl_is_zero_tuples!(A, B, C, D, E, F, G, H); // `Option<&mut T>` never implements `Clone`, so there's no need for an impl of // `SpecFromElem`. +// ignore-tidy-undocumented-unsafe unsafe impl IsZero for Option<&T> { #[inline] fn is_zero(&self) -> bool { @@ -121,6 +126,7 @@ unsafe impl IsZero for Option<&T> { } } +// ignore-tidy-undocumented-unsafe unsafe impl IsZero for Option> { #[inline] fn is_zero(&self) -> bool { @@ -136,6 +142,7 @@ unsafe impl IsZero for Option> { // the only niche available to represent `None` is the one that's all zeros. macro_rules! impl_is_zero_option_of_nonzero_int { ($($t:ty),+ $(,)?) => {$( + // ignore-tidy-undocumented-unsafe unsafe impl IsZero for Option> { #[inline] fn is_zero(&self) -> bool { diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 8bcad62226a0b..5bc7ec2e703a3 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -3894,6 +3894,7 @@ const impl ops::DerefMut for Vec { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl ops::DerefPure for Vec {} #[cfg(not(no_global_oom_handling))] @@ -4383,6 +4384,7 @@ impl Ord for Vec { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +// ignore-tidy-undocumented-unsafe const unsafe impl<#[may_dangle] T: [const] Destruct, A: [const] Allocator + [const] Destruct> Drop for Vec { diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs index e1e08ab7a2cb9..fc7e7c51c5cfc 100644 --- a/library/core/src/alloc/global.rs +++ b/library/core/src/alloc/global.rs @@ -349,6 +349,7 @@ pub unsafe trait GlobalAlloc { /// Allows all [`GlobalAllocator`]s to be used with the legacy [`GlobalAlloc`] interface. #[stable(feature = "global_alloc", since = "1.28.0")] +// ignore-tidy-undocumented-unsafe unsafe impl GlobalAlloc for A where A: GlobalAllocator + ?Sized, diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 5066c0ccc21e7..e05b882bf0b5f 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -576,6 +576,7 @@ pub unsafe trait StaticAllocator: Allocator {} #[stable(feature = "allocator_api", since = "1.100.0")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +// ignore-tidy-undocumented-unsafe const unsafe impl Allocator for &A where A: [const] Allocator + ?Sized, @@ -632,6 +633,7 @@ where #[stable(feature = "allocator_api", since = "1.100.0")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +// ignore-tidy-undocumented-unsafe const unsafe impl Allocator for &mut A where A: [const] Allocator + ?Sized, @@ -689,6 +691,7 @@ where #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] #[unstable_feature_bound(allocator_ext)] +// ignore-tidy-undocumented-unsafe const unsafe impl

Allocator for core::pin::Pin

where P: [const] core::ops::Deref + core::pin::PinSafePointer, @@ -751,14 +754,17 @@ impl

AllocatorNightly for core::pin::Pin

where } #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// ignore-tidy-undocumented-unsafe unsafe impl AllocatorClone for &A {} // If an allocator is `StaticAllocator` all equivalent allocators must also uphold // its semantics, and references are equivalent to the allocator they reference. #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// ignore-tidy-undocumented-unsafe unsafe impl StaticAllocator for &A {} #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +// ignore-tidy-undocumented-unsafe unsafe impl StaticAllocator for &mut A {} /// Allocator marker trait that is only implemented stably for `Global`. diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index 1129e8b6ceb2b..93fda336706cf 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -363,10 +363,12 @@ impl FusedIterator for IntoIter {} // This range is decremented in length in either `next` or `next_back`. It is // always decremented by 1 in those methods, but only if `Some(_)` is returned. #[stable(feature = "array_value_iter_impls", since = "1.40.0")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for IntoIter {} #[doc(hidden)] #[unstable(issue = "none", feature = "std_internals")] +// ignore-tidy-undocumented-unsafe #[unsafe(rustc_allow_lifetime_dependent_specialization)] trait NonDrop {} @@ -377,6 +379,7 @@ impl NonDrop for T {} #[doc(hidden)] #[unstable(issue = "none", feature = "std_internals")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for IntoIter where T: NonDrop, diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index fcd635a03c652..2cd8533f7ab8f 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -475,6 +475,7 @@ impl Clone for [T; N] { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrivialClone for [T; N] {} trait SpecArrayClone: Clone { diff --git a/library/core/src/bstr/mod.rs b/library/core/src/bstr/mod.rs index 0530ddc292a99..b158cce3e08d4 100644 --- a/library/core/src/bstr/mod.rs +++ b/library/core/src/bstr/mod.rs @@ -151,6 +151,7 @@ const impl DerefMut for ByteStr { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for ByteStr {} #[unstable(feature = "bstr", issue = "134915")] diff --git a/library/core/src/bstr/traits.rs b/library/core/src/bstr/traits.rs index 6e9d836f1a1ff..bfe5fbe0f6391 100644 --- a/library/core/src/bstr/traits.rs +++ b/library/core/src/bstr/traits.rs @@ -169,6 +169,7 @@ where } #[unstable(feature = "bstr", issue = "134915")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex for ops::RangeFull { type Output = ByteStr; #[inline] @@ -198,6 +199,7 @@ unsafe impl SliceIndex for ops::RangeFull { } #[unstable(feature = "bstr", issue = "134915")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex for usize { type Output = u8; #[inline] @@ -231,6 +233,7 @@ unsafe impl SliceIndex for usize { macro_rules! impl_slice_index { ($index:ty) => { #[unstable(feature = "bstr", issue = "134915")] + // ignore-tidy-undocumented-unsafe unsafe impl SliceIndex for $index { type Output = ByteStr; #[inline] diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 3dcf033bbd757..22054de4e166e 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -317,6 +317,7 @@ pub struct Cell { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Cell where T: Send {} // Note that this negative impl isn't strictly necessary for correctness, @@ -804,18 +805,25 @@ pub unsafe trait CloneFromCell: Clone {} // `CloneFromCell` can be implemented for types that don't have indirection and which don't access // `Cell`s in their `Clone` implementation. A commonly-used subset is covered here. #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for [T; N] {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for Option {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for Result {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for PhantomData {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for ManuallyDrop {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for ops::Range {} #[unstable(feature = "cell_get_cloned", issue = "145329")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneFromCell for range::Range {} #[unstable(feature = "cell_get_cloned", issue = "145329")] @@ -1436,6 +1444,7 @@ impl RefCell { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for RefCell where T: Send {} #[stable(feature = "rust1", since = "1.0.0")] @@ -1635,6 +1644,7 @@ const impl Deref for Ref<'_, T> { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for Ref<'_, T> {} impl<'b, T: ?Sized> Ref<'b, T> { @@ -2129,6 +2139,7 @@ const impl DerefMut for RefMut<'_, T> { } #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for RefMut<'_, T> {} #[unstable(feature = "coerce_unsized", issue = "18598")] @@ -2608,6 +2619,7 @@ pub struct SyncUnsafeCell { } #[unstable(feature = "sync_unsafe_cell", issue = "95439")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for SyncUnsafeCell {} #[unstable(feature = "sync_unsafe_cell", issue = "95439")] @@ -2713,10 +2725,12 @@ fn assert_coerce_unsized( // user to perform unsizing coercions with `Pin>` pointers if they // can manage to create one. #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl<'b, T: ?Sized> PinSafePointer for Ref<'b, T> {} // The implementations of Deref/DerefMut are not malicious, so we can allow the // user to perform unsizing coercions with `Pin>` pointers if they // can manage to create one. #[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] +// ignore-tidy-undocumented-unsafe unsafe impl<'b, T: ?Sized> PinSafePointer for RefMut<'b, T> {} diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index bd6d929c6d2b0..e8e0fd6f55cc5 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -645,6 +645,7 @@ pub unsafe trait CloneToUninit { } #[unstable(feature = "clone_to_uninit", issue = "126799")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneToUninit for T { #[inline] unsafe fn clone_to_uninit(&self, dest: *mut u8) { @@ -654,6 +655,7 @@ unsafe impl CloneToUninit for T { } #[unstable(feature = "clone_to_uninit", issue = "126799")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneToUninit for [T] { #[inline] #[cfg_attr(debug_assertions, track_caller)] @@ -665,6 +667,7 @@ unsafe impl CloneToUninit for [T] { } #[unstable(feature = "clone_to_uninit", issue = "126799")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneToUninit for str { #[inline] #[cfg_attr(debug_assertions, track_caller)] @@ -675,6 +678,7 @@ unsafe impl CloneToUninit for str { } #[unstable(feature = "clone_to_uninit", issue = "126799")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneToUninit for crate::ffi::CStr { #[cfg_attr(debug_assertions, track_caller)] unsafe fn clone_to_uninit(&self, dest: *mut u8) { @@ -687,6 +691,7 @@ unsafe impl CloneToUninit for crate::ffi::CStr { } #[unstable(feature = "bstr", issue = "134915")] +// ignore-tidy-undocumented-unsafe unsafe impl CloneToUninit for crate::bstr::ByteStr { #[inline] #[cfg_attr(debug_assertions, track_caller)] @@ -720,6 +725,7 @@ mod impls { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] + // ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for $t {} )* } @@ -744,6 +750,7 @@ mod impls { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] + // ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for ! {} #[stable(feature = "rust1", since = "1.0.0")] @@ -758,6 +765,7 @@ mod impls { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] + // ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for *const T {} #[stable(feature = "rust1", since = "1.0.0")] @@ -772,6 +780,7 @@ mod impls { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] + // ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for *mut T {} /// Shared references can be cloned, but mutable references *cannot*! @@ -788,6 +797,7 @@ mod impls { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] + // ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for &T {} #[unstable(feature = "share_trait", issue = "156756")] diff --git a/library/core/src/clone/uninit.rs b/library/core/src/clone/uninit.rs index b6e351fc7c96c..f37eaa23b1727 100644 --- a/library/core/src/clone/uninit.rs +++ b/library/core/src/clone/uninit.rs @@ -9,6 +9,7 @@ pub(super) unsafe trait CopySpec: Clone { unsafe fn clone_slice(src: &[Self], dst: *mut [Self]); } +// ignore-tidy-undocumented-unsafe unsafe impl CopySpec for T { #[inline] default unsafe fn clone_one(src: &Self, dst: *mut Self) { @@ -52,6 +53,7 @@ unsafe impl CopySpec for T { // Specialized implementation for types that are [`TrivialClone`], not just [`Clone`], // and can therefore be copied bitwise. +// ignore-tidy-undocumented-unsafe unsafe impl CopySpec for T { #[inline] unsafe fn clone_one(src: &Self, dst: *mut Self) { diff --git a/library/core/src/cmp/bytewise.rs b/library/core/src/cmp/bytewise.rs index 07e24441cf51d..04fea09fb5d35 100644 --- a/library/core/src/cmp/bytewise.rs +++ b/library/core/src/cmp/bytewise.rs @@ -24,6 +24,7 @@ pub(crate) const unsafe trait BytewiseEq: macro_rules! is_bytewise_comparable { ($($t:ty),+ $(,)?) => {$( + // ignore-tidy-undocumented-unsafe const unsafe impl BytewiseEq for $t {} )+}; } diff --git a/library/core/src/error.rs b/library/core/src/error.rs index 1b640f2d99803..085b1354f82cd 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -1026,6 +1026,7 @@ impl<'a, I: tags::Type<'a>> Tagged> { /// This trait is exclusively implemented by the `TaggedOption` type. unsafe trait Erased<'a>: 'a {} +// ignore-tidy-undocumented-unsafe unsafe impl<'a, I: tags::Type<'a>> Erased<'a> for TaggedOption<'a, I> {} struct Tagged { diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index daa68e885d893..30450fef13e3d 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -799,9 +799,11 @@ pub struct Bytes<'a> { } #[unstable(feature = "cstr_bytes", issue = "112115")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Bytes<'_> {} #[unstable(feature = "cstr_bytes", issue = "112115")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Bytes<'_> {} impl<'a> Bytes<'a> { diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index b308cb7f85df2..28833f8a5dc36 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -319,8 +319,10 @@ crate::cfg_select! { // - i8 is implicitly promoted to c_int in C, and cannot implement `VaArgSafe`. // - u8 is implicitly promoted to c_uint in C, and cannot implement `VaArgSafe`. #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for i16 {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for u16 {} } _ => { @@ -335,6 +337,7 @@ crate::cfg_select! { target_arch = "avr" => { // c_double is f32 on this target. #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for f32 {} } _ => { @@ -345,17 +348,23 @@ crate::cfg_select! { } #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for i32 {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for i64 {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for isize {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for u32 {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for u64 {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for usize {} // Implement `VaArgSafe` for 128-bit integers on targets where clang provides `__int128`. @@ -398,9 +407,11 @@ cfg_select! { ) => { #[unstable_feature_bound(c_variadic_int128)] #[unstable(feature = "c_variadic_int128", issue = "155752")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for i128 {} #[unstable_feature_bound(c_variadic_int128)] #[unstable(feature = "c_variadic_int128", issue = "155752")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for u128 {} } _ => { @@ -414,6 +425,7 @@ cfg_select! { } #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for f64 {} // Implement `VaArgSafe` for f128 on targets where either: @@ -460,14 +472,17 @@ cfg_select! { ) => { #[unstable_feature_bound(f128)] #[unstable(feature = "f128", issue = "116909")] + // ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for f128 {} } _ => { /* unsupported */ } } #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for *mut T {} #[unstable(feature = "c_variadic_va_arg_safe", issue = "162911", implied_by = "c_variadic")] +// ignore-tidy-undocumented-unsafe unsafe impl VaArgSafe for *const T {} // Check that relevant `core::ffi` types implement `VaArgSafe`. diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs index 2b16a568b4031..8940c299b8fdb 100644 --- a/library/core/src/future/mod.rs +++ b/library/core/src/future/mod.rs @@ -51,9 +51,11 @@ pub use self::join::join; pub struct ResumeTy(NonNull>); #[unstable(feature = "gen_future", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for ResumeTy {} #[unstable(feature = "gen_future", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for ResumeTy {} #[lang = "get_context"] diff --git a/library/core/src/index.rs b/library/core/src/index.rs index 70372163c6e17..d794b82f85707 100644 --- a/library/core/src/index.rs +++ b/library/core/src/index.rs @@ -50,6 +50,7 @@ pub struct Clamp(pub Idx); pub struct Last; #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp { type Output = T; @@ -81,6 +82,7 @@ unsafe impl SliceIndex<[T]> for Clamp { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -124,6 +126,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -167,6 +170,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -210,6 +214,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -253,6 +258,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -284,6 +290,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -315,6 +322,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -346,6 +354,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -377,6 +386,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp> { type Output = [T]; @@ -408,6 +418,7 @@ unsafe impl SliceIndex<[T]> for Clamp> { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Clamp { type Output = [T]; @@ -439,6 +450,7 @@ unsafe impl SliceIndex<[T]> for Clamp { } #[unstable(feature = "sliceindex_wrappers", issue = "146179")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for Last { type Output = T; diff --git a/library/core/src/intrinsics/bounds.rs b/library/core/src/intrinsics/bounds.rs index f8ebea7c69522..ba41b6c4e69b5 100644 --- a/library/core/src/intrinsics/bounds.rs +++ b/library/core/src/intrinsics/bounds.rs @@ -11,15 +11,19 @@ pub unsafe trait BuiltinDeref: Sized { type Pointee: PointeeSized; } +// ignore-tidy-undocumented-unsafe unsafe impl BuiltinDeref for &mut T { type Pointee = T; } +// ignore-tidy-undocumented-unsafe unsafe impl BuiltinDeref for &T { type Pointee = T; } +// ignore-tidy-undocumented-unsafe unsafe impl BuiltinDeref for *mut T { type Pointee = T; } +// ignore-tidy-undocumented-unsafe unsafe impl BuiltinDeref for *const T { type Pointee = T; } @@ -53,6 +57,7 @@ pub unsafe trait FloatPrimitive: Sized + Copy { fn from_bits(bits: Self::UInt) -> Self; } +// ignore-tidy-undocumented-unsafe unsafe impl FloatPrimitive for f16 { type UInt = u16; const SIGN_MASK: Self::UInt = f16::SIGN_MASK; @@ -66,6 +71,7 @@ unsafe impl FloatPrimitive for f16 { } } +// ignore-tidy-undocumented-unsafe unsafe impl FloatPrimitive for f32 { type UInt = u32; const SIGN_MASK: Self::UInt = f32::SIGN_MASK; @@ -79,6 +85,7 @@ unsafe impl FloatPrimitive for f32 { } } +// ignore-tidy-undocumented-unsafe unsafe impl FloatPrimitive for f64 { type UInt = u64; const SIGN_MASK: Self::UInt = f64::SIGN_MASK; @@ -92,6 +99,7 @@ unsafe impl FloatPrimitive for f64 { } } +// ignore-tidy-undocumented-unsafe unsafe impl FloatPrimitive for f128 { type UInt = u128; const SIGN_MASK: Self::UInt = f128::SIGN_MASK; @@ -117,6 +125,7 @@ pub const unsafe trait IntegerPrimitive: Copy + [const] Ord {} macro_rules! impl_integer_primitive { ($($t:ty),*) => {$( #[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] + // ignore-tidy-undocumented-unsafe const unsafe impl IntegerPrimitive for $t {} )*}; } diff --git a/library/core/src/io/io_slice.rs b/library/core/src/io/io_slice.rs index 17f4fc4da940a..575d3ec083496 100644 --- a/library/core/src/io/io_slice.rs +++ b/library/core/src/io/io_slice.rs @@ -37,9 +37,11 @@ cfg_select! { pub struct IoSliceMut<'a>(repr::IoSliceMut<'a>); #[stable(feature = "iovec_send_sync", since = "1.44.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a> Send for IoSliceMut<'a> {} #[stable(feature = "iovec_send_sync", since = "1.44.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a> Sync for IoSliceMut<'a> {} #[stable(feature = "iovec", since = "1.36.0")] @@ -195,9 +197,11 @@ impl<'a> DerefMut for IoSliceMut<'a> { pub struct IoSlice<'a>(repr::IoSlice<'a>); #[stable(feature = "iovec_send_sync", since = "1.44.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a> Send for IoSlice<'a> {} #[stable(feature = "iovec_send_sync", since = "1.44.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a> Sync for IoSlice<'a> {} #[stable(feature = "iovec", since = "1.36.0")] diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 6c502ee75e17f..114dfd82f80b3 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -171,6 +171,7 @@ where impl FusedIterator for ArrayChunks where I: FusedIterator {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for ArrayChunks where I: TrustedFused + Iterator {} #[unstable(feature = "iter_array_chunks", issue = "100450")] @@ -245,6 +246,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for ArrayChunks where I: SourceIter + Iterator, @@ -259,6 +261,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for ArrayChunks { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = const { diff --git a/library/core/src/iter/adapters/cloned.rs b/library/core/src/iter/adapters/cloned.rs index c0b6a4053c825..3c93840229141 100644 --- a/library/core/src/iter/adapters/cloned.rs +++ b/library/core/src/iter/adapters/cloned.rs @@ -123,10 +123,12 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Cloned where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Cloned where I: TrustedRandomAccessNoCoerce, @@ -135,6 +137,7 @@ where } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, I, T: 'a> TrustedLen for Cloned where I: TrustedLen, @@ -157,6 +160,7 @@ impl Default for Cloned { } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Cloned where I: SourceIter, @@ -171,6 +175,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Cloned { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/copied.rs b/library/core/src/iter/adapters/copied.rs index ba87fb7216059..1762ee939c743 100644 --- a/library/core/src/iter/adapters/copied.rs +++ b/library/core/src/iter/adapters/copied.rs @@ -165,10 +165,12 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Copied where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Copied where I: TrustedRandomAccessNoCoerce, @@ -177,6 +179,7 @@ where } #[stable(feature = "iter_copied", since = "1.36.0")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, I, T: 'a> TrustedLen for Copied where I: TrustedLen, @@ -261,6 +264,7 @@ impl Default for Copied { } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Copied where I: SourceIter, @@ -275,6 +279,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Copied { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/enumerate.rs b/library/core/src/iter/adapters/enumerate.rs index 916ba88e6160a..12add827c38dd 100644 --- a/library/core/src/iter/adapters/enumerate.rs +++ b/library/core/src/iter/adapters/enumerate.rs @@ -262,10 +262,12 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Enumerate where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Enumerate where I: TrustedRandomAccessNoCoerce, @@ -277,12 +279,15 @@ where impl FusedIterator for Enumerate where I: FusedIterator {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Enumerate {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Enumerate where I: TrustedLen {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Enumerate where I: SourceIter, @@ -297,6 +302,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Enumerate { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/filter.rs b/library/core/src/iter/adapters/filter.rs index cf21536784a28..9866aa3510af0 100644 --- a/library/core/src/iter/adapters/filter.rs +++ b/library/core/src/iter/adapters/filter.rs @@ -199,9 +199,11 @@ where impl FusedIterator for Filter where P: FnMut(&I::Item) -> bool {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Filter {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Filter where I: SourceIter, @@ -216,6 +218,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Filter { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/filter_map.rs b/library/core/src/iter/adapters/filter_map.rs index 3fd7e16d1c148..789e0aebec7fd 100644 --- a/library/core/src/iter/adapters/filter_map.rs +++ b/library/core/src/iter/adapters/filter_map.rs @@ -190,9 +190,11 @@ where impl FusedIterator for FilterMap where F: FnMut(I::Item) -> Option {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for FilterMap {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for FilterMap where I: SourceIter, @@ -207,6 +209,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for FilterMap { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/flatten.rs b/library/core/src/iter/adapters/flatten.rs index 7e3c69e29e96f..3460e728c06ef 100644 --- a/library/core/src/iter/adapters/flatten.rs +++ b/library/core/src/iter/adapters/flatten.rs @@ -148,6 +148,7 @@ where } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for FlatMap where I: Iterator, @@ -158,6 +159,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for FlatMap where I: SourceIter + TrustedFused, @@ -310,6 +312,7 @@ where } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Flatten where I: Iterator, @@ -318,6 +321,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Flatten where I: SourceIter + TrustedFused + Iterator, @@ -694,6 +698,7 @@ where } } +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for FlattenCompat::IntoIter> where @@ -701,6 +706,7 @@ where { } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, const N: usize, I, T> TrustedLen for FlattenCompat::IntoIter> where @@ -708,6 +714,7 @@ where { } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, const N: usize, I, T> TrustedLen for FlattenCompat::IntoIter> where diff --git a/library/core/src/iter/adapters/fuse.rs b/library/core/src/iter/adapters/fuse.rs index f614c31430745..4e820ae502654 100644 --- a/library/core/src/iter/adapters/fuse.rs +++ b/library/core/src/iter/adapters/fuse.rs @@ -35,6 +35,7 @@ impl Fuse { impl FusedIterator for Fuse where I: Iterator {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Fuse where I: TrustedFused {} // Any specialized implementation here is made internal @@ -247,6 +248,7 @@ unsafe impl TrustedRandomAccess for Fuse where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Fuse where I: TrustedRandomAccessNoCoerce, @@ -482,6 +484,7 @@ where // This is used by Flatten's SourceIter impl #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Fuse where I: SourceIter + TrustedFused, diff --git a/library/core/src/iter/adapters/inspect.rs b/library/core/src/iter/adapters/inspect.rs index de94951bc80ff..b94a3bb4180b2 100644 --- a/library/core/src/iter/adapters/inspect.rs +++ b/library/core/src/iter/adapters/inspect.rs @@ -151,9 +151,11 @@ where impl FusedIterator for Inspect where F: FnMut(&I::Item) {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Inspect {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Inspect where I: SourceIter, @@ -168,6 +170,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Inspect { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/map.rs b/library/core/src/iter/adapters/map.rs index 75f70dcd9b58f..b4db9422dd8bd 100644 --- a/library/core/src/iter/adapters/map.rs +++ b/library/core/src/iter/adapters/map.rs @@ -184,9 +184,11 @@ where impl FusedIterator for Map where F: FnMut(I::Item) -> B {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Map {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Map where I: TrustedLen, @@ -196,10 +198,12 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Map where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Map where I: TrustedRandomAccessNoCoerce, @@ -208,6 +212,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Map where I: SourceIter, @@ -222,6 +227,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Map { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/map_while.rs b/library/core/src/iter/adapters/map_while.rs index 3e34427da6142..80bb0bc21fc88 100644 --- a/library/core/src/iter/adapters/map_while.rs +++ b/library/core/src/iter/adapters/map_while.rs @@ -70,6 +70,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for MapWhile where I: SourceIter, @@ -84,6 +85,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for MapWhile { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/mod.rs b/library/core/src/iter/adapters/mod.rs index ca950a138f31c..0fc9555e068c8 100644 --- a/library/core/src/iter/adapters/mod.rs +++ b/library/core/src/iter/adapters/mod.rs @@ -206,6 +206,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for GenericShunt<'_, I, R> where I: SourceIter, @@ -223,6 +224,7 @@ where // in order to return `Some(_)`. Since `iter` has type `I: InPlaceIterable` it's // guaranteed that at least one item will be moved out from the underlying source. #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for GenericShunt<'_, I, R> where I: InPlaceIterable, diff --git a/library/core/src/iter/adapters/peekable.rs b/library/core/src/iter/adapters/peekable.rs index 4bddc2025c26e..b49bd13ee4c9b 100644 --- a/library/core/src/iter/adapters/peekable.rs +++ b/library/core/src/iter/adapters/peekable.rs @@ -459,9 +459,11 @@ impl Peekable { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Peekable where I: TrustedLen {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Peekable where I: SourceIter, diff --git a/library/core/src/iter/adapters/rev.rs b/library/core/src/iter/adapters/rev.rs index b9ada504525f9..117d8ceea22e5 100644 --- a/library/core/src/iter/adapters/rev.rs +++ b/library/core/src/iter/adapters/rev.rs @@ -154,6 +154,7 @@ where impl FusedIterator for Rev where I: FusedIterator + DoubleEndedIterator {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Rev where I: TrustedLen + DoubleEndedIterator {} #[stable(feature = "default_iters", since = "1.70.0")] diff --git a/library/core/src/iter/adapters/scan.rs b/library/core/src/iter/adapters/scan.rs index 7d084a89bd940..1bf675241575f 100644 --- a/library/core/src/iter/adapters/scan.rs +++ b/library/core/src/iter/adapters/scan.rs @@ -80,6 +80,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Scan where I: SourceIter, @@ -94,6 +95,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Scan { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/skip.rs b/library/core/src/iter/adapters/skip.rs index f7a6beb2b8c63..ff9c4154fd55e 100644 --- a/library/core/src/iter/adapters/skip.rs +++ b/library/core/src/iter/adapters/skip.rs @@ -246,9 +246,11 @@ where impl FusedIterator for Skip where I: FusedIterator {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Skip {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Skip where I: SourceIter, @@ -263,6 +265,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Skip { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; @@ -270,10 +273,12 @@ unsafe impl InPlaceIterable for Skip { #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Skip where I: TrustedRandomAccess {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Skip where I: TrustedRandomAccessNoCoerce, @@ -286,4 +291,5 @@ where // bound is never `None`. I: TrustedRandomAccess happens to provide this guarantee while // I: TrustedLen would not. #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Skip where I: Iterator + TrustedRandomAccess {} diff --git a/library/core/src/iter/adapters/skip_while.rs b/library/core/src/iter/adapters/skip_while.rs index ced4fd8f2abc4..d01f72bb4fdc5 100644 --- a/library/core/src/iter/adapters/skip_while.rs +++ b/library/core/src/iter/adapters/skip_while.rs @@ -107,9 +107,11 @@ where } #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for SkipWhile {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for SkipWhile where I: SourceIter, @@ -124,6 +126,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for SkipWhile { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/step_by.rs b/library/core/src/iter/adapters/step_by.rs index c73dfa784b8d9..4b26b02f1bcca 100644 --- a/library/core/src/iter/adapters/step_by.rs +++ b/library/core/src/iter/adapters/step_by.rs @@ -147,6 +147,7 @@ impl FusedIterator for StepBy where I: FusedIterator {} // I: TrustedLen would not. // This also covers the Range specializations since the ranges also implement TRA #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for StepBy where I: Iterator + TrustedRandomAccess {} trait SpecRangeSetup { @@ -222,6 +223,7 @@ unsafe trait StepByBackImpl { F: FnMut(Acc, Self::Item) -> Acc; } +// ignore-tidy-undocumented-unsafe unsafe impl StepByImpl for StepBy { type Item = I::Item; @@ -346,6 +348,7 @@ unsafe impl StepByImpl for StepBy { } } +// ignore-tidy-undocumented-unsafe unsafe impl StepByBackImpl for StepBy { type Item = I::Item; @@ -476,6 +479,7 @@ macro_rules! spec_int_ranges { } } + // ignore-tidy-undocumented-unsafe unsafe impl StepByImpl<$ctor<$t>> for StepBy<$ctor<$t>> { #[inline] fn spec_next(&mut self) -> Option<$t> { @@ -552,6 +556,7 @@ macro_rules! spec_int_ranges_r { ($ctor:ident; $($t:ty)*) => ($( const _: () = assert!(usize::BITS >= <$t>::BITS); + // ignore-tidy-undocumented-unsafe unsafe impl StepByBackImpl<$ctor<$t>> for StepBy<$ctor<$t>> { #[inline] diff --git a/library/core/src/iter/adapters/take.rs b/library/core/src/iter/adapters/take.rs index 3df2c70801644..c9afd46b45cc4 100644 --- a/library/core/src/iter/adapters/take.rs +++ b/library/core/src/iter/adapters/take.rs @@ -141,6 +141,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Take where I: SourceIter, @@ -155,6 +156,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Take { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; @@ -257,9 +259,11 @@ impl ExactSizeIterator for Take where I: ExactSizeIterator {} impl FusedIterator for Take where I: FusedIterator {} #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Take {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Take {} trait SpecTake: Iterator { diff --git a/library/core/src/iter/adapters/take_while.rs b/library/core/src/iter/adapters/take_while.rs index 6e40629567a83..05f57006ed305 100644 --- a/library/core/src/iter/adapters/take_while.rs +++ b/library/core/src/iter/adapters/take_while.rs @@ -108,9 +108,11 @@ where } #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for TakeWhile {} #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for TakeWhile where I: SourceIter, @@ -125,6 +127,7 @@ where } #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for TakeWhile { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = I::MERGE_BY; diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index faba1691b6b8c..cf1a982e4d9f3 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -409,6 +409,7 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Zip where A: TrustedRandomAccess, @@ -418,6 +419,7 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Zip where A: TrustedRandomAccessNoCoerce, @@ -435,6 +437,7 @@ where } #[unstable(issue = "none", feature = "trusted_fused")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedFused for Zip where A: TrustedFused, @@ -443,6 +446,7 @@ where } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Zip where A: TrustedLen, @@ -453,6 +457,7 @@ where // Arbitrarily selects the left side of the zip iteration as extractable "source" // it would require negative trait bounds to be able to try both #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl SourceIter for Zip where A: SourceIter, @@ -468,6 +473,7 @@ where // Since SourceIter forwards the left hand side we do the same here #[unstable(issue = "none", feature = "inplace_iteration")] +// ignore-tidy-undocumented-unsafe unsafe impl InPlaceIterable for Zip { const EXPAND_BY: Option> = A::EXPAND_BY; const MERGE_BY: Option> = A::MERGE_BY; @@ -605,12 +611,14 @@ unsafe trait SpecTrustedRandomAccess: Iterator { unsafe fn try_get_unchecked(&mut self, index: usize) -> Self::Item; } +// ignore-tidy-undocumented-unsafe unsafe impl SpecTrustedRandomAccess for I { default unsafe fn try_get_unchecked(&mut self, _: usize) -> Self::Item { panic!("Should only be called on TrustedRandomAccess iterators"); } } +// ignore-tidy-undocumented-unsafe unsafe impl SpecTrustedRandomAccess for I { #[inline] unsafe fn try_get_unchecked(&mut self, index: usize) -> Self::Item { diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 331c367314e63..93ac9f667c8b0 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -12,6 +12,7 @@ use crate::ops::{self, Try}; macro_rules! unsafe_impl_trusted_step { ($($type:ty)*) => {$( #[unstable(feature = "trusted_step", issue = "85731")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedStep for $type {} )*}; } @@ -983,10 +984,12 @@ macro_rules! unsafe_range_trusted_random_access_impl { ($($t:ty)*) => ($( #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for ops::Range<$t> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for ops::Range<$t> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1355,6 +1358,7 @@ const impl DoubleEndedIterator for ops::Rang // then `(0, Some(0))` is returned by `ops::Range::size_hint`. As such // the second invariant is upheld. #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ops::Range {} #[stable(feature = "fused", since = "1.26.0")] @@ -1385,6 +1389,7 @@ impl Iterator for ops::RangeFrom { // Safety: See above implementation for `ops::Range` #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ops::RangeFrom {} #[stable(feature = "fused", since = "1.26.0")] @@ -1666,6 +1671,7 @@ impl DoubleEndedIterator for ops::RangeInclusive { // Safety: See above implementation for `ops::Range` #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ops::RangeInclusive {} #[stable(feature = "fused", since = "1.26.0")] diff --git a/library/core/src/iter/sources/once.rs b/library/core/src/iter/sources/once.rs index c4a9860bdd76c..88cc3228bb2ce 100644 --- a/library/core/src/iter/sources/once.rs +++ b/library/core/src/iter/sources/once.rs @@ -95,6 +95,7 @@ impl ExactSizeIterator for Once { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Once {} #[stable(feature = "fused", since = "1.26.0")] diff --git a/library/core/src/iter/sources/once_with.rs b/library/core/src/iter/sources/once_with.rs index c9698b4fd431b..a8f10d6562d81 100644 --- a/library/core/src/iter/sources/once_with.rs +++ b/library/core/src/iter/sources/once_with.rs @@ -118,4 +118,5 @@ impl A> ExactSizeIterator for OnceWith { impl A> FusedIterator for OnceWith {} #[stable(feature = "iter_once_with", since = "1.43.0")] +// ignore-tidy-undocumented-unsafe unsafe impl A> TrustedLen for OnceWith {} diff --git a/library/core/src/iter/sources/repeat.rs b/library/core/src/iter/sources/repeat.rs index bdad4adccabac..c17488d3a960b 100644 --- a/library/core/src/iter/sources/repeat.rs +++ b/library/core/src/iter/sources/repeat.rs @@ -147,4 +147,5 @@ impl DoubleEndedIterator for Repeat { impl FusedIterator for Repeat {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Repeat {} diff --git a/library/core/src/iter/sources/repeat_n.rs b/library/core/src/iter/sources/repeat_n.rs index d19ff6b7e024f..65c90e991a075 100644 --- a/library/core/src/iter/sources/repeat_n.rs +++ b/library/core/src/iter/sources/repeat_n.rs @@ -210,4 +210,5 @@ impl DoubleEndedIterator for RepeatN { impl FusedIterator for RepeatN {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RepeatN {} diff --git a/library/core/src/iter/sources/repeat_with.rs b/library/core/src/iter/sources/repeat_with.rs index 5998f9e56f0a1..0515f222ed804 100644 --- a/library/core/src/iter/sources/repeat_with.rs +++ b/library/core/src/iter/sources/repeat_with.rs @@ -120,4 +120,5 @@ impl A> Iterator for RepeatWith { impl A> FusedIterator for RepeatWith {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl A> TrustedLen for RepeatWith {} diff --git a/library/core/src/iter/traits/marker.rs b/library/core/src/iter/traits/marker.rs index fd96424566bcc..41c4476c1432e 100644 --- a/library/core/src/iter/traits/marker.rs +++ b/library/core/src/iter/traits/marker.rs @@ -25,6 +25,7 @@ pub unsafe trait TrustedFused {} /// /// [`Fuse`]: crate::iter::Fuse #[stable(feature = "fused", since = "1.26.0")] +// ignore-tidy-undocumented-unsafe #[unsafe(rustc_allow_lifetime_dependent_specialization)] // FIXME: this should be a #[marker] and have another blanket impl for T: TrustedFused // but that ICEs iter::Fuse specializations. @@ -62,12 +63,15 @@ impl FusedIterator for &mut I {} /// This trait must only be implemented when the contract is upheld. Consumers /// of this trait must inspect [`Iterator::size_hint()`]’s upper bound. #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe #[unsafe(rustc_allow_lifetime_dependent_specialization)] #[rustc_const_unstable(feature = "const_iter", issue = "92476")] pub const unsafe trait TrustedLen: [const] Iterator {} #[unstable(feature = "trusted_len", issue = "37572")] #[rustc_const_unstable(feature = "const_iter", issue = "92476")] +// SAFETY: Since `size_hint` for mutable references is trivially forwarded, +// `TrustedLen` can be trivially inhberited. unsafe impl TrustedLen for &mut I {} /// An iterator that when yielding an item will have taken at least one element diff --git a/library/core/src/marker/variance.rs b/library/core/src/marker/variance.rs index 9e135e89c451e..f372b547915b8 100644 --- a/library/core/src/marker/variance.rs +++ b/library/core/src/marker/variance.rs @@ -62,6 +62,7 @@ macro_rules! phantom_type { impl Copy for $name where T: ?Sized {} #[doc(hidden)] + // ignore-tidy-undocumented-unsafe unsafe impl TrivialClone for $name where T: ?Sized {} impl PartialEq for $name diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs index 1003edad24484..b007bfc5008b0 100644 --- a/library/core/src/ops/deref.rs +++ b/library/core/src/ops/deref.rs @@ -297,9 +297,11 @@ const impl DerefMut for &mut T { pub unsafe trait DerefPure: PointeeSized {} #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for &T {} #[unstable(feature = "deref_pure_trait", issue = "87121")] +// ignore-tidy-undocumented-unsafe unsafe impl DerefPure for &mut T {} /// Indicates that a struct can be used as a method receiver. diff --git a/library/core/src/pin/unsafe_pinned.rs b/library/core/src/pin/unsafe_pinned.rs index 83d9e9acedbf7..e0292412871ea 100644 --- a/library/core/src/pin/unsafe_pinned.rs +++ b/library/core/src/pin/unsafe_pinned.rs @@ -30,6 +30,7 @@ pub struct UnsafePinned { // Override the manual `!Sync` in `UnsafeCell`. #[unstable(feature = "unsafe_pinned", issue = "125735")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for UnsafePinned {} /// When this type is used, that almost certainly means safe APIs need to use pinning to avoid the diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs index 1eeadf1217b5f..adf1dc7919005 100644 --- a/library/core/src/ptr/metadata.rs +++ b/library/core/src/ptr/metadata.rs @@ -210,7 +210,9 @@ impl DynMetadata { } } +// ignore-tidy-undocumented-unsafe unsafe impl Send for DynMetadata {} +// ignore-tidy-undocumented-unsafe unsafe impl Sync for DynMetadata {} impl fmt::Debug for DynMetadata { @@ -233,6 +235,7 @@ impl Clone for DynMetadata { } #[doc(hidden)] +// ignore-tidy-undocumented-unsafe unsafe impl TrivialClone for DynMetadata {} impl Eq for DynMetadata {} diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index 5e3fe666ac9ba..b3ce742273c68 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -47,6 +47,7 @@ pub struct Unique { /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. #[unstable(feature = "ptr_internals", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Unique {} /// `Unique` pointers are `Sync` if `T` is `Sync` because the data they @@ -54,6 +55,7 @@ unsafe impl Send for Unique {} /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. #[unstable(feature = "ptr_internals", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Unique {} #[unstable(feature = "ptr_internals", issue = "none")] @@ -167,6 +169,7 @@ impl Copy for Unique {} #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrivialClone for Unique {} #[unstable(feature = "ptr_internals", issue = "none")] diff --git a/library/core/src/range/iter.rs b/library/core/src/range/iter.rs index 6011949476f6f..c4765b045d282 100644 --- a/library/core/src/range/iter.rs +++ b/library/core/src/range/iter.rs @@ -38,10 +38,12 @@ macro_rules! unsafe_range_trusted_random_access_impl { ($($t:ty)*) => ($( #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for RangeIter<$t> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for RangeIter<$t> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -151,6 +153,7 @@ impl DoubleEndedIterator for RangeIter { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RangeIter {} #[stable(feature = "new_range_api", since = "1.96.0")] @@ -274,6 +277,7 @@ impl DoubleEndedIterator for RangeInclusiveIter { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RangeInclusiveIter {} #[stable(feature = "new_range_inclusive_api", since = "1.95.0")] @@ -430,6 +434,7 @@ impl Iterator for RangeFromIter { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RangeFromIter {} #[stable(feature = "new_range_from_api", since = "1.96.0")] diff --git a/library/core/src/slice/cmp.rs b/library/core/src/slice/cmp.rs index fcdde758fa7df..0df5495b0c4c6 100644 --- a/library/core/src/slice/cmp.rs +++ b/library/core/src/slice/cmp.rs @@ -301,14 +301,19 @@ const impl SliceOrd for A { const unsafe trait UnsignedBytewiseOrd: [const] Ord {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +// ignore-tidy-undocumented-unsafe const unsafe impl UnsignedBytewiseOrd for bool {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +// ignore-tidy-undocumented-unsafe const unsafe impl UnsignedBytewiseOrd for u8 {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +// ignore-tidy-undocumented-unsafe const unsafe impl UnsignedBytewiseOrd for NonZero {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +// ignore-tidy-undocumented-unsafe const unsafe impl UnsignedBytewiseOrd for Option> {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +// ignore-tidy-undocumented-unsafe const unsafe impl UnsignedBytewiseOrd for ascii::Char {} // `compare_bytes` compares a sequence of unsigned bytes lexicographically, so diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 522603c574bad..4f4811309fc27 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -176,6 +176,7 @@ pub impl(crate) const unsafe trait SliceIndex { /// The methods `index` and `index_mut` panic if the index is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for usize { type Output = T; @@ -249,6 +250,7 @@ const unsafe impl SliceIndex<[T]> for usize { /// Because `IndexRange` guarantees `start <= end`, fewer checks are needed here /// than there are for a general `Range` (which might be `100..3`). #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::IndexRange { type Output = [T]; @@ -328,6 +330,7 @@ const unsafe impl SliceIndex<[T]> for ops::IndexRange { /// - the end of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::Range { type Output = [T]; @@ -431,6 +434,7 @@ const unsafe impl SliceIndex<[T]> for ops::Range { #[stable(feature = "new_range_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for range::Range { type Output = [T]; @@ -472,6 +476,7 @@ const unsafe impl SliceIndex<[T]> for range::Range { /// The methods `index` and `index_mut` panic if the end of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::RangeTo { type Output = [T]; @@ -513,6 +518,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeTo { /// The methods `index` and `index_mut` panic if the start of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::RangeFrom { type Output = [T]; @@ -567,6 +573,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFrom { #[stable(feature = "new_range_from_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for range::RangeFrom { type Output = [T]; @@ -607,6 +614,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeFrom { #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::RangeFull { type Output = [T]; @@ -648,6 +656,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFull { /// - the end of the range is out of bounds. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::RangeInclusive { type Output = [T]; @@ -708,6 +717,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeInclusive { #[stable(feature = "new_range_inclusive_api", since = "1.95.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for range::RangeInclusive { type Output = [T]; @@ -749,6 +759,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeInclusive { /// The methods `index` and `index_mut` panic if the end of the range is out of bounds. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { type Output = [T]; @@ -790,6 +801,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { /// The methods `index` and `index_mut` panic if the end of the range is out of bounds. #[stable(feature = "new_range_to_inclusive_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex<[T]> for range::RangeToInclusive { type Output = [T]; @@ -1032,6 +1044,7 @@ pub(crate) const fn into_slice_range( } #[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex<[T]> for (ops::Bound, ops::Bound) { type Output = [T]; diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 1c721f2925eb5..82d86b3aa41c2 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -85,8 +85,10 @@ impl fmt::Debug for Iter<'_, T> { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Iter<'_, T> {} impl<'a, T> Iter<'a, T> { @@ -210,8 +212,10 @@ impl fmt::Debug for IterMut<'_, T> { } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for IterMut<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for IterMut<'_, T> {} impl<'a, T> IterMut<'a, T> { @@ -1436,6 +1440,7 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { impl ExactSizeIterator for Windows<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Windows<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] @@ -1443,10 +1448,12 @@ impl FusedIterator for Windows<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Windows<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1616,6 +1623,7 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { impl ExactSizeIterator for Chunks<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Chunks<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] @@ -1623,10 +1631,12 @@ impl FusedIterator for Chunks<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Chunks<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1792,6 +1802,7 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> { impl ExactSizeIterator for ChunksMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ChunksMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] @@ -1799,18 +1810,22 @@ impl FusedIterator for ChunksMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for ChunksMut<'_, T> where T: Send {} #[stable(feature = "rust1", since = "1.0.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for ChunksMut<'_, T> where T: Sync {} /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a @@ -1971,6 +1986,7 @@ impl ExactSizeIterator for ChunksExact<'_, T> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ChunksExact<'_, T> {} #[stable(feature = "chunks_exact", since = "1.31.0")] @@ -1978,10 +1994,12 @@ impl FusedIterator for ChunksExact<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksExact<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2134,6 +2152,7 @@ impl ExactSizeIterator for ChunksExactMut<'_, T> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ChunksExactMut<'_, T> {} #[stable(feature = "chunks_exact", since = "1.31.0")] @@ -2141,18 +2160,22 @@ impl FusedIterator for ChunksExactMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksExactMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[stable(feature = "chunks_exact", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for ChunksExactMut<'_, T> where T: Send {} #[stable(feature = "chunks_exact", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for ChunksExactMut<'_, T> where T: Sync {} /// A windowed iterator over a slice in overlapping chunks (`N` elements at a @@ -2267,6 +2290,7 @@ impl ExactSizeIterator for ArrayWindows<'_, T, N> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for ArrayWindows<'_, T, N> {} #[stable(feature = "array_windows", since = "1.94.0")] @@ -2274,10 +2298,12 @@ impl FusedIterator for ArrayWindows<'_, T, N> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for ArrayWindows<'_, T, N> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for ArrayWindows<'_, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2431,6 +2457,7 @@ impl<'a, T> DoubleEndedIterator for RChunks<'a, T> { impl ExactSizeIterator for RChunks<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RChunks<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] @@ -2438,10 +2465,12 @@ impl FusedIterator for RChunks<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for RChunks<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunks<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2602,6 +2631,7 @@ impl<'a, T> DoubleEndedIterator for RChunksMut<'a, T> { impl ExactSizeIterator for RChunksMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RChunksMut<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] @@ -2609,18 +2639,22 @@ impl FusedIterator for RChunksMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for RChunksMut<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[stable(feature = "rchunks", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for RChunksMut<'_, T> where T: Send {} #[stable(feature = "rchunks", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for RChunksMut<'_, T> where T: Sync {} /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a @@ -2788,6 +2822,7 @@ impl<'a, T> ExactSizeIterator for RChunksExact<'a, T> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RChunksExact<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] @@ -2795,10 +2830,12 @@ impl FusedIterator for RChunksExact<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for RChunksExact<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksExact<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2961,6 +2998,7 @@ impl ExactSizeIterator for RChunksExactMut<'_, T> { } #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for RChunksExactMut<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] @@ -2968,36 +3006,44 @@ impl FusedIterator for RChunksExactMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksExactMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[stable(feature = "rchunks", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for RChunksExactMut<'_, T> where T: Send {} #[stable(feature = "rchunks", since = "1.31.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for RChunksExactMut<'_, T> where T: Sync {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Iter<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccess for IterMut<'a, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl<'a, T> TrustedRandomAccessNoCoerce for IterMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/core/src/slice/iter/macros.rs b/library/core/src/slice/iter/macros.rs index 6f0f7aa7404fa..c35d9a8c6e3e7 100644 --- a/library/core/src/slice/iter/macros.rs +++ b/library/core/src/slice/iter/macros.rs @@ -474,6 +474,7 @@ macro_rules! iterator { impl FusedIterator for $name<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] + // ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for $name<'_, T> {} #[stable(feature = "default_iters", since = "1.70.0")] diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 60b9e81aaeff9..29ad0d6d176e5 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -398,14 +398,17 @@ impl ExactSizeIterator for Bytes<'_> { impl FusedIterator for Bytes<'_> {} #[unstable(feature = "trusted_len", issue = "37572")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedLen for Bytes<'_> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccess for Bytes<'_> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] +// ignore-tidy-undocumented-unsafe unsafe impl TrustedRandomAccessNoCoerce for Bytes<'_> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index af48c2eae8dd6..8404b8fa097dc 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -398,6 +398,7 @@ impl CharSearcher<'_> { } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a> Searcher<'a> for CharSearcher<'a> { #[inline] fn haystack(&self) -> &'a str { @@ -476,6 +477,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> { // let next_reject use the default implementation from the Searcher trait } +// ignore-tidy-undocumented-unsafe unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> { #[inline] fn next_back(&mut self) -> SearchStep { @@ -681,6 +683,7 @@ impl Pattern for MultiCharEqPattern { } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, C: MultiCharEq> Searcher<'a> for MultiCharEqSearcher<'a, C> { #[inline] fn haystack(&self) -> &'a str { @@ -706,6 +709,7 @@ unsafe impl<'a, C: MultiCharEq> Searcher<'a> for MultiCharEqSearcher<'a, C> { } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, C: MultiCharEq> ReverseSearcher<'a> for MultiCharEqSearcher<'a, C> { #[inline] fn next_back(&mut self) -> SearchStep { @@ -831,10 +835,12 @@ impl Pattern for [char; N] { pattern_methods!('a, CharArraySearcher<'a, N>, MultiCharEqPattern, CharArraySearcher); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, const N: usize> Searcher<'a> for CharArraySearcher<'a, N> { searcher_methods!(forward); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, const N: usize> ReverseSearcher<'a> for CharArraySearcher<'a, N> { searcher_methods!(reverse); } @@ -853,10 +859,12 @@ impl<'b, const N: usize> Pattern for &'b [char; N] { pattern_methods!('a, CharArrayRefSearcher<'a, 'b, N>, MultiCharEqPattern, CharArrayRefSearcher); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b, const N: usize> Searcher<'a> for CharArrayRefSearcher<'a, 'b, N> { searcher_methods!(forward); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b, const N: usize> ReverseSearcher<'a> for CharArrayRefSearcher<'a, 'b, N> { searcher_methods!(reverse); } @@ -873,10 +881,12 @@ impl<'a, 'b, const N: usize> DoubleEndedSearcher<'a> for CharArrayRefSearcher<'a #[derive(Clone, Debug)] pub struct CharSliceSearcher<'a, 'b>( as Pattern>::Searcher<'a>); +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b> Searcher<'a> for CharSliceSearcher<'a, 'b> { searcher_methods!(forward); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b> { searcher_methods!(reverse); } @@ -916,6 +926,7 @@ where .finish() } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, F> Searcher<'a> for CharPredicateSearcher<'a, F> where F: FnMut(char) -> bool, @@ -923,6 +934,7 @@ where searcher_methods!(forward); } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, F> ReverseSearcher<'a> for CharPredicateSearcher<'a, F> where F: FnMut(char) -> bool, @@ -1128,6 +1140,7 @@ impl<'a, 'b> StrSearcher<'a, 'b> { } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> { #[inline] fn haystack(&self) -> &'a str { @@ -1250,6 +1263,7 @@ unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> { } } +// ignore-tidy-undocumented-unsafe unsafe impl<'a, 'b> ReverseSearcher<'a> for StrSearcher<'a, 'b> { #[inline] fn next_back(&mut self) -> SearchStep { diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index 480e4a1b0128a..294ff0d815517 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -92,6 +92,7 @@ where /// Equivalent to `&self[0 .. len]` or `&mut self[0 .. len]`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::RangeFull { type Output = str; #[inline] @@ -186,6 +187,7 @@ const fn check_range(slice: &str, range: crate::range::Range) -> bool { /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::Range { type Output = str; #[inline] @@ -257,6 +259,7 @@ const unsafe impl SliceIndex for ops::Range { #[stable(feature = "new_range_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for range::Range { type Output = str; #[inline] @@ -364,6 +367,7 @@ const unsafe impl SliceIndex for range::Range { /// a character (as defined by `is_char_boundary`), if `begin > end`, or if /// `end > len`. #[stable(feature = "slice_index_str_with_ops_bound_pair", since = "1.73.0")] +// ignore-tidy-undocumented-unsafe unsafe impl SliceIndex for (ops::Bound, ops::Bound) { type Output = str; @@ -419,6 +423,7 @@ unsafe impl SliceIndex for (ops::Bound, ops::Bound) { /// character (as defined by `is_char_boundary`), or if `end > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::RangeTo { type Output = str; #[inline] @@ -488,6 +493,7 @@ const unsafe impl SliceIndex for ops::RangeTo { /// a character (as defined by `is_char_boundary`), or if `begin > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::RangeFrom { type Output = str; #[inline] @@ -544,6 +550,7 @@ const unsafe impl SliceIndex for ops::RangeFrom { #[stable(feature = "new_range_from_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for range::RangeFrom { type Output = str; #[inline] @@ -616,6 +623,7 @@ const unsafe impl SliceIndex for range::RangeFrom { /// byte offset or equal to `len`), if `begin > end`, or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::RangeInclusive { type Output = str; #[inline] @@ -674,6 +682,7 @@ const unsafe impl SliceIndex for ops::RangeInclusive { #[stable(feature = "new_range_inclusive_api", since = "1.95.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for range::RangeInclusive { type Output = str; #[inline] @@ -720,6 +729,7 @@ const unsafe impl SliceIndex for range::RangeInclusive { /// `is_char_boundary`, or equal to `len`), or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for ops::RangeToInclusive { type Output = str; #[inline] @@ -766,6 +776,7 @@ const unsafe impl SliceIndex for ops::RangeToInclusive { /// `is_char_boundary`, or equal to `len`), or if `last >= len`. #[stable(feature = "new_range_to_inclusive_api", since = "1.96.0")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] +// ignore-tidy-undocumented-unsafe const unsafe impl SliceIndex for range::RangeToInclusive { type Output = str; #[inline] diff --git a/library/core/src/sync/sync_view.rs b/library/core/src/sync/sync_view.rs index 69b5270522b76..9dda71246ce90 100644 --- a/library/core/src/sync/sync_view.rs +++ b/library/core/src/sync/sync_view.rs @@ -364,6 +364,7 @@ where #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] +// ignore-tidy-undocumented-unsafe const unsafe impl TrivialClone for SyncView where T: Sync + [const] TrivialClone {} #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 1dbd11426e57e..451a501a2733d 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -415,8 +415,10 @@ pub struct Waker { #[stable(feature = "futures_api", since = "1.36.0")] impl Unpin for Waker {} #[stable(feature = "futures_api", since = "1.36.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Send for Waker {} #[stable(feature = "futures_api", since = "1.36.0")] +// ignore-tidy-undocumented-unsafe unsafe impl Sync for Waker {} impl Waker {