From 004478a829c7b4b7aa608f0f2d4d58a97c7836af Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Wed, 2 Jul 2025 13:19:41 +0000 Subject: [PATCH 1/5] int_log10.rs: change top level doc comments to outer --- library/core/src/num/int_log10.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/int_log10.rs b/library/core/src/num/int_log10.rs index 28a3f5d880ad7..649a736b6e7b5 100644 --- a/library/core/src/num/int_log10.rs +++ b/library/core/src/num/int_log10.rs @@ -1,5 +1,5 @@ -/// These functions compute the integer logarithm of their type, assuming -/// that someone has already checked that the value is strictly positive. +//! These functions compute the integer logarithm of their type, assuming +//! that someone has already checked that the value is strictly positive. // 0 < val <= u8::MAX #[inline] From f96d5d960256557a0c2434a308fd32c98e94aa7f Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Wed, 2 Jul 2025 13:29:16 +0000 Subject: [PATCH 2/5] collect.rs: remove empty line after doc comment --- library/core/src/fmt/mod.rs | 1 - library/core/src/iter/traits/collect.rs | 1 - library/core/src/lib.rs | 6 +++--- library/core/src/net/ip_addr.rs | 1 - library/core/src/primitive_docs.rs | 1 - library/core/src/str/mod.rs | 1 - 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 5e50eacec6eef..77ab1c4201cd0 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -854,7 +854,6 @@ impl Display for Arguments<'_> { /// }"; /// assert_eq!(format!("The origin is: {origin:#?}"), expected); /// ``` - #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( on( diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 3bc9cff8072bf..ab27650067980 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -436,7 +436,6 @@ pub trait Extend { /// **For implementors:** For a collection to unsafely rely on this method's safety precondition (that is, /// invoke UB if they are violated), it must implement `extend_reserve` correctly. In other words, /// callers may assume that if they `extend_reserve`ed enough space they can call this method. - // This method is for internal usage only. It is only on the trait because of specialization's limitations. #[unstable(feature = "extend_one_unchecked", issue = "none")] #[doc(hidden)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2f701171505c7..de5174bcbf6f0 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -39,9 +39,9 @@ //! return. You should mark your implementation using `#[panic_handler]`. //! //! * `rust_eh_personality` - is used by the failure mechanisms of the -//! compiler. This is often mapped to GCC's personality function, but crates -//! which do not trigger a panic can be assured that this function is never -//! called. The `lang` attribute is called `eh_personality`. +//! compiler. This is often mapped to GCC's personality function, but crates +//! which do not trigger a panic can be assured that this function is never +//! called. The `lang` attribute is called `eh_personality`. #![stable(feature = "core", since = "1.6.0")] #![doc( diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index aaa68e8d7d1ad..49a7ae5de5c8f 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -787,7 +787,6 @@ impl Ipv4Addr { /// [IANA IPv4 Special-Purpose Address Registry]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml /// [unspecified address]: Ipv4Addr::UNSPECIFIED /// [broadcast address]: Ipv4Addr::BROADCAST - /// /// # Examples /// diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 2c77c55745b46..28124ac5aa8b2 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1365,7 +1365,6 @@ mod prim_f16 {} /// x = a + b + c + d; // As written /// x = (a + c) + (b + d); // Reordered to shorten critical path and enable vectorization /// ``` - #[stable(feature = "rust1", since = "1.0.0")] mod prim_f32 {} diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index fe64132ff227d..98b5e29009c4e 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2648,7 +2648,6 @@ impl str { /// you're trying to parse into. /// /// `parse` can parse into any type that implements the [`FromStr`] trait. - /// /// # Errors /// From ca4a712b59b9ed216e8bb6e24140b08d7020c68c Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Thu, 3 Jul 2025 12:41:05 +0000 Subject: [PATCH 3/5] clippy fix: markdown indentation for indented items after line break --- library/core/src/async_iter/async_iter.rs | 10 +++++----- library/core/src/mem/mod.rs | 2 +- library/core/src/ptr/docs/as_uninit_slice.md | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/core/src/async_iter/async_iter.rs b/library/core/src/async_iter/async_iter.rs index 069c50c2531b0..c21c08320bef6 100644 --- a/library/core/src/async_iter/async_iter.rs +++ b/library/core/src/async_iter/async_iter.rs @@ -28,15 +28,15 @@ pub trait AsyncIterator { /// async iterator state: /// /// - `Poll::Pending` means that this async iterator's next value is not ready - /// yet. Implementations will ensure that the current task will be notified - /// when the next value may be ready. + /// yet. Implementations will ensure that the current task will be notified + /// when the next value may be ready. /// /// - `Poll::Ready(Some(val))` means that the async iterator has successfully - /// produced a value, `val`, and may produce further values on subsequent - /// `poll_next` calls. + /// produced a value, `val`, and may produce further values on subsequent + /// `poll_next` calls. /// /// - `Poll::Ready(None)` means that the async iterator has terminated, and - /// `poll_next` should not be invoked again. + /// `poll_next` should not be invoked again. /// /// # Panics /// diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index c00585de06496..8db52a38014e3 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -36,7 +36,7 @@ pub use crate::intrinsics::transmute; /// * If you want to leak memory, see [`Box::leak`]. /// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`]. /// * If you want to dispose of a value properly, running its destructor, see -/// [`mem::drop`]. +/// [`mem::drop`]. /// /// # Safety /// diff --git a/library/core/src/ptr/docs/as_uninit_slice.md b/library/core/src/ptr/docs/as_uninit_slice.md index c80c04058838f..1113f4748c2df 100644 --- a/library/core/src/ptr/docs/as_uninit_slice.md +++ b/library/core/src/ptr/docs/as_uninit_slice.md @@ -10,24 +10,24 @@ When calling this method, you have to ensure that *either* the pointer is null * all of the following is true: * The pointer must be [valid] for reads for `ptr.len() * size_of::()` many bytes, -and it must be properly aligned. This means in particular: + and it must be properly aligned. This means in particular: * The entire memory range of this slice must be contained within a single [allocation]! -Slices can never span across multiple allocations. + Slices can never span across multiple allocations. * The pointer must be aligned even for zero-length slices. One -reason for this is that enum layout optimizations may rely on references -(including slices of any length) being aligned and non-null to distinguish -them from other data. You can obtain a pointer that is usable as `data` -for zero-length slices using [`NonNull::dangling()`]. + reason for this is that enum layout optimizations may rely on references + (including slices of any length) being aligned and non-null to distinguish + them from other data. You can obtain a pointer that is usable as `data` + for zero-length slices using [`NonNull::dangling()`]. * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. -See the safety documentation of [`pointer::offset`]. + See the safety documentation of [`pointer::offset`]. * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is -arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. -In particular, while this reference exists, the memory the pointer points to must -not get mutated (except inside `UnsafeCell`). + arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. + In particular, while this reference exists, the memory the pointer points to must + not get mutated (except inside `UnsafeCell`). This applies even if the result of this method is unused! From 093831b4b6639ee11132773eda21ff2411e0741d Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Wed, 2 Jul 2025 13:27:29 +0000 Subject: [PATCH 4/5] clippy fix: bound in one place --- library/core/src/cmp.rs | 5 +++-- library/core/src/iter/traits/iterator.rs | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index b1ca3701fa5ae..7abadc9124ba3 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1481,13 +1481,14 @@ pub trait PartialOrd: PartialEq + PointeeSized { } } -fn default_chaining_impl( +fn default_chaining_impl( lhs: &T, rhs: &U, p: impl FnOnce(Ordering) -> bool, ) -> ControlFlow where - T: PartialOrd, + T: PartialOrd + PointeeSized, + U: PointeeSized, { // It's important that this only call `partial_cmp` once, not call `eq` then // one of the relational operators. We don't want to `bcmp`-then-`memcp` a diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f296792b1dcb2..f83f41b92d23e 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -3414,10 +3414,9 @@ pub trait Iterator { /// ``` #[stable(feature = "iter_copied", since = "1.36.0")] #[rustc_diagnostic_item = "iter_copied"] - fn copied<'a, T: 'a>(self) -> Copied + fn copied<'a, T: Copy + 'a>(self) -> Copied where Self: Sized + Iterator, - T: Copy, { Copied::new(self) } @@ -3462,10 +3461,9 @@ pub trait Iterator { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "iter_cloned"] - fn cloned<'a, T: 'a>(self) -> Cloned + fn cloned<'a, T: Clone + 'a>(self) -> Cloned where Self: Sized + Iterator, - T: Clone, { Cloned::new(self) } From dc2331794b8d4fedde5e652b279aaf993d0ceb94 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Wed, 2 Jul 2025 14:38:05 +0000 Subject: [PATCH 5/5] flt2dec: fix some clippy lints --- library/core/src/num/flt2dec/mod.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/library/core/src/num/flt2dec/mod.rs b/library/core/src/num/flt2dec/mod.rs index 7601e3e2c58a2..ee66d07fec7e0 100644 --- a/library/core/src/num/flt2dec/mod.rs +++ b/library/core/src/num/flt2dec/mod.rs @@ -150,23 +150,19 @@ pub fn round_up(d: &mut [u8]) -> Option { Some(i) => { // d[i+1..n] is all nines d[i] += 1; - for j in i + 1..d.len() { - d[j] = b'0'; - } + d.iter_mut().skip(i + 1).for_each(|c| *c = b'0'); None } - None if d.len() > 0 => { + None if d.is_empty() => { + // an empty buffer rounds up (a bit strange but reasonable) + Some(b'1') + } + None => { // 999..999 rounds to 1000..000 with an increased exponent d[0] = b'1'; - for j in 1..d.len() { - d[j] = b'0'; - } + d.iter_mut().skip(1).for_each(|c| *c = b'0'); Some(b'0') } - None => { - // an empty buffer rounds up (a bit strange but reasonable) - Some(b'1') - } } }