Skip to content

Commit e20a673

Browse files
Auto merge of #143423 - hkBst:clippy-fix-1, r=<try>
Fix multiple clippy issues - int_log10.rs: change top level doc comments to outer - collect.rs: remove empty line after doc comment - clippy fix: markdown indentation for indented items after line break: a markdown list item continued over multiples lines, but those following lines which are part of the same item are not indented - clippy fix: bound in one place: when there is a bound in angle brackets and another bound on the same variable in a where clause - flt2dec: fix some clippy lints: a manual index being used, and it is only used for directly indexing into the thing iterated over, so why iterate over the things directly instead of the indices and a manual is_empty impl `.len() == 0`.
2 parents 8231065 + dc23317 commit e20a673

File tree

13 files changed

+33
-43
lines changed

13 files changed

+33
-43
lines changed

library/core/src/async_iter/async_iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ pub trait AsyncIterator {
2828
/// async iterator state:
2929
///
3030
/// - `Poll::Pending` means that this async iterator's next value is not ready
31-
/// yet. Implementations will ensure that the current task will be notified
32-
/// when the next value may be ready.
31+
/// yet. Implementations will ensure that the current task will be notified
32+
/// when the next value may be ready.
3333
///
3434
/// - `Poll::Ready(Some(val))` means that the async iterator has successfully
35-
/// produced a value, `val`, and may produce further values on subsequent
36-
/// `poll_next` calls.
35+
/// produced a value, `val`, and may produce further values on subsequent
36+
/// `poll_next` calls.
3737
///
3838
/// - `Poll::Ready(None)` means that the async iterator has terminated, and
39-
/// `poll_next` should not be invoked again.
39+
/// `poll_next` should not be invoked again.
4040
///
4141
/// # Panics
4242
///

library/core/src/cmp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,13 +1482,14 @@ pub trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
14821482
}
14831483
}
14841484

1485-
fn default_chaining_impl<T: PointeeSized, U: PointeeSized>(
1485+
fn default_chaining_impl<T, U>(
14861486
lhs: &T,
14871487
rhs: &U,
14881488
p: impl FnOnce(Ordering) -> bool,
14891489
) -> ControlFlow<bool>
14901490
where
1491-
T: PartialOrd<U>,
1491+
T: PartialOrd<U> + PointeeSized,
1492+
U: PointeeSized,
14921493
{
14931494
// It's important that this only call `partial_cmp` once, not call `eq` then
14941495
// one of the relational operators. We don't want to `bcmp`-then-`memcp` a

library/core/src/fmt/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,6 @@ impl Display for Arguments<'_> {
854854
/// }";
855855
/// assert_eq!(format!("The origin is: {origin:#?}"), expected);
856856
/// ```
857-
858857
#[stable(feature = "rust1", since = "1.0.0")]
859858
#[rustc_on_unimplemented(
860859
on(

library/core/src/iter/traits/collect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ pub trait Extend<A> {
436436
/// **For implementors:** For a collection to unsafely rely on this method's safety precondition (that is,
437437
/// invoke UB if they are violated), it must implement `extend_reserve` correctly. In other words,
438438
/// callers may assume that if they `extend_reserve`ed enough space they can call this method.
439-
440439
// This method is for internal usage only. It is only on the trait because of specialization's limitations.
441440
#[unstable(feature = "extend_one_unchecked", issue = "none")]
442441
#[doc(hidden)]

library/core/src/iter/traits/iterator.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,10 +3414,9 @@ pub trait Iterator {
34143414
/// ```
34153415
#[stable(feature = "iter_copied", since = "1.36.0")]
34163416
#[rustc_diagnostic_item = "iter_copied"]
3417-
fn copied<'a, T: 'a>(self) -> Copied<Self>
3417+
fn copied<'a, T: Copy + 'a>(self) -> Copied<Self>
34183418
where
34193419
Self: Sized + Iterator<Item = &'a T>,
3420-
T: Copy,
34213420
{
34223421
Copied::new(self)
34233422
}
@@ -3462,10 +3461,9 @@ pub trait Iterator {
34623461
/// ```
34633462
#[stable(feature = "rust1", since = "1.0.0")]
34643463
#[rustc_diagnostic_item = "iter_cloned"]
3465-
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
3464+
fn cloned<'a, T: Clone + 'a>(self) -> Cloned<Self>
34663465
where
34673466
Self: Sized + Iterator<Item = &'a T>,
3468-
T: Clone,
34693467
{
34703468
Cloned::new(self)
34713469
}

library/core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
//! return. You should mark your implementation using `#[panic_handler]`.
4040
//!
4141
//! * `rust_eh_personality` - is used by the failure mechanisms of the
42-
//! compiler. This is often mapped to GCC's personality function, but crates
43-
//! which do not trigger a panic can be assured that this function is never
44-
//! called. The `lang` attribute is called `eh_personality`.
42+
//! compiler. This is often mapped to GCC's personality function, but crates
43+
//! which do not trigger a panic can be assured that this function is never
44+
//! called. The `lang` attribute is called `eh_personality`.
4545
4646
#![stable(feature = "core", since = "1.6.0")]
4747
#![doc(

library/core/src/mem/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use crate::intrinsics::transmute;
3636
/// * If you want to leak memory, see [`Box::leak`].
3737
/// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`].
3838
/// * If you want to dispose of a value properly, running its destructor, see
39-
/// [`mem::drop`].
39+
/// [`mem::drop`].
4040
///
4141
/// # Safety
4242
///

library/core/src/net/ip_addr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ impl Ipv4Addr {
787787
/// [IANA IPv4 Special-Purpose Address Registry]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
788788
/// [unspecified address]: Ipv4Addr::UNSPECIFIED
789789
/// [broadcast address]: Ipv4Addr::BROADCAST
790-
791790
///
792791
/// # Examples
793792
///

library/core/src/num/flt2dec/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,19 @@ pub fn round_up(d: &mut [u8]) -> Option<u8> {
150150
Some(i) => {
151151
// d[i+1..n] is all nines
152152
d[i] += 1;
153-
for j in i + 1..d.len() {
154-
d[j] = b'0';
155-
}
153+
d.iter_mut().skip(i + 1).for_each(|c| *c = b'0');
156154
None
157155
}
158-
None if d.len() > 0 => {
156+
None if d.is_empty() => {
157+
// an empty buffer rounds up (a bit strange but reasonable)
158+
Some(b'1')
159+
}
160+
None => {
159161
// 999..999 rounds to 1000..000 with an increased exponent
160162
d[0] = b'1';
161-
for j in 1..d.len() {
162-
d[j] = b'0';
163-
}
163+
d.iter_mut().skip(1).for_each(|c| *c = b'0');
164164
Some(b'0')
165165
}
166-
None => {
167-
// an empty buffer rounds up (a bit strange but reasonable)
168-
Some(b'1')
169-
}
170166
}
171167
}
172168

library/core/src/num/int_log10.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// These functions compute the integer logarithm of their type, assuming
2-
/// that someone has already checked that the value is strictly positive.
1+
//! These functions compute the integer logarithm of their type, assuming
2+
//! that someone has already checked that the value is strictly positive.
33
44
// 0 < val <= u8::MAX
55
#[inline]

0 commit comments

Comments
 (0)