From 912acc511b635d4660dac32eaa706ab8214a7d42 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Thu, 28 Nov 2024 16:39:40 +0100 Subject: [PATCH] ref(relay): Fix Rust 1.83 lints (#4307) Fixes all Clippy and rustfmt issues with 1.83. This adds a bunch of ignores for the `non_local_definitions` lint, since `synstructure` generates code which causes the lint to fire. `synstructure` 0.13 has this fixed, but it depends on syn2, where we still use syn1 in the derive crates. Updating to syn2 is too much effort for the moment. --- relay-base-schema/src/metrics/mri.rs | 2 +- relay-cabi/src/core.rs | 2 +- relay-cardinality/src/limiter.rs | 2 +- relay-cardinality/src/redis/script.rs | 2 +- relay-cardinality/src/redis/state.rs | 2 +- relay-cogs/src/test.rs | 2 ++ relay-common/src/time.rs | 2 +- relay-config/src/byte_size.rs | 2 +- relay-config/src/config.rs | 2 +- relay-config/src/upstream.rs | 2 +- relay-crash/src/lib.rs | 2 +- relay-event-derive/src/lib.rs | 1 + relay-event-normalization/src/event.rs | 13 ++++++++++-- .../src/normalize/mod.rs | 2 +- .../src/normalize/span/description/mod.rs | 2 +- .../src/normalize/user_agent.rs | 15 -------------- relay-event-schema/src/processor/attrs.rs | 12 +++++------ relay-event-schema/src/processor/chunks.rs | 2 +- .../src/protocol/security_report.rs | 2 +- relay-event-schema/src/protocol/types.rs | 4 ++-- relay-filter/src/generic.rs | 2 +- relay-kafka/src/config.rs | 2 +- relay-log/src/utils.rs | 2 +- relay-metrics/src/view.rs | 10 +++++----- relay-pattern/src/lib.rs | 2 +- relay-pattern/src/wildmatch.rs | 9 ++++++--- relay-pii/src/attachments.rs | 4 ++-- relay-pii/src/convert.rs | 4 ++-- relay-pii/src/processor.rs | 2 +- relay-profiling/src/sample/v1.rs | 4 ++-- relay-protocol-derive/src/lib.rs | 7 +++++++ relay-protocol/src/annotated.rs | 2 +- relay-protocol/src/impls.rs | 2 +- relay-protocol/src/meta.rs | 2 +- relay-protocol/src/size.rs | 16 +++++++-------- relay-protocol/src/value.rs | 2 +- relay-replays/src/recording.rs | 2 +- relay-replays/src/transform.rs | 12 +++++------ relay-sampling/Cargo.toml | 2 +- relay-sampling/src/dsc.rs | 2 +- relay-sampling/src/evaluation.rs | 20 ++++++++++--------- relay-server/src/metrics/bucket_encoding.rs | 6 +++--- relay-server/src/services/processor.rs | 4 ++-- .../src/services/processor/session.rs | 2 +- relay-server/src/services/store.rs | 2 +- relay-server/src/statsd.rs | 2 +- 46 files changed, 105 insertions(+), 96 deletions(-) diff --git a/relay-base-schema/src/metrics/mri.rs b/relay-base-schema/src/metrics/mri.rs index 3f332d3783..dc4ce08755 100644 --- a/relay-base-schema/src/metrics/mri.rs +++ b/relay-base-schema/src/metrics/mri.rs @@ -322,7 +322,7 @@ impl Serialize for MetricResourceIdentifier<'_> { } } -impl<'a> fmt::Display for MetricResourceIdentifier<'a> { +impl fmt::Display for MetricResourceIdentifier<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // `:/@` write!( diff --git a/relay-cabi/src/core.rs b/relay-cabi/src/core.rs index e7d6df8e9c..f4e7c7a219 100644 --- a/relay-cabi/src/core.rs +++ b/relay-cabi/src/core.rs @@ -81,7 +81,7 @@ impl From for RelayStr { } } -impl<'a> From<&'a str> for RelayStr { +impl From<&str> for RelayStr { fn from(string: &str) -> RelayStr { RelayStr::new(string) } diff --git a/relay-cardinality/src/limiter.rs b/relay-cardinality/src/limiter.rs index d872bf9b5d..094bc207a4 100644 --- a/relay-cardinality/src/limiter.rs +++ b/relay-cardinality/src/limiter.rs @@ -250,7 +250,7 @@ pub struct CardinalityLimitsSplit<'a, T> { pub rejected: Vec<(T, &'a CardinalityLimit)>, } -impl<'a, T> CardinalityLimitsSplit<'a, T> { +impl CardinalityLimitsSplit<'_, T> { /// Creates a new cardinality limits split with a given capacity for `accepted` and `rejected` /// elements. fn with_capacity(accepted_capacity: usize, rejected_capacity: usize) -> Self { diff --git a/relay-cardinality/src/redis/script.rs b/relay-cardinality/src/redis/script.rs index 86e8b0abbf..01859957e1 100644 --- a/relay-cardinality/src/redis/script.rs +++ b/relay-cardinality/src/redis/script.rs @@ -153,7 +153,7 @@ pub struct CardinalityScriptPipeline<'a> { pipe: redis::Pipeline, } -impl<'a> CardinalityScriptPipeline<'a> { +impl CardinalityScriptPipeline<'_> { /// Adds another invocation of the script to the pipeline. pub fn add_invocation( &mut self, diff --git a/relay-cardinality/src/redis/state.rs b/relay-cardinality/src/redis/state.rs index 8c42fd9c46..68bcab5393 100644 --- a/relay-cardinality/src/redis/state.rs +++ b/relay-cardinality/src/redis/state.rs @@ -133,7 +133,7 @@ impl<'a> LimitState<'a> { } } -impl<'a> Drop for LimitState<'a> { +impl Drop for LimitState<'_> { fn drop(&mut self) { let passive = if self.cardinality_limit.passive { "true" diff --git a/relay-cogs/src/test.rs b/relay-cogs/src/test.rs index 9bea86ea41..9dc305c21e 100644 --- a/relay-cogs/src/test.rs +++ b/relay-cogs/src/test.rs @@ -2,10 +2,12 @@ use std::sync::{Arc, Mutex, PoisonError}; use crate::{CogsMeasurement, CogsRecorder}; +/// A [`CogsRecorder`] for testing which allows access to all recorded measurements. #[derive(Clone, Default)] pub struct TestRecorder(Arc>>); impl TestRecorder { + /// Returns the recorded measurements. pub fn measurements(&self) -> Vec { let inner = self.0.lock().unwrap_or_else(PoisonError::into_inner); inner.clone() diff --git a/relay-common/src/time.rs b/relay-common/src/time.rs index ffed89e5b0..1b621268cc 100644 --- a/relay-common/src/time.rs +++ b/relay-common/src/time.rs @@ -174,7 +174,7 @@ impl Serialize for UnixTimestamp { struct UnixTimestampVisitor; -impl<'de> serde::de::Visitor<'de> for UnixTimestampVisitor { +impl serde::de::Visitor<'_> for UnixTimestampVisitor { type Value = UnixTimestamp; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/relay-config/src/byte_size.rs b/relay-config/src/byte_size.rs index 056aa71969..a7a427f64b 100644 --- a/relay-config/src/byte_size.rs +++ b/relay-config/src/byte_size.rs @@ -137,7 +137,7 @@ impl<'de> de::Deserialize<'de> for ByteSize { { struct V; - impl<'de> de::Visitor<'de> for V { + impl de::Visitor<'_> for V { type Value = ByteSize; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/relay-config/src/config.rs b/relay-config/src/config.rs index 4f2324ccd5..54305d2460 100644 --- a/relay-config/src/config.rs +++ b/relay-config/src/config.rs @@ -1263,7 +1263,7 @@ impl Serialize for EmitOutcomes { struct EmitOutcomesVisitor; -impl<'de> Visitor<'de> for EmitOutcomesVisitor { +impl Visitor<'_> for EmitOutcomesVisitor { type Value = EmitOutcomes; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/relay-config/src/upstream.rs b/relay-config/src/upstream.rs index a329624d02..437eb22d0a 100644 --- a/relay-config/src/upstream.rs +++ b/relay-config/src/upstream.rs @@ -119,7 +119,7 @@ impl Default for UpstreamDescriptor<'static> { } } -impl<'a> fmt::Display for UpstreamDescriptor<'a> { +impl fmt::Display for UpstreamDescriptor<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}://{}", &self.scheme, &self.host)?; if self.port() != self.scheme.default_port() { diff --git a/relay-crash/src/lib.rs b/relay-crash/src/lib.rs index f3bd9bfe1f..56ac19810d 100644 --- a/relay-crash/src/lib.rs +++ b/relay-crash/src/lib.rs @@ -55,7 +55,7 @@ pub struct CrashHandler<'a> { environment: Option<&'a str>, } -impl<'a> fmt::Debug for CrashHandler<'a> { +impl fmt::Debug for CrashHandler<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let transport = match self.transport { Some(_) => "Some(fn)", 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/event.rs b/relay-event-normalization/src/event.rs index bb04d466b5..7189efa790 100644 --- a/relay-event-normalization/src/event.rs +++ b/relay-event-normalization/src/event.rs @@ -161,7 +161,7 @@ pub struct NormalizationConfig<'a> { pub span_op_defaults: BorrowedSpanOpDefaults<'a>, } -impl<'a> Default for NormalizationConfig<'a> { +impl Default for NormalizationConfig<'_> { fn default() -> Self { Self { project_id: Default::default(), @@ -1773,7 +1773,16 @@ mod tests { let ipaddr = IpAddr("213.164.1.114".to_string()); let client_ip = Some(&ipaddr); - let user_agent = RawUserAgentInfo::new_test_dummy(); + + let user_agent = RawUserAgentInfo { + user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/109.0"), + client_hints: ClientHints { + sec_ch_ua_platform: Some("macOS"), + sec_ch_ua_platform_version: Some("13.2.0"), + sec_ch_ua: Some(r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#), + sec_ch_ua_model: Some("some model"), + } + }; // This call should fill the event headers with info from the user_agent which is // tested below. 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-normalization/src/normalize/span/description/mod.rs b/relay-event-normalization/src/normalize/span/description/mod.rs index 984e9274ac..ebb9cea237 100644 --- a/relay-event-normalization/src/normalize/span/description/mod.rs +++ b/relay-event-normalization/src/normalize/span/description/mod.rs @@ -441,7 +441,7 @@ fn scrub_resource(resource_type: &str, string: &str) -> Option { } if COMMON_PATH_SEGMENTS.contains(segment) { output_segments.push(segment); - } else if !output_segments.last().is_some_and(|s| *s == "*") { + } else if output_segments.last().is_none_or(|s| *s != "*") { // only one asterisk output_segments.push("*"); } diff --git a/relay-event-normalization/src/normalize/user_agent.rs b/relay-event-normalization/src/normalize/user_agent.rs index b2a31a4657..26f8977b33 100644 --- a/relay-event-normalization/src/normalize/user_agent.rs +++ b/relay-event-normalization/src/normalize/user_agent.rs @@ -1082,21 +1082,6 @@ mod tests { assert_eq!(os.version.value().unwrap(), ">=10.15.7"); } - impl RawUserAgentInfo<&str> { - pub fn new_test_dummy() -> Self { - Self { - user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/109.0"), - client_hints: ClientHints { - sec_ch_ua_platform: Some("macOS"), - sec_ch_ua_platform_version: Some("13.2.0"), - sec_ch_ua: Some(r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#), - sec_ch_ua_model: Some("some model"), - } - - } - } - } - #[test] fn test_default_empty() { assert!(RawUserAgentInfo::<&str>::default().is_empty()); 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-filter/src/generic.rs b/relay-filter/src/generic.rs index f0840ccf31..dede4c9301 100644 --- a/relay-filter/src/generic.rs +++ b/relay-filter/src/generic.rs @@ -135,7 +135,7 @@ impl<'a> Iterator for DynamicGenericFiltersConfigIter<'a> { } } -impl<'a> FusedIterator for DynamicGenericFiltersConfigIter<'a> {} +impl FusedIterator for DynamicGenericFiltersConfigIter<'_> {} /// Merges the two filters with the same id, prioritizing values from the primary. /// 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-log/src/utils.rs b/relay-log/src/utils.rs index 5041a0add7..eefdb50864 100644 --- a/relay-log/src/utils.rs +++ b/relay-log/src/utils.rs @@ -35,7 +35,7 @@ pub fn ensure_error>(error: E) { /// A wrapper around an error that prints its causes. struct LogError<'a, E: Error + ?Sized>(pub &'a E); -impl<'a, E: Error + ?Sized> fmt::Display for LogError<'a, E> { +impl fmt::Display for LogError<'_, E> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0)?; diff --git a/relay-metrics/src/view.rs b/relay-metrics/src/view.rs index ffc7751613..86862c16aa 100644 --- a/relay-metrics/src/view.rs +++ b/relay-metrics/src/view.rs @@ -570,7 +570,7 @@ impl<'a> BucketView<'a> { } } -impl<'a> fmt::Debug for BucketView<'a> { +impl fmt::Debug for BucketView<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BucketView") .field("timestamp", &self.inner.timestamp) @@ -588,7 +588,7 @@ impl<'a> From<&'a Bucket> for BucketView<'a> { } } -impl<'a> Serialize for BucketView<'a> { +impl Serialize for BucketView<'_> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -701,13 +701,13 @@ impl<'a> SetView<'a> { } } -impl<'a> PartialEq for SetView<'a> { +impl PartialEq for SetView<'_> { fn eq(&self, other: &Self) -> bool { self.iter().eq(other.iter()) } } -impl<'a> fmt::Debug for SetView<'a> { +impl fmt::Debug for SetView<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("SetView") .field(&self.iter().collect::>()) @@ -715,7 +715,7 @@ impl<'a> fmt::Debug for SetView<'a> { } } -impl<'a> Serialize for SetView<'a> { +impl Serialize for SetView<'_> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, 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-pii/src/attachments.rs b/relay-pii/src/attachments.rs index b8bf70c1b1..c4bf6cd0f5 100644 --- a/relay-pii/src/attachments.rs +++ b/relay-pii/src/attachments.rs @@ -316,7 +316,7 @@ impl<'a> Iterator for WStrSegmentIter<'a> { } } -impl<'a> FusedIterator for WStrSegmentIter<'a> {} +impl FusedIterator for WStrSegmentIter<'_> {} /// An encoded string segment in a larger data block. /// @@ -535,7 +535,7 @@ mod tests { }, } - impl<'a> AttachmentBytesTestCase<'a> { + impl AttachmentBytesTestCase<'_> { fn run(self) { let (config, filename, value_type, input, expected, changed) = match self { AttachmentBytesTestCase::Builtin { diff --git a/relay-pii/src/convert.rs b/relay-pii/src/convert.rs index f2243c2e91..1bbef0f010 100644 --- a/relay-pii/src/convert.rs +++ b/relay-pii/src/convert.rs @@ -182,8 +182,8 @@ mod tests { use super::to_pii_config as to_pii_config_impl; use super::*; - /// These tests are ported from Sentry's Python testsuite (test_data_scrubber). Each testcase - /// has an equivalent testcase in Python. + // These tests are ported from Sentry's Python testsuite (test_data_scrubber). Each testcase + // has an equivalent testcase in Python. fn to_pii_config(datascrubbing_config: &DataScrubbingConfig) -> Option { let rv = to_pii_config_impl(datascrubbing_config).unwrap(); diff --git a/relay-pii/src/processor.rs b/relay-pii/src/processor.rs index 197b085455..7b536cc06a 100644 --- a/relay-pii/src/processor.rs +++ b/relay-pii/src/processor.rs @@ -57,7 +57,7 @@ impl<'a> PiiProcessor<'a> { } } -impl<'a> Processor for PiiProcessor<'a> { +impl Processor for PiiProcessor<'_> { fn before_process( &mut self, value: Option<&T>, diff --git a/relay-profiling/src/sample/v1.rs b/relay-profiling/src/sample/v1.rs index 0eca111998..8f88cd324e 100644 --- a/relay-profiling/src/sample/v1.rs +++ b/relay-profiling/src/sample/v1.rs @@ -105,10 +105,10 @@ impl SampleProfile { let mut active_ranges: HashMap> = HashMap::new(); for (i, sample) in self.samples.iter().enumerate() { - if !self + if self .stacks .get(sample.stack_id) - .is_some_and(|stack| !stack.is_empty()) + .is_none_or(|stack| stack.is_empty()) { continue; } 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 diff --git a/relay-protocol/src/annotated.rs b/relay-protocol/src/annotated.rs index f437e3975d..3326ff5e5c 100644 --- a/relay-protocol/src/annotated.rs +++ b/relay-protocol/src/annotated.rs @@ -63,7 +63,7 @@ pub struct Annotated(pub Option, pub Meta); /// An utility to serialize annotated objects with payload. pub struct SerializableAnnotated<'a, T>(pub &'a Annotated); -impl<'a, T: IntoValue> Serialize for SerializableAnnotated<'a, T> { +impl Serialize for SerializableAnnotated<'_, T> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/relay-protocol/src/impls.rs b/relay-protocol/src/impls.rs index 72c0c83be2..2a749f2386 100644 --- a/relay-protocol/src/impls.rs +++ b/relay-protocol/src/impls.rs @@ -12,7 +12,7 @@ use crate::value::{Array, Map, Object, Value}; #[doc(hidden)] pub struct SerializePayload<'a, T>(pub &'a Annotated, pub SkipSerialization); -impl<'a, T: IntoValue> Serialize for SerializePayload<'a, T> { +impl Serialize for SerializePayload<'_, T> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/relay-protocol/src/meta.rs b/relay-protocol/src/meta.rs index 80c17cfa39..6e98cebdc6 100644 --- a/relay-protocol/src/meta.rs +++ b/relay-protocol/src/meta.rs @@ -230,7 +230,7 @@ impl<'de> Deserialize<'de> for ErrorKind { fn deserialize>(deserializer: D) -> Result { struct ErrorKindVisitor; - impl<'de> de::Visitor<'de> for ErrorKindVisitor { + impl de::Visitor<'_> for ErrorKindVisitor { type Value = ErrorKind; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/relay-protocol/src/size.rs b/relay-protocol/src/size.rs index 54996d0d16..2b2ad86ce2 100644 --- a/relay-protocol/src/size.rs +++ b/relay-protocol/src/size.rs @@ -72,7 +72,7 @@ impl SizeEstimatingSerializer { } } -impl<'a> ser::Serializer for &'a mut SizeEstimatingSerializer { +impl ser::Serializer for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -286,7 +286,7 @@ impl<'a> ser::Serializer for &'a mut SizeEstimatingSerializer { } } -impl<'a> ser::SerializeSeq for &'a mut SizeEstimatingSerializer { +impl ser::SerializeSeq for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -306,7 +306,7 @@ impl<'a> ser::SerializeSeq for &'a mut SizeEstimatingSerializer { } // Same thing but for tuples. -impl<'a> ser::SerializeTuple for &'a mut SizeEstimatingSerializer { +impl ser::SerializeTuple for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -326,7 +326,7 @@ impl<'a> ser::SerializeTuple for &'a mut SizeEstimatingSerializer { } // Same thing but for tuple structs. -impl<'a> ser::SerializeTupleStruct for &'a mut SizeEstimatingSerializer { +impl ser::SerializeTupleStruct for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -345,7 +345,7 @@ impl<'a> ser::SerializeTupleStruct for &'a mut SizeEstimatingSerializer { } } -impl<'a> ser::SerializeTupleVariant for &'a mut SizeEstimatingSerializer { +impl ser::SerializeTupleVariant for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -364,7 +364,7 @@ impl<'a> ser::SerializeTupleVariant for &'a mut SizeEstimatingSerializer { } } -impl<'a> ser::SerializeMap for &'a mut SizeEstimatingSerializer { +impl ser::SerializeMap for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -392,7 +392,7 @@ impl<'a> ser::SerializeMap for &'a mut SizeEstimatingSerializer { } } -impl<'a> ser::SerializeStruct for &'a mut SizeEstimatingSerializer { +impl ser::SerializeStruct for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; @@ -413,7 +413,7 @@ impl<'a> ser::SerializeStruct for &'a mut SizeEstimatingSerializer { } } -impl<'a> ser::SerializeStructVariant for &'a mut SizeEstimatingSerializer { +impl ser::SerializeStructVariant for &mut SizeEstimatingSerializer { type Ok = (); type Error = Error; diff --git a/relay-protocol/src/value.rs b/relay-protocol/src/value.rs index b596d013bc..89b537b2f5 100644 --- a/relay-protocol/src/value.rs +++ b/relay-protocol/src/value.rs @@ -40,7 +40,7 @@ pub enum Value { /// Helper type that renders out a description of the value. pub struct ValueDescription<'a>(&'a Value); -impl<'a> fmt::Display for ValueDescription<'a> { +impl fmt::Display for ValueDescription<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self.0 { Value::Bool(true) => f.pad("true"), diff --git a/relay-replays/src/recording.rs b/relay-replays/src/recording.rs index 45793986cc..4a84a03dd7 100644 --- a/relay-replays/src/recording.rs +++ b/relay-replays/src/recording.rs @@ -206,7 +206,7 @@ impl<'a, S> EventStreamVisitor<'a, S> { } } -impl<'de, 'a, S> de::Visitor<'de> for EventStreamVisitor<'a, S> +impl<'de, S> de::Visitor<'de> for EventStreamVisitor<'_, S> where S: ser::Serializer, { diff --git a/relay-replays/src/transform.rs b/relay-replays/src/transform.rs index 05cca4f402..aaf64915de 100644 --- a/relay-replays/src/transform.rs +++ b/relay-replays/src/transform.rs @@ -203,7 +203,7 @@ where } } -impl<'de, 'a, D, T> de::Deserializer<'de> for Deserializer<'a, D, T> +impl<'de, D, T> de::Deserializer<'de> for Deserializer<'_, D, T> where D: de::Deserializer<'de>, T: Transform<'de>, @@ -606,7 +606,7 @@ impl<'a, V, T> Visitor<'a, V, T> { } } -impl<'de, 'a, V, T> de::Visitor<'de> for Visitor<'a, V, T> +impl<'de, V, T> de::Visitor<'de> for Visitor<'_, V, T> where V: de::Visitor<'de>, T: Transform<'de>, @@ -824,7 +824,7 @@ where struct SeqAccess<'a, A, T>(A, &'a mut T); -impl<'de, 'a, A, T> de::SeqAccess<'de> for SeqAccess<'a, A, T> +impl<'de, A, T> de::SeqAccess<'de> for SeqAccess<'_, A, T> where A: de::SeqAccess<'de>, T: Transform<'de>, @@ -845,7 +845,7 @@ where struct MapAccess<'a, A, T>(A, &'a mut T); -impl<'de, 'a, A, T> de::MapAccess<'de> for MapAccess<'a, A, T> +impl<'de, A, T> de::MapAccess<'de> for MapAccess<'_, A, T> where A: de::MapAccess<'de>, T: Transform<'de>, @@ -870,7 +870,7 @@ where struct DeserializeValueSeed<'a, D, T>(D, &'a mut T); -impl<'de, 'a, D, T> de::DeserializeSeed<'de> for DeserializeValueSeed<'a, D, T> +impl<'de, D, T> de::DeserializeSeed<'de> for DeserializeValueSeed<'_, D, T> where D: de::DeserializeSeed<'de>, T: Transform<'de>, @@ -891,7 +891,7 @@ where struct DeserializeKeySeed<'a, D, T>(D, &'a mut T); -impl<'de, 'a, D, T> de::DeserializeSeed<'de> for DeserializeKeySeed<'a, D, T> +impl<'de, D, T> de::DeserializeSeed<'de> for DeserializeKeySeed<'_, D, T> where D: de::DeserializeSeed<'de>, T: Transform<'de>, diff --git a/relay-sampling/Cargo.toml b/relay-sampling/Cargo.toml index 0034a6a6d4..06ea23ff6e 100644 --- a/relay-sampling/Cargo.toml +++ b/relay-sampling/Cargo.toml @@ -18,7 +18,7 @@ workspace = true [dependencies] anyhow = { workspace = true, optional = true } -chrono = { workspace = true } +chrono = { workspace = true, features = ["now"] } rand = { workspace = true } rand_pcg = { workspace = true } relay-base-schema = { workspace = true } diff --git a/relay-sampling/src/dsc.rs b/relay-sampling/src/dsc.rs index a363805372..edf58b81ad 100644 --- a/relay-sampling/src/dsc.rs +++ b/relay-sampling/src/dsc.rs @@ -190,7 +190,7 @@ mod sample_rate_as_string { struct BoolOptionVisitor; -impl<'de> serde::de::Visitor<'de> for BoolOptionVisitor { +impl serde::de::Visitor<'_> for BoolOptionVisitor { type Value = Option; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/relay-sampling/src/evaluation.rs b/relay-sampling/src/evaluation.rs index aec585048f..85ec3186fe 100644 --- a/relay-sampling/src/evaluation.rs +++ b/relay-sampling/src/evaluation.rs @@ -56,7 +56,7 @@ pub struct ReservoirEvaluator<'a> { _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> ReservoirEvaluator<'a> { +impl ReservoirEvaluator<'_> { /// Constructor for [`ReservoirEvaluator`]. pub fn new(counters: ReservoirCounters) -> Self { Self { @@ -72,14 +72,6 @@ impl<'a> ReservoirEvaluator<'a> { Arc::clone(&self.counters) } - /// Sets the Redis pool and organization ID for the [`ReservoirEvaluator`]. - /// - /// These values are needed to synchronize with Redis. - #[cfg(feature = "redis")] - pub fn set_redis(&mut self, org_id: OrganizationId, redis_pool: &'a RedisPool) { - self.org_id_and_redis_pool = Some((org_id, redis_pool)); - } - #[cfg(feature = "redis")] fn redis_incr( &self, @@ -146,6 +138,16 @@ impl<'a> ReservoirEvaluator<'a> { } } +#[cfg(feature = "redis")] +impl<'a> ReservoirEvaluator<'a> { + /// Sets the Redis pool and organization ID for the [`ReservoirEvaluator`]. + /// + /// These values are needed to synchronize with Redis. + pub fn set_redis(&mut self, org_id: OrganizationId, redis_pool: &'a RedisPool) { + self.org_id_and_redis_pool = Some((org_id, redis_pool)); + } +} + /// State machine for dynamic sampling. #[derive(Debug)] pub struct SamplingEvaluator<'a> { diff --git a/relay-server/src/metrics/bucket_encoding.rs b/relay-server/src/metrics/bucket_encoding.rs index 2ec03c400c..d126f471ba 100644 --- a/relay-server/src/metrics/bucket_encoding.rs +++ b/relay-server/src/metrics/bucket_encoding.rs @@ -98,7 +98,7 @@ pub enum ArrayEncoding<'a, T> { Dynamic(DynamicArrayEncoding<'a, T>), } -impl<'a, T> ArrayEncoding<'a, T> { +impl ArrayEncoding<'_, T> { /// Name of the encoding. /// /// Should only be used for debugging purposes. @@ -132,7 +132,7 @@ pub enum DynamicArrayEncoding<'a, T> { Zstd { data: &'a str }, } -impl<'a, T> DynamicArrayEncoding<'a, T> { +impl DynamicArrayEncoding<'_, T> { /// Returns the serialized format name. pub fn format(&self) -> &'static str { match self { @@ -170,7 +170,7 @@ fn zstd(data: T, buffer: &mut String) -> io::Result(pub data_encoding::Encoder<'a>); -impl<'a> io::Write for EncoderWriteAdapter<'a> { +impl io::Write for EncoderWriteAdapter<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.append(buf); Ok(buf.len()) diff --git a/relay-server/src/services/processor.rs b/relay-server/src/services/processor.rs index 95d6eaec86..0deceaedfe 100644 --- a/relay-server/src/services/processor.rs +++ b/relay-server/src/services/processor.rs @@ -798,7 +798,7 @@ struct ProcessEnvelopeState<'a, Group> { event_fully_normalized: bool, } -impl<'a, Group> ProcessEnvelopeState<'a, Group> { +impl ProcessEnvelopeState<'_, Group> { /// Returns a reference to the contained [`Envelope`]. fn envelope(&self) -> &Envelope { self.managed_envelope.envelope() @@ -2840,7 +2840,7 @@ enum RateLimiter<'a> { } #[cfg(feature = "processing")] -impl<'a> RateLimiter<'a> { +impl RateLimiter<'_> { fn enforce( &self, global_config: &GlobalConfig, diff --git a/relay-server/src/services/processor/session.rs b/relay-server/src/services/processor/session.rs index bc889a4642..fbafd409af 100644 --- a/relay-server/src/services/processor/session.rs +++ b/relay-server/src/services/processor/session.rs @@ -358,7 +358,7 @@ mod tests { extracted_metrics: Vec, } - impl<'a> TestProcessSessionArguments<'a> { + impl TestProcessSessionArguments<'_> { fn run_session_producer(&mut self) -> bool { process_session( &mut self.item, diff --git a/relay-server/src/services/store.rs b/relay-server/src/services/store.rs index 6500c5da2c..6592f223f3 100644 --- a/relay-server/src/services/store.rs +++ b/relay-server/src/services/store.rs @@ -1144,7 +1144,7 @@ enum MetricValue<'a> { Gauge(GaugeValue), } -impl<'a> MetricValue<'a> { +impl MetricValue<'_> { fn variant(&self) -> &'static str { match self { Self::Counter(_) => "counter", diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index 9b416df1e8..9c33418f40 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -1034,7 +1034,7 @@ pub enum ClientName<'a> { Other(&'a str), } -impl<'a> ClientName<'a> { +impl ClientName<'_> { pub fn name(&self) -> &'static str { match self { Self::Ruby => "sentry-ruby",