Skip to content

Fix multiple clippy issues #143423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions library/core/src/async_iter/async_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
5 changes: 3 additions & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,13 +1481,14 @@ pub trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
}
}

fn default_chaining_impl<T: PointeeSized, U: PointeeSized>(
fn default_chaining_impl<T, U>(
lhs: &T,
rhs: &U,
p: impl FnOnce(Ordering) -> bool,
) -> ControlFlow<bool>
where
T: PartialOrd<U>,
T: PartialOrd<U> + 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
Expand Down
1 change: 0 additions & 1 deletion library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion library/core/src/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ pub trait Extend<A> {
/// **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)]
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>
fn copied<'a, T: Copy + 'a>(self) -> Copied<Self>
where
Self: Sized + Iterator<Item = &'a T>,
T: Copy,
{
Copied::new(self)
}
Expand Down Expand Up @@ -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<Self>
fn cloned<'a, T: Clone + 'a>(self) -> Cloned<Self>
where
Self: Sized + Iterator<Item = &'a T>,
T: Clone,
{
Cloned::new(self)
}
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
1 change: 0 additions & 1 deletion library/core/src/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
18 changes: 7 additions & 11 deletions library/core/src/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,19 @@ pub fn round_up(d: &mut [u8]) -> Option<u8> {
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')
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/int_log10.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
20 changes: 10 additions & 10 deletions library/core/src/ptr/docs/as_uninit_slice.md
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>()` 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::<T>()` 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!

Expand Down
1 change: 0 additions & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,6 @@ impl str {
/// you're trying to parse into.
///
/// `parse` can parse into any type that implements the [`FromStr`] trait.

///
/// # Errors
///
Expand Down
Loading