From 15ac0148ea01df0173a9b45eddf556b669117784 Mon Sep 17 00:00:00 2001 From: arlecchino Date: Mon, 23 Sep 2024 18:26:33 +0200 Subject: [PATCH] chore: allow clippy for MSRV 1.81 compatibility --- src/common/content_type.rs | 5 ++++- src/common/range_header.rs | 3 ++- src/response/util.rs | 7 ++++++- tests/non-chunked-buffering.rs | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/common/content_type.rs b/src/common/content_type.rs index 63143c13..bcd61b6b 100644 --- a/src/common/content_type.rs +++ b/src/common/content_type.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "content-type")] +// #![cfg(feature = "content-type")] use ascii::{AsciiStr, AsciiString}; use std::collections::HashMap; @@ -215,6 +215,7 @@ impl TryFrom<&AsciiStr> for ContentType { } #[cfg(test)] +#[cfg(feature = "content-type")] mod tests { use std::{convert::TryFrom, str::FromStr}; @@ -223,6 +224,7 @@ mod tests { use super::{content_type_lookup, CONTENT_TYPES}; #[test] + #[allow(clippy::const_is_empty)] fn content_types_test() { assert!(!CONTENT_TYPES.is_empty()); for (n, mt) in CONTENT_TYPES.iter().enumerate() { @@ -236,6 +238,7 @@ mod tests { } #[test] + #[allow(clippy::const_is_empty)] fn content_type_lookup_test() { assert!(!CONTENT_TYPES.is_empty()); for mt in CONTENT_TYPES { diff --git a/src/common/range_header.rs b/src/common/range_header.rs index b481d1e2..1c6ed74e 100644 --- a/src/common/range_header.rs +++ b/src/common/range_header.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "range-support")] +// #![cfg(feature = "range-support")] //! HTTP/1.1 supports [Range Requests](https://datatracker.ietf.org/doc/html/rfc9110#name-range-requests) use std::convert::TryFrom; @@ -623,6 +623,7 @@ pub(crate) mod response { } #[cfg(test)] +#[cfg(feature = "range-support")] mod tests { use std::str::FromStr; diff --git a/src/response/util.rs b/src/response/util.rs index 12e8852b..895db862 100644 --- a/src/response/util.rs +++ b/src/response/util.rs @@ -164,7 +164,11 @@ macro_rules! number_to_bytes { while n > 0 { idx -= 1; - #[allow(clippy::cast_possible_truncation, trivial_numeric_casts)] + #[allow( + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + trivial_numeric_casts + )] // truncation intended { digits[idx] = (n % 10) as u8 + 48; @@ -300,6 +304,7 @@ pub(super) fn write_body( } #[inline] +#[allow(clippy::byte_char_slices)] pub(super) fn write_message_header( writer: &mut W, http_version: HttpVersion, diff --git a/tests/non-chunked-buffering.rs b/tests/non-chunked-buffering.rs index 1accda6e..4637589e 100644 --- a/tests/non-chunked-buffering.rs +++ b/tests/non-chunked-buffering.rs @@ -44,6 +44,7 @@ fn big_response_reader() -> Reader { fn identity_served(r: &mut Reader) -> tiny_http::Response<&mut Reader> { let body_len = r.inner.get_ref().len(); + #[allow(clippy::legacy_numeric_constants)] tiny_http::Response::empty(200) .with_chunked_threshold(std::usize::MAX) .with_data(r, Some(body_len))