Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8432202
clippy::manual_is_ascii_check
ChrisDenton Aug 12, 2026
563b112
clippy::manual_ignore_case_cmp
ChrisDenton Aug 12, 2026
5fa3b60
clippy::manual_hash_one
ChrisDenton Aug 12, 2026
7cf35bd
clippy::excessive_precision
ChrisDenton Aug 12, 2026
abce09f
clippy::partialeq_ne_impl
ChrisDenton Aug 12, 2026
d867667
clippy::manual_contains
ChrisDenton Aug 13, 2026
b6ef1ff
clippy::single_match
ChrisDenton Aug 13, 2026
fd0a93f
clippy::match_as_ref
ChrisDenton Aug 13, 2026
28f78d4
clippy::default_constructed_unit_structs
ChrisDenton Aug 13, 2026
a7f7b19
clippy::redundant_closure
ChrisDenton Aug 13, 2026
097f843
clippy::derivable_impls
ChrisDenton Aug 13, 2026
ff47e67
clippy::partialeq_to_none
ChrisDenton Aug 13, 2026
8523083
clippy::unnecessary_map_or
ChrisDenton Aug 13, 2026
64393eb
clippy::manual_clear
ChrisDenton Aug 13, 2026
30dc431
clippy::bind_instead_of_map
ChrisDenton Aug 13, 2026
5051bc3
clippy::redundant_slicing
ChrisDenton Aug 13, 2026
0348ed1
clippy::transmutes_expressible_as_ptr_casts
ChrisDenton Aug 13, 2026
4dae4ea
clippy::manual_repeat_n
ChrisDenton Aug 13, 2026
d1f1aae
clippy::to_digit_is_some
ChrisDenton Aug 18, 2026
4b68669
clippy::double_must_use
ChrisDenton Aug 18, 2026
7401901
clippy::seek_from_current
ChrisDenton Aug 18, 2026
641b3e5
clippy::mem_replace_option_with_some
ChrisDenton Aug 18, 2026
836a20f
clippy::mem_replace_option_with_none
ChrisDenton Aug 18, 2026
3fba07b
clippy::map_clone
ChrisDenton Aug 18, 2026
610a48e
clippy::declare_interior_mutable_const
ChrisDenton Aug 18, 2026
f591acd
clippy::assign_op_pattern
ChrisDenton Aug 18, 2026
31f7abc
clippy::chunks_exact_to_as_chunks
ChrisDenton Aug 18, 2026
4bed8e2
clippy::needless_raw_string_hashes
ChrisDenton Aug 19, 2026
428739b
clippy::approx_constant
ChrisDenton Aug 19, 2026
af533a1
clippy::neg_cmp_op_on_partial_ord
ChrisDenton Aug 12, 2026
9fa2a10
Ignore clippy failures in stdarch submodule
ChrisDenton Aug 18, 2026
79c0d27
Enforce even more clippy lints in CI
ChrisDenton Aug 18, 2026
4c8eac0
Allow lints on backtrace-rs
ChrisDenton Aug 19, 2026
aa9fe90
ignore clippy::redundant_pattern_matching
ChrisDenton Aug 19, 2026
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
3 changes: 0 additions & 3 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ impl<T: ?Sized + CloneToUninit> Box<T> {
/// ```
#[unstable(feature = "clone_from_ref", issue = "149075")]
//#[unstable(feature = "allocator_api", issue = "32838")]
#[must_use]
#[inline]
pub fn try_clone_from_ref(src: &T) -> Result<Box<T>, AllocError> {
Box::try_clone_from_ref_in(src, Global)
Expand Down Expand Up @@ -865,7 +864,6 @@ impl<T: ?Sized + CloneToUninit, A: Allocator> Box<T, A> {
/// ```
#[unstable(feature = "clone_from_ref", issue = "149075")]
//#[unstable(feature = "allocator_api", issue = "32838")]
#[must_use]
#[inline]
pub fn try_clone_from_ref_in(src: &T, alloc: A) -> Result<Box<T, A>, AllocError> {
struct DeallocDropGuard<'a, A: Allocator>(Layout, &'a A, NonNull<u8>);
Expand Down Expand Up @@ -1161,7 +1159,6 @@ impl<T, A: Allocator> Box<[T], A> {
/// ```
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
#[inline]
#[must_use]
pub fn into_array<const N: usize>(self) -> Result<Box<[T; N], A>, Self> {
if self.len() == N {
let (ptr, alloc) = Self::into_raw_with_allocator(self);
Expand Down
9 changes: 1 addition & 8 deletions library/alloc/src/bstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::vec::Vec;
/// showing invalid UTF-8 as hex escapes or the Unicode replacement character, respectively.
#[unstable(feature = "bstr", issue = "134915")]
#[repr(transparent)]
#[derive(Clone)]
#[derive(Clone, Default)]
#[doc(alias = "BString")]
pub struct ByteString(pub Vec<u8>);

Expand Down Expand Up @@ -187,13 +187,6 @@ impl BorrowMut<ByteStr> for ByteString {

// `impl BorrowMut<ByteStr> for Vec<u8>` omitted to avoid inference failures

#[unstable(feature = "bstr", issue = "134915")]
impl Default for ByteString {
fn default() -> Self {
ByteString(Vec::new())
}
}

// Omitted due to inference failures
//
// #[unstable(feature = "bstr", issue = "134915")]
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
pub fn clear(&mut self) {
// avoid moving the allocator
drop(BTreeMap {
root: mem::replace(&mut self.root, None),
root: self.root.take(),
length: mem::replace(&mut self.length, 0),
alloc: self.alloc.clone(),
_marker: PhantomData,
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
where
T: Ord,
{
self.map.insert(value, SetValZST::default()).is_none()
self.map.insert(value, SetValZST).is_none()
}

/// Adds a value to the set, replacing the existing element, if any, that is
Expand Down Expand Up @@ -1483,7 +1483,7 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {

impl<T: Ord, A: Allocator + Clone> BTreeSet<T, A> {
fn from_sorted_iter<I: Iterator<Item = T>>(iter: I, alloc: A) -> BTreeSet<T, A> {
let iter = iter.map(|k| (k, SetValZST::default()));
let iter = iter.map(|k| (k, SetValZST));
let map = BTreeMap::bulk_build_from_sorted_iter(iter, alloc);
BTreeSet { map }
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl<T, A: Allocator> LinkedList<T, A> {

// Fix the head ptr of the second part
self.head = Some(split_node);
self.len = self.len - at;
self.len -= at;

first_part
} else {
Expand Down
5 changes: 3 additions & 2 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// assert!(deque.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[expect(clippy::manual_clear, reason = "implements clear")]
#[inline]
pub fn clear(&mut self) {
self.truncate(0);
Expand Down Expand Up @@ -3312,7 +3313,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
F: FnMut(&'a T) -> Ordering,
{
let (front, back) = self.as_slices();
let cmp_back = back.first().map(|elem| f(elem));
let cmp_back = back.first().map(&mut f);

if let Some(Ordering::Equal) = cmp_back {
Ok(front.len())
Expand Down Expand Up @@ -3423,7 +3424,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
{
let (front, back) = self.as_slices();

if let Some(true) = back.first().map(|v| pred(v)) {
if let Some(true) = back.first().map(&mut pred) {
back.partition_point(pred) + front.len()
} else {
front.partition_point(pred)
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/io/buffered/bufreader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<R: Read + ?Sized> BufReader<R> {
let new = self.buf.read_more(&mut self.inner)?;
if new == 0 {
// end of file, no more bytes to read
return Ok(&self.buf.buffer()[..]);
return Ok(self.buf.buffer());
}
debug_assert_eq!(self.buf.pos(), 0);
}
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#![allow(unused_features)]
#![allow(incomplete_features)]
#![allow(unused_attributes)]
#![expect(clippy::partialeq_ne_impl, reason = "we need to implement ne for a lot of alloc types")]
#![stable(feature = "alloc", since = "1.36.0")]
#![doc(
html_playground_url = "https://play.rust-lang.org/",
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,6 @@ impl<T, A: Allocator> Rc<[T], A> {
/// ```
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
#[inline]
#[must_use]
pub fn into_array<const N: usize>(self) -> Result<Rc<[T; N], A>, Self> {
if self.len() == N {
let (ptr, alloc) = Self::into_raw_with_allocator(self);
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,6 @@ impl<T, A: Allocator> Arc<[T], A> {
/// ```
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
#[inline]
#[must_use]
pub fn into_array<const N: usize>(self) -> Result<Arc<[T; N], A>, Self> {
if self.len() == N {
let (ptr, alloc) = Self::into_raw_with_allocator(self);
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,6 @@ impl<T, A: Allocator> Vec<T, A> {
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
#[must_use]
pub fn into_array<const N: usize>(self) -> Result<Box<[T; N], A>, Self> {
if self.len() == N {
// SAFETY: `Box::into_array` is guaranteed to return `Ok` if the
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ascii/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ impl AsciiChar {
pub const fn eq_ignore_case(self, other: Self) -> bool {
// FIXME(const-hack) `arg.to_u8().to_ascii_lowercase()` -> `arg.to_lowercase()`
// once `PartialEq` is const for `Self`.
self.to_u8().to_ascii_lowercase() == other.to_u8().to_ascii_lowercase()
self.to_u8().eq_ignore_ascii_case(&other.to_u8())
}

/// Converts this value to its upper case equivalent in-place.
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! impl char {}

#![expect(clippy::manual_is_ascii_check, reason = "this module implements various is_ascii checks")]
Comment thread
clarfonthey marked this conversation as resolved.

use super::*;
use crate::panic::const_panic;
use crate::slice;
Expand Down Expand Up @@ -343,6 +345,7 @@ impl char {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_char_classify", since = "1.87.0")]
#[expect(clippy::to_digit_is_some, reason = "implements is_digit")]
#[inline]
pub const fn is_digit(self, radix: u32) -> bool {
self.to_digit(radix).is_some()
Expand Down Expand Up @@ -1985,6 +1988,7 @@ impl char {
/// [to_ascii_lowercase]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")]
#[expect(clippy::manual_ignore_case_cmp, reason = "implements eq_ignore_ascii_case")]
#[inline]
pub const fn eq_ignore_ascii_case(&self, other: &char) -> bool {
self.to_ascii_lowercase() == other.to_ascii_lowercase()
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<T: ?Sized, const VARIANT: u32, const FIELD: u32> Default
for FieldRepresentingType<T, VARIANT, FIELD>
{
fn default() -> Self {
Self { _phantom: PhantomData::default() }
Self { _phantom: PhantomData }
}
}

Expand Down
1 change: 1 addition & 0 deletions library/core/src/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ pub trait BuildHasher {
/// );
/// ```
#[stable(feature = "build_hasher_simple_hash_one", since = "1.71.0")]
#[expect(clippy::manual_hash_one, reason = "implements hash_one")]
fn hash_one<T: Hash>(&self, x: T) -> u64
Comment thread
ChrisDenton marked this conversation as resolved.
where
Self: Sized,
Expand Down
11 changes: 3 additions & 8 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2915,14 +2915,9 @@ pub const fn contract_check_ensures<C: Fn(&Ret) -> bool + Copy, Ret>(
// Do nothing
ret
} else {
match cond {
crate::option::Option::Some(cond) => {
Comment thread
ChrisDenton marked this conversation as resolved.
if !cond(&ret) {
// Emit no unwind panic in case this was a safety requirement.
crate::panicking::panic_nounwind("failed ensures check");
}
},
crate::option::Option::None => {},
if let crate::option::Option::Some(cond) = cond && !cond(&ret) {
// Emit no unwind panic in case this was a safety requirement.
crate::panicking::panic_nounwind("failed ensures check");
}
ret
}
Expand Down
1 change: 0 additions & 1 deletion library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ impl Error {

#[doc(hidden)]
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[must_use]
#[inline]
pub fn into_custom_owner(self) -> result::Result<CustomOwner, Self> {
if matches!(self.repr.data(), ErrorData::Custom(..)) {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/io/seek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub trait Seek {
/// }
/// ```
#[stable(feature = "seek_convenience", since = "1.51.0")]
#[expect(clippy::seek_from_current, reason = "implements stream_position")]
fn stream_position(&mut self) -> Result<u64> {
self.seek(SeekFrom::Current(0))
}
Expand Down
8 changes: 7 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
#![feature(x86_amx_intrinsics)]
// tidy-alphabetical-end

// tidy-alphabetical-start
#![expect(clippy::partialeq_ne_impl, reason = "we need to implement ne for a lot of core types")]
// tidy-alphabetical-end

// allow using `core::` in intra-doc links
#[allow(unused_extern_crates)]
extern crate self as core;
Expand Down Expand Up @@ -359,7 +363,9 @@ pub mod primitive;
unsafe_op_in_unsafe_fn,
ambiguous_glob_reexports,
deprecated_in_future,
unreachable_pub
unreachable_pub,
// FIXME: stdach is a submodule so clippy lints should be fixed (and ideally enforced) there
clippy::all,
)]
#[allow(rustdoc::bare_urls)]
mod core_arch;
Expand Down
5 changes: 4 additions & 1 deletion library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! defined directly on the `f128` type.

#![unstable(feature = "f128", issue = "116909")]
#![expect(clippy::approx_constant, reason = "this module defines f128 constants")]

use crate::convert::{FloatToFloat, FloatToInt};
use crate::num::FpCategory;
Expand Down Expand Up @@ -1499,6 +1500,7 @@ impl f128 {
#[inline]
#[unstable(feature = "f128", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "NaN is also invalid")]
pub const fn clamp(mut self, min: f128, max: f128) -> f128 {
const_assert!(
min <= max,
Expand Down Expand Up @@ -1543,8 +1545,9 @@ impl f128 {
#[inline]
#[unstable(feature = "clamp_magnitude", issue = "148519")]
#[must_use = "this returns the clamped value and does not modify the original"]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "NaN is also invalid")]
pub fn clamp_magnitude(self, limit: f128) -> f128 {
assert!(limit >= 0.0, "limit must be non-negative");
assert!(limit >= 0.0, "limit must be non-negative and not NaN");
let limit = limit.abs(); // Canonicalises -0.0 to 0.0
self.clamp(-limit, limit)
}
Expand Down
5 changes: 4 additions & 1 deletion library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! defined directly on the `f16` type.

#![unstable(feature = "f16", issue = "116909")]
#![expect(clippy::approx_constant, reason = "this module defines f16 constants")]

use crate::convert::{FloatToFloat, FloatToInt};
use crate::num::FpCategory;
Expand Down Expand Up @@ -1485,6 +1486,7 @@ impl f16 {
#[inline]
#[unstable(feature = "f16", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "NaN is also invalid")]
pub const fn clamp(mut self, min: f16, max: f16) -> f16 {
const_assert!(
min <= max,
Expand Down Expand Up @@ -1529,8 +1531,9 @@ impl f16 {
#[inline]
#[unstable(feature = "clamp_magnitude", issue = "148519")]
#[must_use = "this returns the clamped value and does not modify the original"]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "NaN is also invalid")]
pub fn clamp_magnitude(self, limit: f16) -> f16 {
assert!(limit >= 0.0, "limit must be non-negative");
assert!(limit >= 0.0, "limit must be non-negative and not NaN");
let limit = limit.abs(); // Canonicalises -0.0 to 0.0
self.clamp(-limit, limit)
}
Expand Down
13 changes: 8 additions & 5 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! defined directly on the `f32` type.

#![stable(feature = "rust1", since = "1.0.0")]
#![expect(clippy::approx_constant, reason = "this module defines f32 constants")]

use crate::convert::{FloatToFloat, FloatToInt};
use crate::num::FpCategory;
Expand Down Expand Up @@ -438,22 +439,22 @@ impl f32 {
/// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
#[rustc_diagnostic_item = "f32_epsilon"]
pub const EPSILON: f32 = 1.19209290e-07_f32;
pub const EPSILON: f32 = 1.1920929e-07_f32;

/// Smallest finite `f32` value.
///
/// Equal to &minus;[`MAX`].
///
/// [`MAX`]: f32::MAX
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN: f32 = -3.40282347e+38_f32;
Comment thread
ChrisDenton marked this conversation as resolved.
pub const MIN: f32 = -3.4028235e+38_f32;
/// Smallest positive normal `f32` value.
///
/// Equal to 2<sup>[`MIN_EXP`]&nbsp;&minus;&nbsp;1</sup>.
///
/// [`MIN_EXP`]: f32::MIN_EXP
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
pub const MIN_POSITIVE: f32 = 1.1754944e-38_f32;
/// Largest finite `f32` value.
///
/// Equal to
Expand All @@ -462,7 +463,7 @@ impl f32 {
/// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
/// [`MAX_EXP`]: f32::MAX_EXP
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MAX: f32 = 3.40282347e+38_f32;
pub const MAX: f32 = 3.4028235e+38_f32;

/// One greater than the minimum possible *normal* power of 2 exponent
/// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition).
Expand Down Expand Up @@ -1659,6 +1660,7 @@ impl f32 {
#[stable(feature = "clamp", since = "1.50.0")]
#[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")]
#[inline]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "Nan is also invalid")]
pub const fn clamp(mut self, min: f32, max: f32) -> f32 {
const_assert!(
min <= max,
Expand Down Expand Up @@ -1700,8 +1702,9 @@ impl f32 {
#[must_use = "this returns the clamped value and does not modify the original"]
#[unstable(feature = "clamp_magnitude", issue = "148519")]
#[inline]
#[expect(clippy::neg_cmp_op_on_partial_ord, reason = "NaN is also invalid")]
pub fn clamp_magnitude(self, limit: f32) -> f32 {
assert!(limit >= 0.0, "limit must be non-negative");
assert!(limit >= 0.0, "limit must be non-negative and not NaN");
let limit = limit.abs(); // Canonicalises -0.0 to 0.0
self.clamp(-limit, limit)
}
Expand Down
Loading
Loading