Rollup merge of #119449 - Nilstrieb:library-clippy, r=cuviper
Fix `clippy::correctness` in the library needs https://github.com/rust-lang/backtrace-rs/pull/579 to be complete for https://github.com/rust-lang/compiler-team/issues/709
This commit is contained in:
commit
0c5d8d3d3e
8 changed files with 16 additions and 0 deletions
|
@ -88,6 +88,7 @@ use crate::str;
|
||||||
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
|
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
|
||||||
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
|
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
|
||||||
#[cfg_attr(not(doc), repr(transparent))]
|
#[cfg_attr(not(doc), repr(transparent))]
|
||||||
|
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||||
pub struct CStr {
|
pub struct CStr {
|
||||||
// FIXME: this should not be represented with a DST slice but rather with
|
// FIXME: this should not be represented with a DST slice but rather with
|
||||||
// just a raw `c_char` along with some form of marker to make
|
// just a raw `c_char` along with some form of marker to make
|
||||||
|
|
|
@ -462,6 +462,7 @@ impl f32 {
|
||||||
/// and target platforms isn't guaranteed.
|
/// and target platforms isn't guaranteed.
|
||||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||||
#[rustc_diagnostic_item = "f32_nan"]
|
#[rustc_diagnostic_item = "f32_nan"]
|
||||||
|
#[allow(clippy::eq_op)]
|
||||||
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
|
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
|
||||||
/// Infinity (∞).
|
/// Infinity (∞).
|
||||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||||
|
@ -483,6 +484,7 @@ impl f32 {
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
|
||||||
pub const fn is_nan(self) -> bool {
|
pub const fn is_nan(self) -> bool {
|
||||||
self != self
|
self != self
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,6 +461,7 @@ impl f64 {
|
||||||
/// and target platforms isn't guaranteed.
|
/// and target platforms isn't guaranteed.
|
||||||
#[rustc_diagnostic_item = "f64_nan"]
|
#[rustc_diagnostic_item = "f64_nan"]
|
||||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||||
|
#[allow(clippy::eq_op)]
|
||||||
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
|
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
|
||||||
/// Infinity (∞).
|
/// Infinity (∞).
|
||||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||||
|
@ -482,6 +483,7 @@ impl f64 {
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
|
||||||
pub const fn is_nan(self) -> bool {
|
pub const fn is_nan(self) -> bool {
|
||||||
self != self
|
self != self
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,6 +567,7 @@ use crate::{
|
||||||
#[rustc_diagnostic_item = "Option"]
|
#[rustc_diagnostic_item = "Option"]
|
||||||
#[lang = "Option"]
|
#[lang = "Option"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow(clippy::derived_hash_with_manual_eq)] // PartialEq is specialized
|
||||||
pub enum Option<T> {
|
pub enum Option<T> {
|
||||||
/// No value.
|
/// No value.
|
||||||
#[lang = "None"]
|
#[lang = "None"]
|
||||||
|
|
|
@ -376,6 +376,8 @@
|
||||||
//! [Stacked Borrows]: https://plv.mpi-sws.org/rustbelt/stacked-borrows/
|
//! [Stacked Borrows]: https://plv.mpi-sws.org/rustbelt/stacked-borrows/
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
// There are many unsafe functions taking pointers that don't dereference them.
|
||||||
|
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||||
|
|
||||||
use crate::cmp::Ordering;
|
use crate::cmp::Ordering;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
|
|
|
@ -216,6 +216,10 @@
|
||||||
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))]
|
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))]
|
||||||
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))]
|
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))]
|
||||||
#![rustc_diagnostic_item = "atomic_mod"]
|
#![rustc_diagnostic_item = "atomic_mod"]
|
||||||
|
// Clippy complains about the pattern of "safe function calling unsafe function taking pointers".
|
||||||
|
// This happens with AtomicPtr intrinsics but is fine, as the pointers clippy is concerned about
|
||||||
|
// are just normal values that get loaded/stored, but not dereferenced.
|
||||||
|
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||||
|
|
||||||
use self::Ordering::*;
|
use self::Ordering::*;
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ impl Arena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::mut_from_ref)] // arena allocator
|
||||||
pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str {
|
pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str {
|
||||||
let alloc = self.alloc_raw(string.len());
|
let alloc = self.alloc_raw(string.len());
|
||||||
let bytes = MaybeUninit::write_slice(alloc, string.as_bytes());
|
let bytes = MaybeUninit::write_slice(alloc, string.as_bytes());
|
||||||
|
|
|
@ -201,6 +201,7 @@ impl ToString for TokenStream {
|
||||||
/// `TokenTree::Punct`, or `TokenTree::Literal`.
|
/// `TokenTree::Punct`, or `TokenTree::Literal`.
|
||||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||||
impl fmt::Display for TokenStream {
|
impl fmt::Display for TokenStream {
|
||||||
|
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str(&self.to_string())
|
f.write_str(&self.to_string())
|
||||||
}
|
}
|
||||||
|
@ -776,6 +777,7 @@ impl ToString for TokenTree {
|
||||||
/// `TokenTree::Punct`, or `TokenTree::Literal`.
|
/// `TokenTree::Punct`, or `TokenTree::Literal`.
|
||||||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||||
impl fmt::Display for TokenTree {
|
impl fmt::Display for TokenTree {
|
||||||
|
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str(&self.to_string())
|
f.write_str(&self.to_string())
|
||||||
}
|
}
|
||||||
|
@ -906,6 +908,7 @@ impl ToString for Group {
|
||||||
/// with `Delimiter::None` delimiters.
|
/// with `Delimiter::None` delimiters.
|
||||||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||||
impl fmt::Display for Group {
|
impl fmt::Display for Group {
|
||||||
|
#[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str(&self.to_string())
|
f.write_str(&self.to_string())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue