Skip to content
Merged
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
4 changes: 2 additions & 2 deletions crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5524,8 +5524,8 @@ impl Compiler {
"too many sub-patterns in mapping pattern".to_string(),
)));
}
#[allow(clippy::cast_possible_truncation)]
let size = size as u32; // checked right before
#[allow(clippy::cast_possible_truncation, reason = "checked right before")]
let size = size as u32;

// Step 2: If we have keys to match
if size > 0 {
Expand Down
10 changes: 8 additions & 2 deletions crates/common/src/lock/cell_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ pub struct RawCellMutex {
}

unsafe impl RawMutex for RawCellMutex {
#[allow(clippy::declare_interior_mutable_const)]
#[allow(
clippy::declare_interior_mutable_const,
reason = "const lock initializer intentionally uses interior mutability"
)]
const INIT: Self = Self {
locked: Cell::new(false),
};
Expand Down Expand Up @@ -60,7 +63,10 @@ impl RawCellRwLock {
}

unsafe impl RawRwLock for RawCellRwLock {
#[allow(clippy::declare_interior_mutable_const)]
#[allow(
clippy::declare_interior_mutable_const,
reason = "const rwlock initializer intentionally uses interior mutability"
)]
const INIT: Self = Self {
state: Cell::new(0),
};
Expand Down
5 changes: 4 additions & 1 deletion crates/common/src/lock/thread_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ pub struct RawThreadMutex<R: RawMutex, G: GetThreadId> {
}

impl<R: RawMutex, G: GetThreadId> RawThreadMutex<R, G> {
#[allow(clippy::declare_interior_mutable_const)]
#[allow(
clippy::declare_interior_mutable_const,
reason = "const initializer for lock primitive contains atomics by design"
)]
pub const INIT: Self = Self {
owner: AtomicUsize::new(0),
mutex: R::INIT,
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ pub mod levenshtein {

pub fn levenshtein_distance(a: &[u8], b: &[u8], max_cost: usize) -> usize {
thread_local! {
#[allow(clippy::declare_interior_mutable_const)]
#[allow(clippy::declare_interior_mutable_const, reason = "thread-local scratch buffer uses const initializer with RefCell")]
static BUFFER: RefCell<[usize; MAX_STRING_SIZE]> = const {
RefCell::new([0usize; MAX_STRING_SIZE])
};
Expand Down
2 changes: 1 addition & 1 deletion crates/derive-impl/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ItemNursery {
impl ToTokens for ValidatedItemNursery {
fn to_tokens(&self, tokens: &mut TokenStream) {
let mut sorted = self.0.0.clone();
sorted.sort_by(|a, b| a.sort_order.cmp(&b.sort_order));
sorted.sort_by_key(|a| a.sort_order);
tokens.extend(sorted.iter().map(|item| {
let cfgs = &item.cfgs;
let tokens = &item.tokens;
Expand Down
6 changes: 4 additions & 2 deletions crates/sre_engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ fn _match<S: StrDrive>(req: &Request<'_, S>, state: &mut State, mut ctx: MatchCo
let mut context_stack = vec![];
let mut popped_result = false;

// NOTE: 'result loop is not an actual loop but break label
#[allow(clippy::never_loop)]
#[allow(
clippy::never_loop,
reason = "'result loop is not an actual loop but break label"
)]
'coro: loop {
popped_result = 'result: loop {
let yielded = 'context: loop {
Expand Down
10 changes: 8 additions & 2 deletions crates/stdlib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ fn main() {
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
println!(r#"cargo::rustc-check-cfg=cfg(openssl_vendored)"#);

#[allow(clippy::unusual_byte_groupings)]
#[allow(
clippy::unusual_byte_groupings,
reason = "hex groups follow OpenSSL version field boundaries"
)]
let ossl_vers = [
(0x1_00_01_00_0, "ossl101"),
(0x1_00_02_00_0, "ossl102"),
Expand All @@ -25,7 +28,10 @@ fn main() {

#[cfg(feature = "ssl-openssl")]
{
#[allow(clippy::unusual_byte_groupings)]
#[allow(
clippy::unusual_byte_groupings,
reason = "OpenSSL version number is parsed with grouped hex fields"
)]
if let Ok(v) = std::env::var("DEP_OPENSSL_VERSION_NUMBER") {
println!("cargo:rustc-env=OPENSSL_API_VERSION={v}");
// cfg setup from openssl crate's build script
Expand Down
5 changes: 4 additions & 1 deletion crates/stdlib/src/json/machinery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ static ESCAPE_CHARS: [&str; 0x20] = [
// And which one need to be escaped (1)
// The characters that need escaping are 0x00 to 0x1F, 0x22 ("), 0x5C (\), 0x7F (DEL)
// Non-ASCII unicode characters can be safely included in a JSON string
#[allow(clippy::unusual_byte_groupings)] // it's groups of 16, come on clippy
#[allow(
clippy::unusual_byte_groupings,
reason = "groups of 16 are intentional here"
)]
static NEEDS_ESCAPING_BITSET: [u64; 4] = [
//fedcba9876543210_fedcba9876543210_fedcba9876543210_fedcba9876543210
0b0000000000000000_0000000000000100_1111111111111111_1111111111111111, // 3_2_1_0
Expand Down
5 changes: 4 additions & 1 deletion crates/stdlib/src/overlapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,10 @@ mod _overlapped {
}

// TransmitFile
#[allow(clippy::too_many_arguments)]
#[allow(
clippy::too_many_arguments,
reason = "mirrors Windows TransmitFile argument structure"
)]
#[pymethod]
fn TransmitFile(
zelf: &Py<Self>,
Expand Down
10 changes: 8 additions & 2 deletions crates/stdlib/src/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ mod _statistics {
use crate::vm::{PyResult, VirtualMachine, function::ArgIntoFloat};

// See https://github.com/python/cpython/blob/6846d6712a0894f8e1a91716c11dd79f42864216/Modules/_statisticsmodule.c#L28-L120
#[allow(clippy::excessive_precision)]
#[allow(
clippy::excessive_precision,
reason = "constants are kept at CPython precision"
)]
fn normal_dist_inv_cdf(p: f64, mu: f64, sigma: f64) -> Option<f64> {
if p <= 0.0 || p >= 1.0 {
return None;
Expand Down Expand Up @@ -53,7 +56,10 @@ mod _statistics {
let r = (-(r.ln())).sqrt();
let num;
let den;
#[allow(clippy::excessive_precision)]
#[allow(
clippy::excessive_precision,
reason = "piecewise polynomial coefficients match CPython"
)]
if r <= 5.0 {
let r = r - 1.6;
// Hash sum-49.33206503301610289036
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,6 @@ impl PyPayload for PyBoundMethod {
impl Representable for PyBoundMethod {
#[inline]
fn repr_str(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
#[allow(clippy::needless_match)] // False positive on nightly
let func_name =
if let Some(qname) = vm.get_attribute_opt(zelf.function.clone(), "__qualname__")? {
Some(qname)
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/builtins/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ impl PyModuleDef {
}
}

#[allow(clippy::new_without_default)] // avoid Default implementation
#[allow(
clippy::new_without_default,
reason = "avoid a misleading Default implementation"
)]
#[pyclass(module = false, name = "module")]
#[derive(Debug)]
pub struct PyModule {
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/builtins/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ pub trait AsPyStr<'a>
where
Self: 'a,
{
#[allow(clippy::wrong_self_convention)] // to implement on refs
#[allow(
clippy::wrong_self_convention,
reason = "this trait is intentionally implemented for references"
)]
fn as_pystr(self, ctx: &Context) -> &'a Py<PyStr>;
}

Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,10 @@ impl ExceptionZoo {
}

// TODO: remove it after fixing `errno` / `winerror` problem
#[allow(clippy::redundant_clone)]
#[allow(
clippy::redundant_clone,
reason = "temporary workaround until errno/winerror handling is fixed"
)]
pub fn extend(ctx: &Context) {
use self::types::*;

Expand Down
6 changes: 3 additions & 3 deletions crates/vm/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ macro_rules! match_class {

// The default arm, binding the original object to the specified identifier.
(match ($obj:expr) { $binding:ident => $default:expr $(,)? }) => {{
#[allow(clippy::redundant_locals)]
#[allow(clippy::redundant_locals, reason = "macro arm intentionally binds expression once to a local")]
let $binding = $obj;
$default
}};
(match ($obj:expr) { ref $binding:ident => $default:expr $(,)? }) => {{
#[allow(clippy::redundant_locals)]
#[allow(clippy::redundant_locals, reason = "macro arm intentionally binds expression once to a local reference")]
let $binding = &$obj;
$default
}};
Expand Down Expand Up @@ -190,7 +190,7 @@ macro_rules! identifier(
macro_rules! identifier_utf8(
($as_ctx:expr, $name:ident) => {
// Safety: All known identifiers are ascii strings.
#[allow(clippy::macro_metavars_in_unsafe)]
#[allow(clippy::macro_metavars_in_unsafe, reason = "known identifiers are ASCII and downcast target is fixed")]
unsafe { $as_ctx.as_ref().names.$name.as_object().downcast_unchecked_ref::<$crate::builtins::PyUtf8Str>() }
};
);
Expand Down
3 changes: 1 addition & 2 deletions crates/vm/src/object/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ pub struct PyWeak {

cfg_if::cfg_if! {
if #[cfg(feature = "threading")] {
#[allow(clippy::non_send_fields_in_send_ty)] // false positive?
unsafe impl Send for PyWeak {}
unsafe impl Sync for PyWeak {}
}
Expand Down Expand Up @@ -1631,7 +1630,7 @@ macro_rules! partially_init {
) => {{
// check all the fields are there but *don't* actually run it

#[allow(clippy::diverging_sub_expression)] // FIXME: better way than using `if false`?
#[allow(clippy::diverging_sub_expression, reason = "intentional compile-time field check in an unreachable branch")]
if false {
#[allow(invalid_value, dead_code, unreachable_code)]
let _ = {$ty {
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use std::sync::mpsc;
pub(crate) const NSIG: usize = 64;
static ANY_TRIGGERED: AtomicBool = AtomicBool::new(false);
// hack to get around const array repeat expressions, rust issue #79270
#[allow(clippy::declare_interior_mutable_const)]
#[allow(
clippy::declare_interior_mutable_const,
reason = "workaround for const array repeat limitation (rust issue #79270)"
)]
const ATOMIC_FALSE: AtomicBool = AtomicBool::new(false);
pub(crate) static TRIGGERS: [AtomicBool; NSIG] = [ATOMIC_FALSE; NSIG];

Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/stdlib/ctypes/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,10 @@ pub(super) fn bytes_to_pyobject(
let wchars =
unsafe { core::slice::from_raw_parts(ptr as *const libc::wchar_t, len) };
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::unnecessary_cast)]
#[allow(
clippy::unnecessary_cast,
reason = "wchar_t is i32 on some platforms and u32 on others"
)]
let s: String = wchars
.iter()
.filter_map(|&c| char::from_u32(c as u32))
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/stdlib/winapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ mod _winapi {

/// CreateFile - Create or open a file or I/O device.
#[pyfunction]
#[allow(clippy::too_many_arguments)]
#[allow(
clippy::too_many_arguments,
reason = "matches Win32 CreateFile parameter structure"
)]
fn CreateFile(
file_name: PyStrRef,
desired_access: u32,
Expand Down
Loading