Created
April 13, 2019 18:47
-
-
Save yaahc/8866c5266e7b35091cdb3c60dfa63236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tokio-trace-env-logger/examples/hyper-echo.rs b/tokio-trace-env-logger/examples/hyper-echo.rs | |
index db8bd1b..4d753a0 100644 | |
--- a/tokio-trace-env-logger/examples/hyper-echo.rs | |
+++ b/tokio-trace-env-logger/examples/hyper-echo.rs | |
@@ -124,7 +124,7 @@ fn main() { | |
tokio_trace::subscriber::with_default(subscriber, || { | |
let addr: ::std::net::SocketAddr = ([127, 0, 0, 1], 3000).into(); | |
- let mut server_span = span!(Level::TRACE, "server", local = &field::debug(addr)); | |
+ let server_span = span!(Level::TRACE, "server", local = &field::debug(addr)); | |
let server = tokio::net::TcpListener::bind(&addr) | |
.expect("bind") | |
.incoming() | |
diff --git a/tokio-trace-fmt/src/default.rs b/tokio-trace-fmt/src/default.rs | |
index 6ce2402..e382438 100644 | |
--- a/tokio-trace-fmt/src/default.rs | |
+++ b/tokio-trace-fmt/src/default.rs | |
@@ -28,7 +28,7 @@ where | |
} | |
ctx.with_current(|(_, span)| write!(f, " {}", span.fields())) | |
.unwrap_or(Ok(()))?; | |
- writeln!(f, "") | |
+ writeln!(f) | |
} | |
pub fn fmt_verbose<N>(ctx: &span::Context<N>, f: &mut Write, event: &Event) -> fmt::Result | |
@@ -47,7 +47,7 @@ where | |
let mut recorder = ctx.new_visitor(f, true); | |
event.record(&mut recorder); | |
} | |
- writeln!(f, "") | |
+ writeln!(f) | |
} | |
pub struct NewRecorder; | |
@@ -206,12 +206,12 @@ impl<'a> fmt::Display for FmtLevel<'a> { | |
#[cfg(feature = "ansi")] | |
impl<'a> fmt::Display for FmtLevel<'a> { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
- match self.0 { | |
- &Level::TRACE => write!(f, "{}", Colour::Purple.paint("TRACE")), | |
- &Level::DEBUG => write!(f, "{}", Colour::Blue.paint("DEBUG")), | |
- &Level::INFO => write!(f, "{}", Colour::Green.paint(" INFO")), | |
- &Level::WARN => write!(f, "{}", Colour::Yellow.paint(" WARN")), | |
- &Level::ERROR => write!(f, "{}", Colour::Red.paint("ERROR")), | |
+ match *self.0 { | |
+ Level::TRACE => write!(f, "{}", Colour::Purple.paint("TRACE")), | |
+ Level::DEBUG => write!(f, "{}", Colour::Blue.paint("DEBUG")), | |
+ Level::INFO => write!(f, "{}", Colour::Green.paint(" INFO")), | |
+ Level::WARN => write!(f, "{}", Colour::Yellow.paint(" WARN")), | |
+ Level::ERROR => write!(f, "{}", Colour::Red.paint("ERROR")), | |
} | |
} | |
} | |
diff --git a/tokio-trace-fmt/src/filter.rs b/tokio-trace-fmt/src/filter.rs | |
index 6dd4b52..fa94ab6 100644 | |
--- a/tokio-trace-fmt/src/filter.rs | |
+++ b/tokio-trace-fmt/src/filter.rs | |
@@ -5,7 +5,7 @@ use tokio_trace_core::{subscriber::Interest, Level, Metadata}; | |
use std::env; | |
-pub const DEFAULT_FILTER_ENV: &'static str = "RUST_LOG"; | |
+pub const DEFAULT_FILTER_ENV: &str = "RUST_LOG"; | |
pub trait Filter<N> { | |
fn callsite_enabled(&self, metadata: &Metadata, ctx: &span::Context<N>) -> Interest { | |
@@ -106,13 +106,13 @@ where | |
impl<N> Filter<N> for EnvFilter { | |
fn callsite_enabled(&self, metadata: &Metadata, _: &span::Context<N>) -> Interest { | |
- if !self.includes_span_directive && metadata.level() > &self.max_level { | |
+ if !self.includes_span_directive && *metadata.level() > self.max_level { | |
return Interest::never(); | |
} | |
let mut interest = Interest::never(); | |
for directive in self.directives_for(metadata) { | |
- let accepts_level = metadata.level() <= &directive.level; | |
+ let accepts_level = *metadata.level() <= directive.level; | |
match directive.in_span.as_ref() { | |
// The directive applies to anything within the span described | |
// by this metadata. The span must always be enabled. | |
@@ -136,7 +136,7 @@ impl<N> Filter<N> for EnvFilter { | |
fn enabled<'a>(&self, metadata: &Metadata, ctx: &span::Context<'a, N>) -> bool { | |
for directive in self.directives_for(metadata) { | |
- let accepts_level = metadata.level() <= &directive.level; | |
+ let accepts_level = *metadata.level() <= directive.level; | |
match directive.in_span.as_ref() { | |
// The directive applies to anything within the span described | |
// by this metadata. The span must always be enabled. | |
diff --git a/tokio-trace-fmt/src/lib.rs b/tokio-trace-fmt/src/lib.rs | |
index 5d118df..8d85ea7 100644 | |
--- a/tokio-trace-fmt/src/lib.rs | |
+++ b/tokio-trace-fmt/src/lib.rs | |
@@ -236,6 +236,7 @@ impl<N, E, F> Builder<N, E, F> { | |
/// Sets the subscriber being built to use the default full span formatter. | |
// TODO: this should probably just become the default. | |
+ #[allow(clippy::type_complexity)] | |
pub fn full( | |
self, | |
) -> Builder<N, fn(&span::Context<N>, &mut fmt::Write, &Event) -> fmt::Result, F> | |
@@ -268,10 +269,7 @@ impl<N, E, F> Builder<N, E, F> { | |
/// by default). | |
pub fn inherit_fields(self, inherit_fields: bool) -> Self { | |
Builder { | |
- settings: Settings { | |
- inherit_fields, | |
- ..self.settings | |
- }, | |
+ settings: Settings { inherit_fields }, | |
..self | |
} | |
} | |
diff --git a/tokio-trace-fmt/src/span.rs b/tokio-trace-fmt/src/span.rs | |
index 01e541b..9af05f0 100644 | |
--- a/tokio-trace-fmt/src/span.rs | |
+++ b/tokio-trace-fmt/src/span.rs | |
@@ -99,7 +99,7 @@ pub(crate) fn pop(expected_id: &Id) { | |
impl<'a> Span<'a> { | |
pub fn name(&self) -> &'static str { | |
match self.lock.span { | |
- State::Full(ref data) => data.name.as_ref(), | |
+ State::Full(ref data) => data.name, | |
State::Empty(_) => unreachable!(), | |
} | |
} | |
@@ -388,7 +388,7 @@ impl Slot { | |
let mut recorder = new_visitor.make(&mut fields, true); | |
attrs.record(&mut recorder); | |
} | |
- if fields.len() != 0 { | |
+ if fields.is_empty() { | |
data.is_empty = false; | |
} | |
Self { | |
@@ -413,7 +413,7 @@ impl Slot { | |
let mut recorder = new_visitor.make(fields, true); | |
attrs.record(&mut recorder); | |
} | |
- if fields.len() != 0 { | |
+ if fields.is_empty() { | |
data.is_empty = false; | |
} | |
match mem::replace(&mut self.span, State::Full(data)) { | |
@@ -435,7 +435,7 @@ impl Slot { | |
let mut recorder = new_visitor.make(buf, data.is_empty); | |
fields.record(&mut recorder); | |
} | |
- if buf.len() != 0 { | |
+ if buf.is_empty() { | |
data.is_empty = false; | |
} | |
} | |
@@ -453,14 +453,14 @@ impl Slot { | |
impl Slab { | |
#[inline] | |
fn write_slot(&self, idx: usize) -> Option<RwLockWriteGuard<Slot>> { | |
- self.slab.get(idx).map(|slot| slot.write()) | |
+ self.slab.get(idx).map(RwLock::write) | |
} | |
#[inline] | |
- fn read_slot<'a>(&'a self, idx: usize) -> Option<RwLockReadGuard<'a, Slot>> { | |
+ fn read_slot(&self, idx: usize) -> Option<RwLockReadGuard<'_, Slot>> { | |
self.slab | |
.get(idx) | |
- .map(|slot| slot.read()) | |
+ .map(RwLock::read) | |
.and_then(|lock| match lock.span { | |
State::Empty(_) => None, | |
State::Full(_) => Some(lock), | |
diff --git a/tokio-trace-log/src/lib.rs b/tokio-trace-log/src/lib.rs | |
index caa1091..ba8ed9c 100644 | |
--- a/tokio-trace-log/src/lib.rs | |
+++ b/tokio-trace-log/src/lib.rs | |
@@ -115,12 +115,12 @@ impl<'a> AsTrace for log::Record<'a> { | |
impl AsLog for tokio_trace::Level { | |
type Log = log::Level; | |
fn as_log(&self) -> log::Level { | |
- match self { | |
- &tokio_trace::Level::ERROR => log::Level::Error, | |
- &tokio_trace::Level::WARN => log::Level::Warn, | |
- &tokio_trace::Level::INFO => log::Level::Info, | |
- &tokio_trace::Level::DEBUG => log::Level::Debug, | |
- &tokio_trace::Level::TRACE => log::Level::Trace, | |
+ match *self { | |
+ tokio_trace::Level::ERROR => log::Level::Error, | |
+ tokio_trace::Level::WARN => log::Level::Warn, | |
+ tokio_trace::Level::INFO => log::Level::Info, | |
+ tokio_trace::Level::DEBUG => log::Level::Debug, | |
+ tokio_trace::Level::TRACE => log::Level::Trace, | |
} | |
} | |
} | |
@@ -463,8 +463,8 @@ impl Subscriber for TraceLogger { | |
&log::Record::builder() | |
.metadata(log_meta) | |
.target(meta.target) | |
- .module_path(meta.module_path.as_ref().map(|&p| p)) | |
- .file(meta.file.as_ref().map(|&f| f)) | |
+ .module_path(meta.module_path.as_ref().cloned()) | |
+ .file(meta.file.as_ref().cloned()) | |
.line(meta.line) | |
.args(format_args!( | |
"{}{}{}{}", | |
diff --git a/tokio-trace-proc-macros/examples/basic.rs b/tokio-trace-proc-macros/examples/basic.rs | |
index 815a6c9..7677361 100644 | |
--- a/tokio-trace-proc-macros/examples/basic.rs | |
+++ b/tokio-trace-proc-macros/examples/basic.rs | |
@@ -13,7 +13,7 @@ fn main() { | |
tokio_trace::subscriber::with_default(subscriber, || { | |
let num: u64 = 1; | |
- let mut span = span!( | |
+ let span = span!( | |
Level::TRACE, | |
"Getting rec from another function.", | |
number_of_recs = &num | |
diff --git a/tokio-trace-subscriber/src/registry.rs b/tokio-trace-subscriber/src/registry.rs | |
index da29bcd..251202f 100644 | |
--- a/tokio-trace-subscriber/src/registry.rs | |
+++ b/tokio-trace-subscriber/src/registry.rs | |
@@ -171,17 +171,15 @@ impl RegisterSpan for IncreasingCounter { | |
fn new_span(&self, _new_span: &Attributes) -> Id { | |
let id = self.next_id.fetch_add(1, Ordering::SeqCst); | |
- let id = Id::from_u64(id as u64); | |
+ Id::from_u64(id as u64) | |
// if let Ok(spans) = self.spans.lock() { | |
// // spans.insert(id.clone(), new_span); | |
// } | |
- id | |
} | |
fn new_id(&self, _new: &Attributes) -> Id { | |
let id = self.next_id.fetch_add(1, Ordering::SeqCst); | |
- let id = Id::from_u64(id as u64); | |
- id | |
+ Id::from_u64(id as u64) | |
} | |
fn add_follows_from(&self, _span: &Id, _follows: &Id) { | |
diff --git a/tokio-trace-tower-http/examples/tower-h2-server.rs b/tokio-trace-tower-http/examples/tower-h2-server.rs | |
index f1ae4dc..bf54c26 100644 | |
--- a/tokio-trace-tower-http/examples/tower-h2-server.rs | |
+++ b/tokio-trace-tower-http/examples/tower-h2-server.rs | |
@@ -122,7 +122,7 @@ fn main() { | |
let addr = "[::1]:8888".parse().unwrap(); | |
let bind = TcpListener::bind(&addr).expect("bind"); | |
- let mut serve_span = span!( | |
+ let serve_span = span!( | |
Level::TRACE, | |
"serve", | |
local_ip = field::debug(addr.ip()), | |
@@ -138,7 +138,7 @@ fn main() { | |
.incoming() | |
.fold((h2, reactor), |(mut h2, reactor), sock| { | |
let addr = sock.peer_addr().expect("can't get addr"); | |
- let mut conn_span = span!( | |
+ let conn_span = span!( | |
Level::TRACE, | |
"conn", | |
remote_ip = field::debug(addr.ip()), | |
diff --git a/tokio-trace-tower/src/lib.rs b/tokio-trace-tower/src/lib.rs | |
index 75ae848..627cc53 100644 | |
--- a/tokio-trace-tower/src/lib.rs | |
+++ b/tokio-trace-tower/src/lib.rs | |
@@ -41,7 +41,7 @@ where | |
let inner = &mut self.inner; | |
span.enter(|| { | |
// TODO: custom `Value` impls for `http` types would be nice... | |
- let mut span = span!(Level::TRACE, "request", request = &field::debug(&req)); | |
+ let span = span!(Level::TRACE, "request", request = &field::debug(&req)); | |
let span2 = span.clone(); | |
span.enter(move || inner.call(req).instrument(span2)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment