diff --git a/Cargo.toml b/Cargo.toml index 7bd1c9bf4..4da467184 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ description = """ Sentry (getsentry.com) client for rust ;) """ build = "build.rs" +edition = "2018" autoexamples = true [package.metadata.docs.rs] diff --git a/README.md b/README.md index 04dab9eb8..9cfcb1735 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ We currently only verify this crate against a recent version of Sentry hosted on [sentry.io](https://sentry.io/) but it should work with on-prem Sentry versions 8.20 and later. +Additionally, the lowest Rust version we target is _1.31.0_. + ## Resources - [crates.io](https://crates.io/crates/sentry) diff --git a/build.rs b/build.rs index 0de9b1de4..5a176cedf 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,3 @@ -#[cfg(feature = "with_rust_info")] -extern crate rustc_version; - use std::env; use std::fs::File; use std::io::Write; diff --git a/examples/before-send.rs b/examples/before-send.rs index 779129132..94c498f09 100644 --- a/examples/before-send.rs +++ b/examples/before-send.rs @@ -1,5 +1,3 @@ -extern crate sentry; - use std::sync::Arc; fn main() { diff --git a/examples/error-chain-demo.rs b/examples/error-chain-demo.rs index 49e0ef0ea..e2803db06 100644 --- a/examples/error-chain-demo.rs +++ b/examples/error-chain-demo.rs @@ -1,7 +1,5 @@ #[macro_use] extern crate error_chain; -#[macro_use] -extern crate sentry; use sentry::integrations::error_chain::capture_error_chain; @@ -25,7 +23,7 @@ fn main() { .parse() .unwrap(), ), - release: sentry_crate_release!(), + release: sentry::release_name!(), ..Default::default() }); diff --git a/examples/event-processors.rs b/examples/event-processors.rs index b1b4698dd..178f452ab 100644 --- a/examples/event-processors.rs +++ b/examples/event-processors.rs @@ -1,5 +1,3 @@ -extern crate sentry; - fn main() { let client = sentry::Client::from_config("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156"); diff --git a/examples/failure-demo.rs b/examples/failure-demo.rs index ea57b28d1..9e5f0bb51 100644 --- a/examples/failure-demo.rs +++ b/examples/failure-demo.rs @@ -1,9 +1,4 @@ -extern crate failure; -#[macro_use] -extern crate failure_derive; -#[macro_use] -extern crate sentry; - +use failure::Fail; use sentry::integrations::failure::capture_error; #[derive(Fail, Debug)] @@ -25,7 +20,7 @@ fn main() { let _sentry = sentry::init(( "https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156", sentry::ClientOptions { - release: sentry_crate_release!(), + release: sentry::release_name!(), ..Default::default() }, )); diff --git a/examples/init-with-client.rs b/examples/init-with-client.rs index f5b205f40..793a86fde 100644 --- a/examples/init-with-client.rs +++ b/examples/init-with-client.rs @@ -1,5 +1,3 @@ -extern crate sentry; - fn main() { let client = sentry::Client::from_config("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156"); diff --git a/examples/log-demo.rs b/examples/log-demo.rs index 8dd2bccc1..19d32384b 100644 --- a/examples/log-demo.rs +++ b/examples/log-demo.rs @@ -1,15 +1,10 @@ -extern crate log; -extern crate pretty_env_logger; -extern crate sentry; - use log::{debug, error, info, warn}; -use sentry::sentry_crate_release; fn main() { let _sentry = sentry::init(( "https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156", sentry::ClientOptions { - release: sentry_crate_release!(), + release: sentry::release_name!(), ..Default::default() }, )); diff --git a/examples/message-demo.rs b/examples/message-demo.rs index 7cfcd4577..79a827b93 100644 --- a/examples/message-demo.rs +++ b/examples/message-demo.rs @@ -1,5 +1,3 @@ -extern crate sentry; - fn main() { let _sentry = sentry::init("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156"); sentry::configure_scope(|scope| { diff --git a/examples/panic-demo.rs b/examples/panic-demo.rs index 484a01b87..f20170e90 100644 --- a/examples/panic-demo.rs +++ b/examples/panic-demo.rs @@ -1,11 +1,8 @@ -#[macro_use] -extern crate sentry; - fn main() { let _sentry = sentry::init(( "https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156", sentry::ClientOptions { - release: sentry_crate_release!(), + release: sentry::release_name!(), ..Default::default() }, )); diff --git a/examples/send-with-extra.rs b/examples/send-with-extra.rs index 83f1ff4e9..4fb0b4eec 100644 --- a/examples/send-with-extra.rs +++ b/examples/send-with-extra.rs @@ -1,5 +1,3 @@ -extern crate sentry; - fn main() { let _sentry = sentry::init("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156"); diff --git a/examples/thread-demo.rs b/examples/thread-demo.rs index ab7e2c9ef..df2e4a5cb 100644 --- a/examples/thread-demo.rs +++ b/examples/thread-demo.rs @@ -1,9 +1,3 @@ -#[macro_use] -extern crate log; -extern crate pretty_env_logger; -#[macro_use] -extern crate sentry; - use std::sync::Arc; use std::thread; @@ -14,7 +8,7 @@ fn main() { let _sentry = sentry::init(( "https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156", sentry::ClientOptions { - release: sentry_crate_release!(), + release: sentry::release_name!(), ..Default::default() }, )); @@ -25,12 +19,12 @@ fn main() { sentry::integrations::panic::register_panic_handler(); // the log integration sends to Hub::current() - info!("Spawning thread"); + log::info!("Spawning thread"); thread::spawn(|| { // The thread spawned here gets a new hub cloned from the hub of the // main thread. - info!("Spawned thread, configuring scope."); + log::info!("Spawned thread, configuring scope."); // now we want to create a new hub based on the thread's normal hub for // working with it explicitly. @@ -47,7 +41,7 @@ fn main() { sentry::Hub::run(hub, || { // the log integration picks up the Hub::current which is now bound // to the outer hub. - error!("Failing!"); + log::error!("Failing!"); }); }) .join() diff --git a/integrations/sentry-actix/Cargo.toml b/integrations/sentry-actix/Cargo.toml index 0f1abdcdb..536c06ad8 100644 --- a/integrations/sentry-actix/Cargo.toml +++ b/integrations/sentry-actix/Cargo.toml @@ -10,6 +10,7 @@ documentation = "https://docs.rs/sentry-actix" description = """ Sentry client extension for actix-web """ +edition = "2018" [dependencies] actix-web = { version = "0.7", default-features = false } diff --git a/integrations/sentry-actix/examples/basic.rs b/integrations/sentry-actix/examples/basic.rs index 8cb6b3203..44758138d 100644 --- a/integrations/sentry-actix/examples/basic.rs +++ b/integrations/sentry-actix/examples/basic.rs @@ -1,7 +1,3 @@ -extern crate actix_web; -extern crate sentry; -extern crate sentry_actix; - use std::env; use std::io; diff --git a/integrations/sentry-actix/src/lib.rs b/integrations/sentry-actix/src/lib.rs index c84124304..3d32ff14a 100644 --- a/integrations/sentry-actix/src/lib.rs +++ b/integrations/sentry-actix/src/lib.rs @@ -74,10 +74,6 @@ //! }); //! # } //! ``` -extern crate actix_web; -extern crate failure; -extern crate fragile; -extern crate sentry; use std::borrow::Cow; use std::cell::RefCell; @@ -326,7 +322,7 @@ impl ActixWebHubExt for Hub { fn capture_actix_error(&self, err: &Error) -> Uuid { let mut exceptions = vec![]; - let mut ptr: Option<&Fail> = Some(err.as_fail()); + let mut ptr: Option<&dyn Fail> = Some(err.as_fail()); let mut idx = 0; while let Some(fail) = ptr { // Check whether the failure::Fail held by err is a failure::Error wrapped in Compat diff --git a/src/backtrace_support.rs b/src/backtrace_support.rs index e0068b258..9bbff9c4d 100644 --- a/src/backtrace_support.rs +++ b/src/backtrace_support.rs @@ -5,7 +5,7 @@ use regex::{Captures, Regex}; use crate::protocol::{Frame, Stacktrace}; -lazy_static! { +lazy_static::lazy_static! { static ref HASH_FUNC_RE: Regex = Regex::new(r#"(?x) ^(.*)::h[a-f0-9]{16}$ "#).unwrap(); @@ -27,6 +27,7 @@ pub static ref WELL_KNOWN_SYS_MODULES: Vec<&'static str> = { } rv }; + pub static ref WELL_KNOWN_BORDER_FRAMES: Vec<&'static str> = { #[allow(unused_mut)] let mut rv = vec![ @@ -44,6 +45,7 @@ pub static ref WELL_KNOWN_BORDER_FRAMES: Vec<&'static str> = { } rv }; + pub static ref SECONDARY_BORDER_FRAMES: Vec<(&'static str, &'static str)> = { #![allow(unused_mut)] let mut rv = Vec::new(); @@ -74,7 +76,7 @@ pub fn strip_symbol(s: &str) -> &str { pub fn demangle_symbol(s: &str) -> String { COMMON_RUST_SYMBOL_ESCAPES_RE - .replace_all(s, |caps: &Captures| { + .replace_all(s, |caps: &Captures<'_>| { match &caps[1] { "SP" => "@", "BP" => "*", diff --git a/src/client.rs b/src/client.rs index fe9518ffa..dd2442401 100644 --- a/src/client.rs +++ b/src/client.rs @@ -21,11 +21,11 @@ use crate::utils; /// The Sentry client object. pub struct Client { options: ClientOptions, - transport: RwLock>>>, + transport: RwLock>>>, } impl fmt::Debug for Client { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("dsn", &self.dsn()) .field("options", &self.options) @@ -43,7 +43,7 @@ impl Clone for Client { } /// Type alias for before event/breadcrumb handlers. -pub type BeforeCallback = Arc Option + Send + Sync>>; +pub type BeforeCallback = Arc Option + Send + Sync>>; /// Configuration settings for the client. pub struct ClientOptions { @@ -54,7 +54,7 @@ pub struct ClientOptions { /// This is typically either a boxed function taking the client options by /// reference and returning a `Transport`, a boxed `Arc` or /// alternatively the `DefaultTransportFactory`. - pub transport: Box, + pub transport: Box, /// module prefixes that are always considered in_app pub in_app_include: Vec<&'static str>, /// module prefixes that are never in_app @@ -107,7 +107,7 @@ pub struct ClientOptions { impl RefUnwindSafe for ClientOptions {} impl fmt::Debug for ClientOptions { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { #[derive(Debug)] struct TransportFactory; #[derive(Debug)] @@ -207,7 +207,7 @@ impl Default for ClientOptions { } } -lazy_static! { +lazy_static::lazy_static! { static ref CRATE_RE: Regex = Regex::new(r"^(?:_<)?([a-zA-Z0-9_]+?)(?:\.\.|::)").unwrap(); } @@ -385,7 +385,7 @@ impl Client { mut event: Event<'static>, scope: Option<&Scope>, ) -> Option> { - lazy_static! { + lazy_static::lazy_static! { static ref DEBUG_META: DebugMeta = DebugMeta { images: utils::debug_images(), ..Default::default() diff --git a/src/constants.rs b/src/constants.rs index afcc8bb80..4cfb932ea 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -5,7 +5,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION"); include!(concat!(env!("OUT_DIR"), "/constants.gen.rs")); -lazy_static! { +lazy_static::lazy_static! { pub static ref USER_AGENT: String = format!("sentry.rust/{}", VERSION); pub static ref SDK_INFO: ClientSdkInfo = ClientSdkInfo { name: "sentry-rust".into(), diff --git a/src/hub.rs b/src/hub.rs index 5e1c48825..426ec9346 100644 --- a/src/hub.rs +++ b/src/hub.rs @@ -15,7 +15,7 @@ use crate::scope::{Scope, ScopeGuard}; use crate::{client::Client, scope::Stack, utils}; #[cfg(feature = "with_client_implementation")] -lazy_static! { +lazy_static::lazy_static! { static ref PROCESS_HUB: (Arc, thread::ThreadId) = ( Arc::new(Hub::new(None, Arc::new(Default::default()))), thread::current().id() diff --git a/src/integrations/failure.rs b/src/integrations/failure.rs index 75be60701..6c0217024 100644 --- a/src/integrations/failure.rs +++ b/src/integrations/failure.rs @@ -35,7 +35,7 @@ use crate::hub::Hub; use crate::internals::Uuid; use crate::protocol::{Event, Exception, Frame, Level, Stacktrace}; -lazy_static! { +lazy_static::lazy_static! { static ref MODULE_SPLIT_RE: Regex = Regex::new(r"^(.*)::(.*?)$").unwrap(); static ref FRAME_RE: Regex = Regex::new( r#"(?xm) @@ -160,7 +160,7 @@ pub fn event_from_error(err: &failure::Error) -> Event<'static> { pub fn event_from_fail(fail: &F) -> Event<'static> { let mut exceptions = vec![exception_from_single_fail(fail, fail.backtrace())]; - let mut ptr: Option<&Fail> = None; + let mut ptr: Option<&dyn Fail> = None; while let Some(cause) = ptr.map(Fail::cause).unwrap_or_else(|| fail.cause()) { exceptions.push(exception_from_single_fail(cause, cause.backtrace())); ptr = Some(cause); diff --git a/src/integrations/log.rs b/src/integrations/log.rs index 88327f233..8c4a9f2b0 100644 --- a/src/integrations/log.rs +++ b/src/integrations/log.rs @@ -96,7 +96,7 @@ impl LoggerOptions { } /// Checks if an issue should be created. - fn create_issue_for_record(&self, record: &log::Record) -> bool { + fn create_issue_for_record(&self, record: &log::Record<'_>) -> bool { match record.level() { log::Level::Warn => self.emit_warning_events, log::Level::Error => self.emit_error_events, @@ -107,7 +107,7 @@ impl LoggerOptions { /// Provides a dispatching logger. pub struct Logger { - dest: Option>, + dest: Option>, options: LoggerOptions, } @@ -116,7 +116,7 @@ impl Logger { /// /// It can just send to Sentry or additionally also send messages to another /// logger. - pub fn new(dest: Option>, options: LoggerOptions) -> Logger { + pub fn new(dest: Option>, options: LoggerOptions) -> Logger { Logger { dest, options } } @@ -126,13 +126,13 @@ impl Logger { } /// Returns the destination logger. - pub fn dest_log(&self) -> Option<&log::Log> { + pub fn dest_log(&self) -> Option<&dyn log::Log> { self.dest.as_ref().map(|x| &**x) } } /// Creates a breadcrumb from a given log record. -pub fn breadcrumb_from_record(record: &log::Record) -> Breadcrumb { +pub fn breadcrumb_from_record(record: &log::Record<'_>) -> Breadcrumb { Breadcrumb { ty: "log".into(), level: convert_log_level(record.level()), @@ -146,7 +146,7 @@ pub fn breadcrumb_from_record(record: &log::Record) -> Breadcrumb { /// /// If `with_stacktrace` is set to `true` then a stacktrace is attached /// from the current frame. -pub fn event_from_record(record: &log::Record, with_stacktrace: bool) -> Event<'static> { +pub fn event_from_record(record: &log::Record<'_>, with_stacktrace: bool) -> Event<'static> { Event { logger: Some(record.target().into()), level: convert_log_level(record.level()), @@ -166,7 +166,7 @@ pub fn event_from_record(record: &log::Record, with_stacktrace: bool) -> Event<' } impl log::Log for Logger { - fn enabled(&self, md: &log::Metadata) -> bool { + fn enabled(&self, md: &log::Metadata<'_>) -> bool { if let Some(global_filter) = self.options.global_filter { if md.level() > global_filter { return false; @@ -175,7 +175,7 @@ impl log::Log for Logger { md.level() <= self.options.filter || self.dest.as_ref().map_or(false, |x| x.enabled(md)) } - fn log(&self, record: &log::Record) { + fn log(&self, record: &log::Record<'_>) { if self.options.create_issue_for_record(record) { Hub::with_active(|hub| hub.capture_event(event_from_record(record, true))); } @@ -231,7 +231,7 @@ fn convert_log_level(level: log::Level) -> Level { /// /// (For using `env_logger` you can also use the `env_logger` integration /// which simplifies this). -pub fn init(dest: Option>, options: LoggerOptions) { +pub fn init(dest: Option>, options: LoggerOptions) { let logger = Logger::new(dest, options); let filter = logger.options().effective_global_filter(); if filter > log::max_level() { diff --git a/src/integrations/panic.rs b/src/integrations/panic.rs index 1c4184053..3a0549737 100644 --- a/src/integrations/panic.rs +++ b/src/integrations/panic.rs @@ -20,7 +20,7 @@ use crate::hub::Hub; use crate::protocol::{Event, Exception, Level}; /// Extract the message of a panic. -pub fn message_from_panic_info<'a>(info: &'a PanicInfo) -> &'a str { +pub fn message_from_panic_info<'a>(info: &'a PanicInfo<'_>) -> &'a str { match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, None => match info.payload().downcast_ref::() { @@ -33,7 +33,7 @@ pub fn message_from_panic_info<'a>(info: &'a PanicInfo) -> &'a str { /// Creates an event from the given panic info. /// /// The stacktrace is calculated from the current frame. -pub fn event_from_panic_info(info: &PanicInfo) -> Event<'static> { +pub fn event_from_panic_info(info: &PanicInfo<'_>) -> Event<'static> { let msg = message_from_panic_info(info); Event { exception: vec![Exception { @@ -53,7 +53,7 @@ pub fn event_from_panic_info(info: &PanicInfo) -> Event<'static> { /// This panic handler report panics to Sentry. It also attempts to prevent /// double faults in some cases where it's known to be unsafe to invoke the /// Sentry panic handler. -pub fn panic_handler(info: &PanicInfo) { +pub fn panic_handler(info: &PanicInfo<'_>) { Hub::with_active(|hub| { hub.capture_event(event_from_panic_info(info)); }); diff --git a/src/lib.rs b/src/lib.rs index 651c98fdb..d80096f41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,83 +106,30 @@ //! * `with_test_support`: enables the test support module #![warn(missing_docs)] -#[cfg(feature = "with_backtrace")] -extern crate backtrace; -#[cfg(feature = "with_client_implementation")] -extern crate im; -#[cfg(any( - feature = "with_backtrace", - feature = "with_client_implementation", - feature = "with_failure", - feature = "with_device_info" -))] -#[macro_use] -extern crate lazy_static; -#[cfg(feature = "with_client_implementation")] -extern crate httpdate; -#[cfg(feature = "with_client_implementation")] -extern crate reqwest; -extern crate sentry_types; -#[cfg(feature = "with_client_implementation")] -extern crate url; - -#[cfg(feature = "with_device_info")] -extern crate libc; - -#[cfg(feature = "with_device_info")] -extern crate hostname; - -#[cfg(all(feature = "with_device_info", not(windows)))] -extern crate uname; - -#[cfg(any(feature = "with_backtrace", feature = "with_device_info"))] -extern crate regex; - -#[cfg(feature = "with_failure")] -extern crate failure; - -#[cfg(feature = "with_error_chain")] -extern crate error_chain; - -#[cfg(any(feature = "with_log", feature = "with_debug_to_log"))] -#[cfg_attr(feature = "with_debug_to_log", macro_use)] -extern crate log; - -#[cfg(feature = "with_env_logger")] -extern crate env_logger; - -#[cfg(feature = "with_debug_meta")] -extern crate findshlibs; - -#[cfg(all(feature = "with_debug_meta", unix))] -extern crate memmap; - -#[cfg(all(feature = "with_debug_meta", unix))] -extern crate goblin; - -extern crate rand; - #[macro_use] mod macros; mod api; -#[cfg(feature = "with_client_implementation")] -mod client; mod hub; mod scope; +pub mod integrations; + #[cfg(feature = "with_backtrace")] mod backtrace_support; + +#[cfg(feature = "with_client_implementation")] +mod client; #[cfg(feature = "with_client_implementation")] mod constants; -pub mod integrations; -#[cfg(any(test, feature = "with_test_support"))] -pub mod test; #[cfg(feature = "with_client_implementation")] mod transport; #[cfg(feature = "with_client_implementation")] pub mod utils; +#[cfg(any(test, feature = "with_test_support"))] +pub mod test; + /// Useful internals. /// /// This module contains types that users of the create typically do not @@ -191,26 +138,27 @@ pub mod utils; pub mod internals { pub use crate::hub::IntoBreadcrumbs; pub use crate::scope::ScopeGuard; + #[cfg(feature = "with_client_implementation")] pub use crate::{ client::{ClientInitGuard, IntoDsn}, transport::{DefaultTransportFactory, HttpTransport, Transport, TransportFactory}, }; + pub use sentry_types::{ Auth, ChronoParseError, DateTime, DebugId, Dsn, DsnParseError, ParseDebugIdError, ProjectId, ProjectIdParseError, Scheme, TimeZone, Utc, Uuid, UuidVariant, UuidVersion, }; } -/// Directly exposed apis. +// public api or exports from this crate pub use crate::api::*; +pub use crate::hub::Hub; +pub use crate::scope::Scope; + +#[cfg(feature = "with_client_implementation")] +pub use crate::client::{init, Client, ClientOptions}; // public api from other crates pub use sentry_types::protocol::v7 as protocol; pub use sentry_types::protocol::v7::{Breadcrumb, Level, User}; - -// public exports from this crate -#[cfg(feature = "with_client_implementation")] -pub use crate::client::{init, Client, ClientOptions}; -pub use crate::hub::Hub; -pub use crate::scope::Scope; diff --git a/src/macros.rs b/src/macros.rs index 397a86268..f2c62b422 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -4,7 +4,7 @@ /// the information supplied by cargo to calculate a release. #[macro_export] #[cfg(feature = "with_client_implementation")] -macro_rules! sentry_crate_release { +macro_rules! release_name { () => {{ use std::sync::{Once, ONCE_INIT}; static mut INIT: Once = ONCE_INIT; @@ -23,6 +23,15 @@ macro_rules! sentry_crate_release { }}; } +#[macro_export] +#[cfg(feature = "with_client_implementation")] +#[deprecated(since = "0.13.0", note = "use sentry::release_name! instead")] +macro_rules! sentry_crate_release { + () => { + ::sentry::release_name!() + }; +} + macro_rules! with_client_impl { ($body:block) => { #[cfg(feature = "with_client_implementation")] @@ -41,7 +50,7 @@ macro_rules! sentry_debug { ($($arg:tt)*) => { with_client_impl! {{ #[cfg(feature = "with_debug_to_log")] { - debug!(target: "sentry", $($arg)*); + ::log::debug!(target: "sentry", $($arg)*); } #[cfg(not(feature = "with_debug_to_log"))] { $crate::Hub::with(|hub| { diff --git a/src/scope/noop.rs b/src/scope/noop.rs index 08ca1959a..00a05bf5b 100644 --- a/src/scope/noop.rs +++ b/src/scope/noop.rs @@ -1,6 +1,6 @@ use std::fmt; -use protocol::{Context, Event, Level, User, Value}; +use crate::protocol::{Context, Event, Level, User, Value}; /// The minimal scope. /// diff --git a/src/scope/real.rs b/src/scope/real.rs index d3deaf9f9..8c73d663a 100644 --- a/src/scope/real.rs +++ b/src/scope/real.rs @@ -7,7 +7,7 @@ use crate::protocol::map::Entry; use crate::protocol::{Breadcrumb, Context, Event, Level, User, Value}; use crate::utils; -lazy_static! { +lazy_static::lazy_static! { static ref CONTEXT_DEFAULTS: ContextDefaults = ContextDefaults { os: utils::os_context(), rust: utils::rust_context(), @@ -27,7 +27,7 @@ pub struct Stack { layers: Vec, } -pub type EventProcessor = Box) -> Option> + Send + Sync>; +pub type EventProcessor = Box) -> Option> + Send + Sync>; /// Holds contextual data for the current scope. /// @@ -58,7 +58,7 @@ pub struct Scope { } impl fmt::Debug for Scope { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Scope") .field("level", &self.level) .field("fingerprint", &self.fingerprint) @@ -133,7 +133,7 @@ impl Stack { pub struct ScopeGuard(pub(crate) Option<(Arc>, usize)>); impl fmt::Debug for ScopeGuard { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ScopeGuard") } } @@ -215,7 +215,7 @@ impl Scope { /// Add an event processor to the scope. pub fn add_event_processor( &mut self, - f: Box) -> Option> + Send + Sync>, + f: Box) -> Option> + Send + Sync>, ) { self.event_processors.push_back(Arc::new(f)); } diff --git a/src/test.rs b/src/test.rs index f0c2ac698..53ea7d68e 100644 --- a/src/test.rs +++ b/src/test.rs @@ -26,7 +26,7 @@ use crate::internals::Dsn; use crate::protocol::Event; use crate::transport::Transport; -lazy_static! { +lazy_static::lazy_static! { static ref TEST_DSN: Dsn = "https://public@sentry.invalid/1".parse().unwrap(); } diff --git a/src/transport.rs b/src/transport.rs index 46e88ed5a..d56f0462a 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -32,11 +32,11 @@ pub trait Transport: Send + Sync + 'static { } pub trait InternalTransportFactoryClone { - fn clone_factory(&self) -> Box; + fn clone_factory(&self) -> Box; } impl InternalTransportFactoryClone for T { - fn clone_factory(&self) -> Box { + fn clone_factory(&self) -> Box { Box::new(self.clone()) } } @@ -56,14 +56,14 @@ impl InternalTransportFactoryClone for T /// options and returning a boxed factory. pub trait TransportFactory: Send + Sync + InternalTransportFactoryClone { /// Given some options creates a transport. - fn create_transport(&self, options: &ClientOptions) -> Box; + fn create_transport(&self, options: &ClientOptions) -> Box; } impl TransportFactory for F where - F: Fn(&ClientOptions) -> Box + Clone + Send + Sync + 'static, + F: Fn(&ClientOptions) -> Box + Clone + Send + Sync + 'static, { - fn create_transport(&self, options: &ClientOptions) -> Box { + fn create_transport(&self, options: &ClientOptions) -> Box { (*self)(options) } } @@ -79,7 +79,7 @@ impl Transport for Arc { } impl TransportFactory for Arc { - fn create_transport(&self, options: &ClientOptions) -> Box { + fn create_transport(&self, options: &ClientOptions) -> Box { let _options = options; Box::new(self.clone()) } @@ -93,7 +93,7 @@ impl TransportFactory for Arc { pub struct DefaultTransportFactory; impl TransportFactory for DefaultTransportFactory { - fn create_transport(&self, options: &ClientOptions) -> Box { + fn create_transport(&self, options: &ClientOptions) -> Box { Box::new(HttpTransport::new(options)) } } diff --git a/src/utils.rs b/src/utils.rs index 208cc3b7b..d910027ff 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -12,7 +12,7 @@ mod model_support { use regex::Regex; use std::ptr; - lazy_static! { + lazy_static::lazy_static! { static ref FAMILY_RE: Regex = Regex::new(r#"([a-zA-Z]+)\d"#).unwrap(); } @@ -69,27 +69,28 @@ mod model_support { mod findshlibs_support { use super::*; + use std::env; + use std::ffi::CStr; + use findshlibs::{ Segment, SharedLibrary, SharedLibraryId, TargetSharedLibrary, TARGET_SUPPORTED, }; - use internals::Uuid; - use protocol::debugid::DebugId; - use protocol::SymbolicDebugImage; - - use std::env; - use std::ffi::CStr; + use crate::internals::Uuid; + use crate::protocol::debugid::DebugId; + use crate::protocol::SymbolicDebugImage; #[cfg(unix)] pub fn find_build_id_from_binary(name: &CStr) -> Option { - use goblin::elf::note::NT_GNU_BUILD_ID; - use goblin::elf::Elf; - use memmap::Mmap; use std::ffi::OsStr; use std::fs::File; use std::os::unix::ffi::OsStrExt; use std::path::Path; + use goblin::elf::note::NT_GNU_BUILD_ID; + use goblin::elf::Elf; + use memmap::Mmap; + fn from_be(id: Uuid) -> Uuid { let (a, b, c, d) = id.as_fields(); Uuid::from_fields(u32::from_be(a), u16::from_be(b), u16::from_be(c), d).unwrap() @@ -240,7 +241,7 @@ pub fn os_context() -> Option { } #[cfg(all(feature = "with_device_info", windows))] { - use constants::PLATFORM; + use crate::constants::PLATFORM; Some( OsContext { name: Some(PLATFORM.into()),