From bcf2842751e484196000e85ab623918b25c9f8a2 Mon Sep 17 00:00:00 2001 From: Chrislearn Young Date: Mon, 11 Nov 2024 10:12:20 +0800 Subject: [PATCH] cargo clippy --- crates/core/src/conn/mod.rs | 1 - crates/core/src/conn/proto.rs | 4 ++-- crates/core/src/http/mod.rs | 2 +- crates/core/src/routing/filters/path.rs | 3 ++- crates/core/src/server.rs | 1 - crates/oapi-macros/src/component.rs | 4 ++-- crates/oapi-macros/src/operation/mod.rs | 4 ++-- crates/oapi-macros/src/response/derive.rs | 2 +- crates/oapi-macros/src/response/mod.rs | 4 ++-- crates/oapi-macros/src/schema/enum_variant.rs | 2 +- crates/oapi-macros/src/shared.rs | 2 +- crates/oapi-macros/tests/derive_to_schema_tests.rs | 1 + crates/oapi-macros/tests/endpoint_tests.rs | 1 + crates/oapi/src/openapi/mod.rs | 6 +++--- 14 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/core/src/conn/mod.rs b/crates/core/src/conn/mod.rs index 855d2863f..ae92311d7 100644 --- a/crates/core/src/conn/mod.rs +++ b/crates/core/src/conn/mod.rs @@ -162,7 +162,6 @@ impl Display for Holding { } /// `Listener` represents a listener that can bind to a specific address and port and return an acceptor. - pub trait Listener { /// Acceptor type. type Acceptor: Acceptor; diff --git a/crates/core/src/conn/proto.rs b/crates/core/src/conn/proto.rs index 0b846b592..fc31780db 100644 --- a/crates/core/src/conn/proto.rs +++ b/crates/core/src/conn/proto.rs @@ -238,7 +238,7 @@ impl HttpBuilder { #[allow(dead_code)] #[allow(clippy::future_not_send)] -pub(crate) async fn read_version<'a, A>(mut reader: A) -> IoResult<(Version, Rewind)> +pub(crate) async fn read_version(mut reader: A) -> IoResult<(Version, Rewind)> where A: AsyncRead + Unpin, { @@ -288,7 +288,7 @@ where if this.buf.filled() == H2_PREFACE { *this.version = Version::HTTP_2; } - return Poll::Ready(Ok((*this.version, this.buf.filled().to_vec()))); + Poll::Ready(Ok((*this.version, this.buf.filled().to_vec()))) } } diff --git a/crates/core/src/http/mod.rs b/crates/core/src/http/mod.rs index 0cee2920e..0b84eab5b 100644 --- a/crates/core/src/http/mod.rs +++ b/crates/core/src/http/mod.rs @@ -46,7 +46,7 @@ pub trait HttpConnection { fn fusewire(&self) -> Option; } -/// Get Http version from alph. +// /// Get Http version from alph. // pub fn version_from_alpn(proto: impl AsRef<[u8]>) -> Version { // if proto.as_ref().windows(2).any(|window| window == b"h2") { // Version::HTTP_2 diff --git a/crates/core/src/routing/filters/path.rs b/crates/core/src/routing/filters/path.rs index 4fc436a00..634e8fa27 100644 --- a/crates/core/src/routing/filters/path.rs +++ b/crates/core/src/routing/filters/path.rs @@ -313,6 +313,7 @@ impl CombWisp { let mut is_greedy = false; let mut wild_start = None; let mut wild_regex = None; + let any_chars_regex = Regex::new(".*").expect("regex should worked"); for wisp in wisps { match wisp { WispKind::Const(wisp) => { @@ -342,7 +343,7 @@ impl CombWisp { if wisp.0.starts_with('*') { is_greedy = true; let (star_mark, name) = crate::routing::split_wild_name(&wisp.0); - wild_regex = Some(Regex::new(".*").expect("regex should worked")); + wild_regex = Some(any_chars_regex.clone()); wild_start = Some(star_mark.to_owned()); names.push(name.to_owned()); } else { diff --git a/crates/core/src/server.rs b/crates/core/src/server.rs index f79f62724..050d3d2af 100644 --- a/crates/core/src/server.rs +++ b/crates/core/src/server.rs @@ -208,7 +208,6 @@ impl Server { /// /// ```no_run /// use salvo_core::prelude::*; - /// #[handler] /// async fn hello() -> &'static str { /// "Hello World" diff --git a/crates/oapi-macros/src/component.rs b/crates/oapi-macros/src/component.rs index 746999271..4047a5608 100644 --- a/crates/oapi-macros/src/component.rs +++ b/crates/oapi-macros/src/component.rs @@ -51,7 +51,7 @@ pub(crate) struct ComponentSchema { tokens: TokenStream, } -impl<'c> ComponentSchema { +impl ComponentSchema { pub(crate) fn new( ComponentSchemaProps { type_tree, @@ -519,7 +519,7 @@ impl<'c> ComponentSchema { Ok(()) } - pub(crate) fn get_deprecated(deprecated: Option<&'c Deprecated>) -> Option { + pub(crate) fn get_deprecated(deprecated: Option<&Deprecated>) -> Option { deprecated.map(|deprecated| quote! { .deprecated(#deprecated) }) } } diff --git a/crates/oapi-macros/src/operation/mod.rs b/crates/oapi-macros/src/operation/mod.rs index 4313f8b7d..ee279e8b0 100644 --- a/crates/oapi-macros/src/operation/mod.rs +++ b/crates/oapi-macros/src/operation/mod.rs @@ -217,7 +217,7 @@ enum Description<'a> { LitStrOrExpr(&'a LitStrOrExpr), Vec(&'a [String]), } -impl<'a> Description<'a> { +impl Description<'_> { fn is_empty(&self) -> bool { match self { Self::LitStrOrExpr(value) => value.is_empty(), @@ -250,7 +250,7 @@ enum Summary<'a> { LitStrOrExpr(&'a LitStrOrExpr), Str(&'a str), } -impl<'a> Summary<'a> { +impl Summary<'_> { pub(crate) fn is_empty(&self) -> bool { match self { Self::LitStrOrExpr(value) => value.is_empty(), diff --git a/crates/oapi-macros/src/response/derive.rs b/crates/oapi-macros/src/response/derive.rs index 0cda4f2a9..b9196f5e6 100644 --- a/crates/oapi-macros/src/response/derive.rs +++ b/crates/oapi-macros/src/response/derive.rs @@ -370,7 +370,7 @@ struct ToResponseNamedStructResponse<'p>(ResponseTuple<'p>); impl Response for ToResponseNamedStructResponse<'_> {} -impl<'p> ToResponseNamedStructResponse<'p> { +impl ToResponseNamedStructResponse<'_> { fn new( attributes: &[Attribute], ident: &Ident, diff --git a/crates/oapi-macros/src/response/mod.rs b/crates/oapi-macros/src/response/mod.rs index a7b4066e5..bc8ffbf21 100644 --- a/crates/oapi-macros/src/response/mod.rs +++ b/crates/oapi-macros/src/response/mod.rs @@ -210,13 +210,13 @@ pub(crate) struct DeriveResponsesAttributes { description: parse_utils::LitStrOrExpr, } -impl<'r> From> for ResponseValue<'r> { +impl From> for ResponseValue<'_> { fn from(value: DeriveResponsesAttributes) -> Self { Self::from_derive_to_responses_value(value.derive_value, value.description) } } -impl<'r> From>> for ResponseValue<'r> { +impl From>> for ResponseValue<'_> { fn from( DeriveResponsesAttributes::> { derive_value, diff --git a/crates/oapi-macros/src/schema/enum_variant.rs b/crates/oapi-macros/src/schema/enum_variant.rs index 7dc409bf6..22ebb18b3 100644 --- a/crates/oapi-macros/src/schema/enum_variant.rs +++ b/crates/oapi-macros/src/schema/enum_variant.rs @@ -375,7 +375,7 @@ impl<'c, T: ToTokens> CustomEnum<'c, T> { } } -impl<'c, T> ToTokens for CustomEnum<'c, T> +impl< T> ToTokens for CustomEnum<'_, T> where T: ToTokens, { diff --git a/crates/oapi-macros/src/shared.rs b/crates/oapi-macros/src/shared.rs index 539a33b18..1e5bab385 100644 --- a/crates/oapi-macros/src/shared.rs +++ b/crates/oapi-macros/src/shared.rs @@ -180,7 +180,7 @@ where } } -impl<'a, T> Deref for Array<'a, T> +impl Deref for Array<'_, T> where T: Sized + ToTokens, { diff --git a/crates/oapi-macros/tests/derive_to_schema_tests.rs b/crates/oapi-macros/tests/derive_to_schema_tests.rs index 125fcb418..39652fb51 100644 --- a/crates/oapi-macros/tests/derive_to_schema_tests.rs +++ b/crates/oapi-macros/tests/derive_to_schema_tests.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] use assert_json_diff::assert_json_eq; use salvo::oapi::extract::*; use salvo::prelude::*; diff --git a/crates/oapi-macros/tests/endpoint_tests.rs b/crates/oapi-macros/tests/endpoint_tests.rs index 7de21dbec..d4e1cbc6d 100644 --- a/crates/oapi-macros/tests/endpoint_tests.rs +++ b/crates/oapi-macros/tests/endpoint_tests.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] use assert_json_diff::assert_json_eq; use salvo::oapi::extract::*; use salvo::prelude::*; diff --git a/crates/oapi/src/openapi/mod.rs b/crates/oapi/src/openapi/mod.rs index 7fba3a42c..0aba13528 100644 --- a/crates/oapi/src/openapi/mod.rs +++ b/crates/oapi/src/openapi/mod.rs @@ -562,7 +562,7 @@ impl<'de> Deserialize<'de> for OpenApiVersion { { struct VersionVisitor; - impl<'v> Visitor<'v> for VersionVisitor { + impl Visitor<'_> for VersionVisitor { type Value = OpenApiVersion; fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result { @@ -636,7 +636,7 @@ impl<'de> Deserialize<'de> for Deprecated { D: serde::Deserializer<'de>, { struct BoolVisitor; - impl<'de> Visitor<'de> for BoolVisitor { + impl Visitor<'_> for BoolVisitor { type Value = Deprecated; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -696,7 +696,7 @@ impl<'de> Deserialize<'de> for Required { D: serde::Deserializer<'de>, { struct BoolVisitor; - impl<'de> Visitor<'de> for BoolVisitor { + impl Visitor<'_> for BoolVisitor { type Value = Required; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {