From 58bf9edf32db3e23facefb88b47176ebca207dc9 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 20 Nov 2020 10:55:38 +0100 Subject: [PATCH 1/3] fix: Make Rust 1.48 clippy happy --- sentry-core/src/scope/real.rs | 1 + sentry-types/src/dsn.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry-core/src/scope/real.rs b/sentry-core/src/scope/real.rs index 3080f91c..b68d8c7f 100644 --- a/sentry-core/src/scope/real.rs +++ b/sentry-core/src/scope/real.rs @@ -32,6 +32,7 @@ pub type EventProcessor = Box) -> Option> + /// [`add_breadcrumb`]: fn.add_breadcrumb.html /// [`configure_scope`]: fn.configure_scope.html #[derive(Clone)] +#[allow(clippy::rc_buffer)] pub struct Scope { pub(crate) level: Option, pub(crate) fingerprint: Option>>>, diff --git a/sentry-types/src/dsn.rs b/sentry-types/src/dsn.rs index 16167a40..e67aa5e5 100644 --- a/sentry-types/src/dsn.rs +++ b/sentry-types/src/dsn.rs @@ -174,7 +174,7 @@ impl FromStr for Dsn { let project_id = path_segments .next() - .ok_or_else(|| ParseDsnError::NoProjectId)? + .ok_or(ParseDsnError::NoProjectId)? .parse() .map_err(ParseDsnError::InvalidProjectId)?; let path = match path_segments.next().unwrap_or("") { From 9f9776604cdd9c7b90d10be4bdf4cf997a2acd8d Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 20 Nov 2020 12:42:38 +0100 Subject: [PATCH 2/3] rather make clippy happy --- sentry-core/src/scope/real.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sentry-core/src/scope/real.rs b/sentry-core/src/scope/real.rs index b68d8c7f..23df110e 100644 --- a/sentry-core/src/scope/real.rs +++ b/sentry-core/src/scope/real.rs @@ -32,11 +32,10 @@ pub type EventProcessor = Box) -> Option> + /// [`add_breadcrumb`]: fn.add_breadcrumb.html /// [`configure_scope`]: fn.configure_scope.html #[derive(Clone)] -#[allow(clippy::rc_buffer)] pub struct Scope { pub(crate) level: Option, - pub(crate) fingerprint: Option>>>, - pub(crate) transaction: Option>, + pub(crate) fingerprint: Option]>>, + pub(crate) transaction: Option>, pub(crate) breadcrumbs: im::Vector, pub(crate) user: Option>, pub(crate) extra: im::HashMap, @@ -168,13 +167,13 @@ impl Scope { /// Sets the fingerprint. pub fn set_fingerprint(&mut self, fingerprint: Option<&[&str]>) { - self.fingerprint = fingerprint - .map(|fp| Arc::new(fp.iter().map(|x| Cow::Owned((*x).to_string())).collect())) + self.fingerprint = + fingerprint.map(|fp| fp.iter().map(|s| Cow::Owned((*s).into())).collect()) } /// Sets the transaction. pub fn set_transaction(&mut self, transaction: Option<&str>) { - self.transaction = transaction.map(|txn| Arc::new(txn.to_string())); + self.transaction = transaction.map(Arc::from); } /// Sets the user for the current scope. @@ -232,8 +231,8 @@ impl Scope { } if event.user.is_none() { - if let Some(ref user) = self.user { - event.user = Some((**user).clone()); + if let Some(user) = self.user.as_deref() { + event.user = Some(user.clone()); } } @@ -245,16 +244,16 @@ impl Scope { event.contexts.extend(self.contexts.clone().into_iter()); if event.transaction.is_none() { - if let Some(ref txn) = self.transaction { - event.transaction = Some((**txn).clone()); + if let Some(txn) = self.transaction.as_deref() { + event.transaction = Some(txn.to_owned()); } } if event.fingerprint.len() == 1 && (event.fingerprint[0] == "{{ default }}" || event.fingerprint[0] == "{{default}}") { - if let Some(ref fp) = self.fingerprint { - event.fingerprint = Cow::Owned((**fp).clone()); + if let Some(fp) = self.fingerprint.as_deref() { + event.fingerprint = Cow::Owned(fp.to_owned()); } } From 9c20c58447a84eba1eb67e7ee0164d6477b00033 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 20 Nov 2020 14:08:40 +0100 Subject: [PATCH 3/3] remove more of leftover failure references --- sentry-core/Cargo.toml | 1 - sentry-core/src/error.rs | 7 ------- sentry/src/defaults.rs | 3 --- sentry/src/lib.rs | 2 -- 4 files changed, 13 deletions(-) diff --git a/sentry-core/Cargo.toml b/sentry-core/Cargo.toml index 59c2200c..c3c3a809 100644 --- a/sentry-core/Cargo.toml +++ b/sentry-core/Cargo.toml @@ -38,5 +38,4 @@ log_ = { package = "log", version = "0.4.8", optional = true, features = ["std"] sentry = { version = "0.21.0", path = "../sentry", default-features = false, features = ["test"] } thiserror = "1.0.15" anyhow = "1.0.30" -failure = "0.1.8" tokio = { version = "0.2", features = ["rt-core", "macros"] } diff --git a/sentry-core/src/error.rs b/sentry-core/src/error.rs index 980d09ad..4ee16db1 100644 --- a/sentry-core/src/error.rs +++ b/sentry-core/src/error.rs @@ -145,11 +145,4 @@ fn test_parse_type_from_debug() { anyhow::Error::from("NaN".parse::().unwrap_err()) ); assert_eq!(parse(&err), "ParseIntError"); - - // `failure` is using normal debug formatting - let err = format!( - "{:?}", - failure::Error::from("NaN".parse::().unwrap_err()) - ); - assert_eq!(parse(&err), "ParseIntError"); } diff --git a/sentry/src/defaults.rs b/sentry/src/defaults.rs index c58bd18d..0a8fbaca 100644 --- a/sentry/src/defaults.rs +++ b/sentry/src/defaults.rs @@ -1,6 +1,3 @@ -#![cfg_attr(feature = "error-chain", allow(deprecated))] -#![cfg_attr(feature = "failure", allow(deprecated))] - use std::env; use std::{borrow::Cow, sync::Arc}; diff --git a/sentry/src/lib.rs b/sentry/src/lib.rs index 534144f6..cdf56b6b 100644 --- a/sentry/src/lib.rs +++ b/sentry/src/lib.rs @@ -56,8 +56,6 @@ //! //! * `anyhow`: Enables support for the `anyhow` crate. //! * `debug-images`: Attaches a list of loaded libraries to events (currently only supported on unix). -//! * `error-chain`: Enables support for the `error-chain` crate. -//! * `failure`: Enables support for the `failure` crate. //! * `log`: Enables support for the `log` crate. //! * `env_logger`: Enables support for the `log` crate with additional `env_logger` support. //! * `slog`: Enables support for the `slog` crate.