Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(relay): Fix Rust 1.83 lints #4307

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion relay-base-schema/src/metrics/mri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// `<ty>:<ns>/<name>@<unit>`
write!(
Expand Down
2 changes: 1 addition & 1 deletion relay-cabi/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl From<String> for RelayStr {
}
}

impl<'a> From<&'a str> for RelayStr {
impl From<&str> for RelayStr {
fn from(string: &str) -> RelayStr {
RelayStr::new(string)
}
Expand Down
2 changes: 1 addition & 1 deletion relay-cardinality/src/limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct CardinalityLimitsSplit<'a, T> {
pub rejected: Vec<(T, &'a CardinalityLimit)>,
}

impl<'a, T> CardinalityLimitsSplit<'a, T> {
impl<T> 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 {
Expand Down
2 changes: 1 addition & 1 deletion relay-cardinality/src/redis/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion relay-cardinality/src/redis/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions relay-cogs/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mutex<Vec<CogsMeasurement>>>);

impl TestRecorder {
/// Returns the recorded measurements.
pub fn measurements(&self) -> Vec<CogsMeasurement> {
let inner = self.0.lock().unwrap_or_else(PoisonError::into_inner);
inner.clone()
Expand Down
2 changes: 1 addition & 1 deletion relay-common/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion relay-config/src/byte_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion relay-config/src/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion relay-crash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions relay-event-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::processor::ValueType> {
match *self {
Expand Down
13 changes: 11 additions & 2 deletions relay-event-normalization/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion relay-event-normalization/src/normalize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<'a> CombinedMeasurementsConfig<'a> {
/// there are no duplicates.
pub fn builtin_measurement_keys(
&'a self,
) -> impl Iterator<Item = &'a BuiltinMeasurementKey> + '_ {
) -> impl Iterator<Item = &'a BuiltinMeasurementKey> + 'a {
let project = self
.project
.map(|p| p.builtin_measurements.as_slice())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn scrub_resource(resource_type: &str, string: &str) -> Option<String> {
}
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("*");
}
Expand Down
15 changes: 0 additions & 15 deletions relay-event-normalization/src/normalize/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
12 changes: 6 additions & 6 deletions relay-event-schema/src/processor/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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),
Expand Down Expand Up @@ -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()
}
Expand All @@ -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> {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion relay-event-schema/src/processor/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion relay-event-schema/src/protocol/security_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ mod serde_date_time_3339 {
{
struct DateTimeVisitor;

impl<'de> Visitor<'de> for DateTimeVisitor {
impl Visitor<'_> for DateTimeVisitor {
type Value = Option<DateTime<Utc>>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions relay-event-schema/src/protocol/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<V>>
pub fn get<'a, Q>(&'a self, key: Q) -> Option<&'a Annotated<V>>
where
Q: AsRef<str>,
K: 'a,
Expand All @@ -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<str>,
K: 'a,
Expand Down
2 changes: 1 addition & 1 deletion relay-filter/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion relay-kafka/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl TopicAssignment {
&'a self,
default_config: &'a Vec<KafkaConfigParam>,
secondary_configs: &'a BTreeMap<String, Vec<KafkaConfigParam>>,
) -> Result<KafkaParams<'_>, ConfigError> {
) -> Result<KafkaParams<'a>, ConfigError> {
let kafka_config = match self {
Self::Primary(topic_name) => KafkaParams {
topic_name,
Expand Down
2 changes: 1 addition & 1 deletion relay-log/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn ensure_error<E: AsRef<dyn 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<E: Error + ?Sized> fmt::Display for LogError<'_, E> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)?;

Expand Down
10 changes: 5 additions & 5 deletions relay-metrics/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -588,7 +588,7 @@ impl<'a> From<&'a Bucket> for BucketView<'a> {
}
}

impl<'a> Serialize for BucketView<'a> {
impl Serialize for BucketView<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down Expand Up @@ -701,21 +701,21 @@ 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::<Vec<_>>())
.finish()
}
}

impl<'a> Serialize for SetView<'a> {
impl Serialize for SetView<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down
2 changes: 1 addition & 1 deletion relay-pattern/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions relay-pattern/src/wildmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -434,7 +437,7 @@ impl<'a> TokenIndex for AltAndTokens<'a> {
}
}

impl<'a> std::ops::Index<usize> for AltAndTokens<'a> {
impl std::ops::Index<usize> for AltAndTokens<'_> {
type Output = Token;

fn index(&self, index: usize) -> &Self::Output {
Expand Down
4 changes: 2 additions & 2 deletions relay-pii/src/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions relay-pii/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PiiConfig> {
let rv = to_pii_config_impl(datascrubbing_config).unwrap();
Expand Down
Loading