Skip to content

Commit 0c5d8d3

Browse files
authored
Rollup merge of rust-lang#119449 - Nilstrieb:library-clippy, r=cuviper
Fix `clippy::correctness` in the library needs rust-lang/backtrace-rs#579 to be complete for rust-lang/compiler-team#709
2 parents a576e81 + e55716e commit 0c5d8d3

File tree

8 files changed

+16
-0
lines changed

8 files changed

+16
-0
lines changed

library/core/src/ffi/c_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ use crate::str;
8888
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
8989
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
9090
#[cfg_attr(not(doc), repr(transparent))]
91+
#[allow(clippy::derived_hash_with_manual_eq)]
9192
pub struct CStr {
9293
// FIXME: this should not be represented with a DST slice but rather with
9394
// just a raw `c_char` along with some form of marker to make

library/core/src/num/f32.rs

+2
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ impl f32 {
462462
/// and target platforms isn't guaranteed.
463463
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
464464
#[rustc_diagnostic_item = "f32_nan"]
465+
#[allow(clippy::eq_op)]
465466
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
466467
/// Infinity (∞).
467468
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
@@ -483,6 +484,7 @@ impl f32 {
483484
#[stable(feature = "rust1", since = "1.0.0")]
484485
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
485486
#[inline]
487+
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
486488
pub const fn is_nan(self) -> bool {
487489
self != self
488490
}

library/core/src/num/f64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ impl f64 {
461461
/// and target platforms isn't guaranteed.
462462
#[rustc_diagnostic_item = "f64_nan"]
463463
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
464+
#[allow(clippy::eq_op)]
464465
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
465466
/// Infinity (∞).
466467
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
@@ -482,6 +483,7 @@ impl f64 {
482483
#[stable(feature = "rust1", since = "1.0.0")]
483484
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
484485
#[inline]
486+
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
485487
pub const fn is_nan(self) -> bool {
486488
self != self
487489
}

library/core/src/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ use crate::{
567567
#[rustc_diagnostic_item = "Option"]
568568
#[lang = "Option"]
569569
#[stable(feature = "rust1", since = "1.0.0")]
570+
#[allow(clippy::derived_hash_with_manual_eq)] // PartialEq is specialized
570571
pub enum Option<T> {
571572
/// No value.
572573
#[lang = "None"]

library/core/src/ptr/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@
376376
//! [Stacked Borrows]: https://plv.mpi-sws.org/rustbelt/stacked-borrows/
377377
378378
#![stable(feature = "rust1", since = "1.0.0")]
379+
// There are many unsafe functions taking pointers that don't dereference them.
380+
#![allow(clippy::not_unsafe_ptr_arg_deref)]
379381

380382
use crate::cmp::Ordering;
381383
use crate::fmt;

library/core/src/sync/atomic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@
216216
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))]
217217
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))]
218218
#![rustc_diagnostic_item = "atomic_mod"]
219+
// Clippy complains about the pattern of "safe function calling unsafe function taking pointers".
220+
// This happens with AtomicPtr intrinsics but is fine, as the pointers clippy is concerned about
221+
// are just normal values that get loaded/stored, but not dereferenced.
222+
#![allow(clippy::not_unsafe_ptr_arg_deref)]
219223

220224
use self::Ordering::*;
221225

library/proc_macro/src/bridge/arena.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl Arena {
102102
}
103103
}
104104

105+
#[allow(clippy::mut_from_ref)] // arena allocator
105106
pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str {
106107
let alloc = self.alloc_raw(string.len());
107108
let bytes = MaybeUninit::write_slice(alloc, string.as_bytes());

library/proc_macro/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ impl ToString for TokenStream {
201201
/// `TokenTree::Punct`, or `TokenTree::Literal`.
202202
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
203203
impl fmt::Display for TokenStream {
204+
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
204205
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205206
f.write_str(&self.to_string())
206207
}
@@ -776,6 +777,7 @@ impl ToString for TokenTree {
776777
/// `TokenTree::Punct`, or `TokenTree::Literal`.
777778
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
778779
impl fmt::Display for TokenTree {
780+
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
779781
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
780782
f.write_str(&self.to_string())
781783
}
@@ -906,6 +908,7 @@ impl ToString for Group {
906908
/// with `Delimiter::None` delimiters.
907909
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
908910
impl fmt::Display for Group {
911+
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
909912
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
910913
f.write_str(&self.to_string())
911914
}

0 commit comments

Comments
 (0)