From 102746bc8f0e24c6ba1ddfb88dffcea5624e442b Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 6 Apr 2023 18:57:48 +0300 Subject: [PATCH] Apply clippy rule exclusion locally instead of a global approach (#3974) --- libs/pq_proto/src/lib.rs | 3 +++ run_clippy.sh | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libs/pq_proto/src/lib.rs b/libs/pq_proto/src/lib.rs index a976e19029..ed0239072a 100644 --- a/libs/pq_proto/src/lib.rs +++ b/libs/pq_proto/src/lib.rs @@ -293,6 +293,9 @@ impl FeStartupPacket { // We shouldn't advance `buf` as probably full message is not there yet, // so can't directly use Bytes::get_u32 etc. let len = (&buf[0..4]).read_u32::().unwrap() as usize; + // The proposed replacement is `!(4..=MAX_STARTUP_PACKET_LENGTH).contains(&len)` + // which is less readable + #[allow(clippy::manual_range_contains)] if len < 4 || len > MAX_STARTUP_PACKET_LENGTH { return Err(ProtocolError::Protocol(format!( "invalid startup packet message length {}", diff --git a/run_clippy.sh b/run_clippy.sh index ae9482ee96..9adfddedc2 100755 --- a/run_clippy.sh +++ b/run_clippy.sh @@ -8,13 +8,7 @@ # warnings and errors right in the editor. # In vscode, this setting is Rust-analyzer>Check On Save:Command -# manual-range-contains wants -# !(4..=MAX_STARTUP_PACKET_LENGTH).contains(&len) -# instead of -# len < 4 || len > MAX_STARTUP_PACKET_LENGTH -# , let's disagree. - # * `-A unknown_lints` – do not warn about unknown lint suppressions # that people with newer toolchains might use # * `-D warnings` - fail on any warnings (`cargo` returns non-zero exit status) -cargo clippy --locked --all --all-targets --all-features -- -A unknown_lints -A clippy::manual-range-contains -D warnings +cargo clippy --locked --all --all-targets --all-features -- -A unknown_lints -D warnings