From 2e1de9010ddd03c71939167e5f6de3617d5d55a9 Mon Sep 17 00:00:00 2001 From: Fredrik Enestad Date: Thu, 28 Nov 2024 15:55:00 +0100 Subject: [PATCH] Run cargo clippy --fix (#1605) New lints with rust 1.83 --- runtimes/core/src/api/jsonschema/de.rs | 16 ++++++++-------- runtimes/core/src/api/jsonschema/meta.rs | 2 +- runtimes/core/src/api/jsonschema/ser.rs | 2 +- runtimes/core/src/sqldb/manager.rs | 2 +- runtimes/core/src/trace/protocol.rs | 2 +- tsparser/src/legacymeta/mod.rs | 2 +- tsparser/src/legacymeta/schema.rs | 2 +- tsparser/src/parser/parser.rs | 2 +- .../src/parser/resourceparser/resource_parser.rs | 2 +- tsparser/src/parser/resources/parseutil.rs | 2 +- tsparser/src/parser/service_discovery.rs | 2 +- tsparser/src/parser/types/resolved.rs | 2 +- tsparser/src/parser/types/type_resolve.rs | 6 +++--- tsparser/src/parser/usageparser/mod.rs | 4 ++-- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/runtimes/core/src/api/jsonschema/de.rs b/runtimes/core/src/api/jsonschema/de.rs index c61084e5e3..c84a209496 100644 --- a/runtimes/core/src/api/jsonschema/de.rs +++ b/runtimes/core/src/api/jsonschema/de.rs @@ -290,7 +290,7 @@ macro_rules! recurse0 { }}; } -impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { +impl<'de> Visitor<'de> for DecodeValue<'_> { type Value = PValue; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -492,7 +492,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { serde::de::Error::custom(format_args!("invalid datetime: {}", e,)) }), Basic::Bool if self.cfg.coerce_strings => { - return if value == "true" { + if value == "true" { Ok(PValue::Bool(true)) } else if value == "false" { Ok(PValue::Bool(false)) @@ -504,7 +504,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { } } Basic::Number if self.cfg.coerce_strings => { - return if let Ok(num) = value.parse::() { + if let Ok(num) = value.parse::() { Ok(PValue::Number(num.into())) } else if let Ok(num) = value.parse::() { Ok(JSONNumber::from_f64(num).map_or(PValue::Null, PValue::Number)) @@ -516,7 +516,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { } } Basic::Null if self.cfg.coerce_strings => { - return if value == "null" { + if value == "null" { Ok(PValue::Null) } else { Err(serde::de::Error::custom(format_args!( @@ -539,7 +539,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { Value::Literal(lit) => match lit { Literal::Str(val) if val.as_str() == value => Ok(PValue::String(value)), Literal::Bool(_) if self.cfg.coerce_strings => { - return if let Ok(got) = value.parse::() { + if let Ok(got) = value.parse::() { self.visit_bool(got) } else { Err(serde::de::Error::custom(format_args!( @@ -550,7 +550,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { } } Literal::Int(_) if self.cfg.coerce_strings => { - return if let Ok(got) = value.parse::() { + if let Ok(got) = value.parse::() { self.visit_i64(got) } else { Err(serde::de::Error::custom(format_args!( @@ -561,7 +561,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> { } } Literal::Float(_) if self.cfg.coerce_strings => { - return if let Ok(got) = value.parse::() { + if let Ok(got) = value.parse::() { self.visit_f64(got) } else { Err(serde::de::Error::custom(format_args!( @@ -886,7 +886,7 @@ struct FieldList<'a> { names: &'a [&'a str], } -impl<'a> DecodeValue<'a> { +impl DecodeValue<'_> { #[cfg_attr( feature = "rttrace", tracing::instrument(skip(self), ret, level = "trace") diff --git a/runtimes/core/src/api/jsonschema/meta.rs b/runtimes/core/src/api/jsonschema/meta.rs index fff34427f3..8d57dc7ded 100644 --- a/runtimes/core/src/api/jsonschema/meta.rs +++ b/runtimes/core/src/api/jsonschema/meta.rs @@ -106,7 +106,7 @@ impl<'a> Builder<'a> { } } -impl<'a, 'b> BuilderCtx<'a, 'b> { +impl BuilderCtx<'_, '_> { /// Computes the JSONSchema value for the given type. #[inline] fn typ(&mut self, typ: T) -> Result { diff --git a/runtimes/core/src/api/jsonschema/ser.rs b/runtimes/core/src/api/jsonschema/ser.rs index 34c0e52a9d..6bc4dc1862 100644 --- a/runtimes/core/src/api/jsonschema/ser.rs +++ b/runtimes/core/src/api/jsonschema/ser.rs @@ -7,7 +7,7 @@ struct SchemaSerializeWrapper<'a> { payload: &'a JSONPayload, } -impl<'a> Serialize for SchemaSerializeWrapper<'a> { +impl Serialize for SchemaSerializeWrapper<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/runtimes/core/src/sqldb/manager.rs b/runtimes/core/src/sqldb/manager.rs index 5002c26bb1..be54fd9001 100644 --- a/runtimes/core/src/sqldb/manager.rs +++ b/runtimes/core/src/sqldb/manager.rs @@ -27,7 +27,7 @@ pub struct ManagerConfig<'a> { pub runtime: tokio::runtime::Handle, } -impl<'a> ManagerConfig<'a> { +impl ManagerConfig<'_> { pub fn build(self) -> anyhow::Result { // Start listening so we can tell which port it is when we generate configuration. let listener = diff --git a/runtimes/core/src/trace/protocol.rs b/runtimes/core/src/trace/protocol.rs index c8da590f7f..6ec715d7a5 100644 --- a/runtimes/core/src/trace/protocol.rs +++ b/runtimes/core/src/trace/protocol.rs @@ -76,7 +76,7 @@ pub struct LogMessageData<'a, I> { pub fields: Option, } -impl<'a, I> LogMessageData<'a, I> { +impl LogMessageData<'_, I> { fn level_byte(&self) -> u8 { match self.level { log::Level::Error => 4, diff --git a/tsparser/src/legacymeta/mod.rs b/tsparser/src/legacymeta/mod.rs index 0a3409f98b..26b939f88a 100644 --- a/tsparser/src/legacymeta/mod.rs +++ b/tsparser/src/legacymeta/mod.rs @@ -45,7 +45,7 @@ struct MetaBuilder<'a> { data: v1::Data, } -impl<'a> MetaBuilder<'a> { +impl MetaBuilder<'_> { pub fn build(mut self) -> Result { // self.data.app_revision = parse_app_revision(&self.app_root)?; self.data.app_revision = std::env::var("ENCORE_APP_REVISION").unwrap_or_default(); diff --git a/tsparser/src/legacymeta/schema.rs b/tsparser/src/legacymeta/schema.rs index d674102004..04665747ac 100644 --- a/tsparser/src/legacymeta/schema.rs +++ b/tsparser/src/legacymeta/schema.rs @@ -80,7 +80,7 @@ impl<'a> SchemaBuilder<'a> { } } -impl<'a, 'b> BuilderCtx<'a, 'b> { +impl BuilderCtx<'_, '_> { #[tracing::instrument(skip(self), ret, level = "trace")] fn typ(&mut self, typ: &Type) -> Result { Ok(match typ { diff --git a/tsparser/src/parser/parser.rs b/tsparser/src/parser/parser.rs index 7322812702..1d12fd6e54 100644 --- a/tsparser/src/parser/parser.rs +++ b/tsparser/src/parser/parser.rs @@ -191,7 +191,7 @@ impl<'a> Parser<'a> { // Skip non-".ts" files. let ext = entry.path().extension().and_then(OsStr::to_str); - if !ext.is_some_and(|ext| ext == "ts") { + if ext.is_none_or(|ext| ext != "ts") { continue; } diff --git a/tsparser/src/parser/resourceparser/resource_parser.rs b/tsparser/src/parser/resourceparser/resource_parser.rs index 7e7d7ce963..05dabcb9ca 100644 --- a/tsparser/src/parser/resourceparser/resource_parser.rs +++ b/tsparser/src/parser/resourceparser/resource_parser.rs @@ -30,7 +30,7 @@ pub struct ResourceParserRegistry<'a> { interested_for_paths: HashMap, Vec<&'a ResourceParser>>, } -impl<'a> Default for ResourceParserRegistry<'a> { +impl Default for ResourceParserRegistry<'_> { fn default() -> Self { Self::new(DEFAULT_RESOURCE_PARSERS) } diff --git a/tsparser/src/parser/resources/parseutil.rs b/tsparser/src/parser/resources/parseutil.rs index 861c51dcac..ceb9e25ec2 100644 --- a/tsparser/src/parser/resources/parseutil.rs +++ b/tsparser/src/parser/resources/parseutil.rs @@ -368,7 +368,7 @@ impl<'a, R> IterReferenceVisitor<'a, R> { } } -impl<'a, R: ReferenceParser> swc_ecma_visit::VisitAstPath for IterReferenceVisitor<'a, R> { +impl swc_ecma_visit::VisitAstPath for IterReferenceVisitor<'_, R> { fn visit_ident<'ast: 'r, 'r>( &mut self, n: &'ast ast::Ident, diff --git a/tsparser/src/parser/service_discovery.rs b/tsparser/src/parser/service_discovery.rs index 8bf2e6368f..ec1e11465b 100644 --- a/tsparser/src/parser/service_discovery.rs +++ b/tsparser/src/parser/service_discovery.rs @@ -39,7 +39,7 @@ struct ServiceDiscoverer<'a> { strong_root: HashSet, } -impl<'a> ServiceDiscoverer<'a> { +impl ServiceDiscoverer<'_> { fn discover(mut self) -> Result> { for b in self.binds { match &b.resource { diff --git a/tsparser/src/parser/types/resolved.rs b/tsparser/src/parser/types/resolved.rs index 0389bb5548..599cd7c304 100644 --- a/tsparser/src/parser/types/resolved.rs +++ b/tsparser/src/parser/types/resolved.rs @@ -93,7 +93,7 @@ where } } -impl<'a, 'b, B: ?Sized, C: ?Sized> PartialEq> for Resolved<'a, B> +impl<'b, B: ?Sized, C: ?Sized> PartialEq> for Resolved<'_, B> where B: PartialEq + ToOwned, C: ToOwned, diff --git a/tsparser/src/parser/types/type_resolve.rs b/tsparser/src/parser/types/type_resolve.rs index b45428624f..93bd58abdd 100644 --- a/tsparser/src/parser/types/type_resolve.rs +++ b/tsparser/src/parser/types/type_resolve.rs @@ -140,7 +140,7 @@ impl<'a> Ctx<'a> { } } -impl<'a> Ctx<'a> { +impl Ctx<'_> { pub fn typ(&self, typ: &ast::TsType) -> Type { match typ { ast::TsType::TsKeywordType(tt) => self.keyword(tt), @@ -1244,7 +1244,7 @@ impl<'a> Ctx<'a> { } } -impl<'a> Ctx<'a> { +impl Ctx<'_> { pub fn obj_type(&self, obj: &Object) -> Type { if matches!(&obj.kind, ObjectKind::Module(_)) { // Modules don't have a type. @@ -1417,7 +1417,7 @@ impl<'a> Ctx<'a> { } } -impl<'a> Ctx<'a> { +impl Ctx<'_> { #[tracing::instrument(skip(self), ret, level = "trace")] pub fn concrete<'b>(&'b self, typ: &'b Type) -> Resolved<'b, Type> { match typ { diff --git a/tsparser/src/parser/usageparser/mod.rs b/tsparser/src/parser/usageparser/mod.rs index b01d3e7961..2218685cbe 100644 --- a/tsparser/src/parser/usageparser/mod.rs +++ b/tsparser/src/parser/usageparser/mod.rs @@ -332,7 +332,7 @@ impl<'a> UsageVisitor<'a> { let parent = path.get(idx - 1); let grandparent = path.get(idx - 2); - return match parent { + match parent { Some(AstParentNodeRef::MemberExpr(sel, MemberExprField::Obj)) => { // We have a member expression, where the object ("foo" in foo.bar) is the bind. // Ensure "bar" is a static identifier and not a private field or a computed property. @@ -439,7 +439,7 @@ impl<'a> UsageVisitor<'a> { } } } - }; + } } }