From 4a894d0b85045cf487a62d09eac21cdae275f34d Mon Sep 17 00:00:00 2001 From: David Herberth Date: Thu, 28 Nov 2024 15:59:40 +0100 Subject: [PATCH] ref(relay): Fix Rust 1.83 lints --- relay-event-derive/src/lib.rs | 1 + relay-event-normalization/src/normalize/mod.rs | 2 +- relay-event-schema/src/processor/attrs.rs | 12 ++++++------ relay-event-schema/src/processor/chunks.rs | 2 +- relay-event-schema/src/protocol/security_report.rs | 2 +- relay-event-schema/src/protocol/types.rs | 4 ++-- relay-kafka/src/config.rs | 2 +- relay-pattern/src/lib.rs | 2 +- relay-pattern/src/wildmatch.rs | 9 ++++++--- relay-protocol-derive/src/lib.rs | 7 +++++++ 10 files changed, 27 insertions(+), 16 deletions(-) diff --git a/relay-event-derive/src/lib.rs b/relay-event-derive/src/lib.rs index 814802af2b..9214e0c201 100644 --- a/relay-event-derive/src/lib.rs +++ b/relay-event-derive/src/lib.rs @@ -171,6 +171,7 @@ fn derive_process_value(mut s: synstructure::Structure<'_>) -> TokenStream { s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl crate::processor::ProcessValue for @Self { fn value_type(&self) -> enumset::EnumSet { match *self { diff --git a/relay-event-normalization/src/normalize/mod.rs b/relay-event-normalization/src/normalize/mod.rs index 9db1472cc0..b3a74c45a0 100644 --- a/relay-event-normalization/src/normalize/mod.rs +++ b/relay-event-normalization/src/normalize/mod.rs @@ -134,7 +134,7 @@ impl<'a> CombinedMeasurementsConfig<'a> { /// there are no duplicates. pub fn builtin_measurement_keys( &'a self, - ) -> impl Iterator + '_ { + ) -> impl Iterator + 'a { let project = self .project .map(|p| p.builtin_measurements.as_slice()) diff --git a/relay-event-schema/src/processor/attrs.rs b/relay-event-schema/src/processor/attrs.rs index c80a9fe7c6..b8772a09dc 100644 --- a/relay-event-schema/src/processor/attrs.rs +++ b/relay-event-schema/src/processor/attrs.rs @@ -236,7 +236,7 @@ impl<'a> PartialEq for PathItem<'a> { } } -impl<'a> PathItem<'a> { +impl PathItem<'_> { /// Returns the key if there is one #[inline] pub fn key(&self) -> Option<&str> { @@ -257,7 +257,7 @@ impl<'a> PathItem<'a> { } } -impl<'a> fmt::Display for PathItem<'a> { +impl fmt::Display for PathItem<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { PathItem::StaticKey(s) => f.pad(s), @@ -517,9 +517,9 @@ impl<'a> Iterator for ProcessingStateIter<'a> { } } -impl<'a> ExactSizeIterator for ProcessingStateIter<'a> {} +impl ExactSizeIterator for ProcessingStateIter<'_> {} -impl<'a> Default for ProcessingState<'a> { +impl Default for ProcessingState<'_> { fn default() -> Self { ProcessingState::root().clone() } @@ -531,7 +531,7 @@ impl<'a> Default for ProcessingState<'a> { #[derive(Debug)] pub struct Path<'a>(&'a ProcessingState<'a>); -impl<'a> Path<'a> { +impl Path<'_> { /// Returns the current key if there is one #[inline] pub fn key(&self) -> Option<&str> { @@ -560,7 +560,7 @@ impl<'a> Path<'a> { } } -impl<'a> fmt::Display for Path<'a> { +impl fmt::Display for Path<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut items = Vec::with_capacity(self.0.depth); for state in self.0.iter() { diff --git a/relay-event-schema/src/processor/chunks.rs b/relay-event-schema/src/processor/chunks.rs index 58db9f4602..201a6b7992 100644 --- a/relay-event-schema/src/processor/chunks.rs +++ b/relay-event-schema/src/processor/chunks.rs @@ -49,7 +49,7 @@ pub enum Chunk<'a> { }, } -impl<'a> Chunk<'a> { +impl Chunk<'_> { /// The text of this chunk. pub fn as_str(&self) -> &str { match self { diff --git a/relay-event-schema/src/protocol/security_report.rs b/relay-event-schema/src/protocol/security_report.rs index 4a5812c66a..893a2911bb 100644 --- a/relay-event-schema/src/protocol/security_report.rs +++ b/relay-event-schema/src/protocol/security_report.rs @@ -688,7 +688,7 @@ mod serde_date_time_3339 { { struct DateTimeVisitor; - impl<'de> Visitor<'de> for DateTimeVisitor { + impl Visitor<'_> for DateTimeVisitor { type Value = Option>; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/relay-event-schema/src/protocol/types.rs b/relay-event-schema/src/protocol/types.rs index 8379c2be22..a0ef1ea1c0 100644 --- a/relay-event-schema/src/protocol/types.rs +++ b/relay-event-schema/src/protocol/types.rs @@ -185,7 +185,7 @@ where /// /// The key may be any borrowed form of the pairlist's key type. If there are multiple entries /// with the same key, the first is returned. - pub fn get<'a, Q>(&'a self, key: Q) -> Option<&Annotated> + pub fn get<'a, Q>(&'a self, key: Q) -> Option<&'a Annotated> where Q: AsRef, K: 'a, @@ -200,7 +200,7 @@ where /// /// The key may be any borrowed form of the pairlist's key type. If there are multiple entries /// with the same key, the first is returned. - pub fn get_value<'a, Q>(&'a self, key: Q) -> Option<&V> + pub fn get_value<'a, Q>(&'a self, key: Q) -> Option<&'a V> where Q: AsRef, K: 'a, diff --git a/relay-kafka/src/config.rs b/relay-kafka/src/config.rs index e6ccf553ae..7b9e841124 100644 --- a/relay-kafka/src/config.rs +++ b/relay-kafka/src/config.rs @@ -189,7 +189,7 @@ impl TopicAssignment { &'a self, default_config: &'a Vec, secondary_configs: &'a BTreeMap>, - ) -> Result, ConfigError> { + ) -> Result, ConfigError> { let kafka_config = match self { Self::Primary(topic_name) => KafkaParams { topic_name, diff --git a/relay-pattern/src/lib.rs b/relay-pattern/src/lib.rs index 869bbe68a7..47c72b9f5c 100644 --- a/relay-pattern/src/lib.rs +++ b/relay-pattern/src/lib.rs @@ -184,7 +184,7 @@ pub struct PatternBuilder<'a> { options: Options, } -impl<'a> PatternBuilder<'a> { +impl PatternBuilder<'_> { /// If enabled matches the pattern case insensitive. /// /// This is disabled by default. diff --git a/relay-pattern/src/wildmatch.rs b/relay-pattern/src/wildmatch.rs index 687092d4f0..691edd7070 100644 --- a/relay-pattern/src/wildmatch.rs +++ b/relay-pattern/src/wildmatch.rs @@ -409,10 +409,13 @@ struct AltAndTokens<'a> { tokens: &'a [Token], } -impl<'a> TokenIndex for AltAndTokens<'a> { +impl TokenIndex for AltAndTokens<'_> { // Type here does not matter, we implement `with_alternate` by returning the never type. // It just needs to satisfy the `TokenIndex` trait bound. - type WithAlternates<'b> = AltAndTokens<'b> where Self: 'b; + type WithAlternates<'b> + = AltAndTokens<'b> + where + Self: 'b; #[inline(always)] fn len(&self) -> usize { @@ -434,7 +437,7 @@ impl<'a> TokenIndex for AltAndTokens<'a> { } } -impl<'a> std::ops::Index for AltAndTokens<'a> { +impl std::ops::Index for AltAndTokens<'_> { type Output = Token; fn index(&self, index: usize) -> &Self::Output { diff --git a/relay-protocol-derive/src/lib.rs b/relay-protocol-derive/src/lib.rs index 11f9b2d6ab..3e6df9e492 100644 --- a/relay-protocol-derive/src/lib.rs +++ b/relay-protocol-derive/src/lib.rs @@ -77,6 +77,7 @@ fn derive_empty(mut s: synstructure::Structure<'_>) -> TokenStream { s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::Empty for @Self { fn is_empty(&self) -> bool { match *self { @@ -139,6 +140,7 @@ fn derive_newtype_metastructure( Ok(match t { Trait::From => s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::FromValue for @Self { fn from_value( __value: ::relay_protocol::Annotated<::relay_protocol::Value>, @@ -152,6 +154,7 @@ fn derive_newtype_metastructure( }), Trait::To => s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::IntoValue for @Self { fn into_value(self) -> ::relay_protocol::Value { ::relay_protocol::IntoValue::into_value(self.0) @@ -267,6 +270,7 @@ fn derive_enum_metastructure( Trait::From => { s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::FromValue for @Self { fn from_value( __value: ::relay_protocol::Annotated<::relay_protocol::Value>, @@ -287,6 +291,7 @@ fn derive_enum_metastructure( Trait::To => { s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::IntoValue for @Self { fn into_value(self) -> ::relay_protocol::Value { match self { @@ -490,6 +495,7 @@ fn derive_metastructure(s: synstructure::Structure<'_>, t: Trait) -> TokenStream s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::FromValue for @Self { fn from_value( __value: ::relay_protocol::Annotated<::relay_protocol::Value>, @@ -540,6 +546,7 @@ fn derive_metastructure(s: synstructure::Structure<'_>, t: Trait) -> TokenStream s.gen_impl(quote! { #[automatically_derived] + #[expect(non_local_definitions, reason = "crate needs to be migrated to syn2")] gen impl ::relay_protocol::IntoValue for @Self { fn into_value(self) -> ::relay_protocol::Value { #into_value