chore: fix warnings introduced by Rustc 1.54 (#1495)

Split from #1460
This commit is contained in:
Teo Klestrup Röijezon 2021-08-06 18:36:27 +02:00 committed by GitHub
parent 0af3ea6465
commit 5f0f5cc97e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 54 additions and 55 deletions

View File

@ -258,7 +258,7 @@ where
{
fn set_from(&self, bytes: Bytes) -> Result<(), String> {
use std::str;
let body = str::from_utf8(&bytes.as_ref()).map_err(|e| format!("{}", e))?;
let body = str::from_utf8(bytes.as_ref()).map_err(|e| format!("{}", e))?;
trace!(request.body = ?body);
let new_filter = body
.parse::<tracing_subscriber::filter::EnvFilter>()

View File

@ -30,7 +30,7 @@ impl<T: Write + Send + Sync + 'static> Worker<T> {
fn handle_recv(&mut self, result: &Result<Msg, RecvError>) -> io::Result<WorkerState> {
match result {
Ok(Msg::Line(msg)) => {
self.writer.write_all(&msg)?;
self.writer.write_all(msg)?;
Ok(WorkerState::Continue)
}
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),
@ -41,7 +41,7 @@ impl<T: Write + Send + Sync + 'static> Worker<T> {
fn handle_try_recv(&mut self, result: &Result<Msg, TryRecvError>) -> io::Result<WorkerState> {
match result {
Ok(Msg::Line(msg)) => {
self.writer.write_all(&msg)?;
self.writer.write_all(msg)?;
Ok(WorkerState::Continue)
}
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),

View File

@ -66,7 +66,7 @@ fn expr_field() {
.only(),
);
run_test(span, || {
fn_expr_field(&"hello world");
fn_expr_field("hello world");
});
}
@ -80,7 +80,7 @@ fn two_expr_fields() {
.only(),
);
run_test(span, || {
fn_two_expr_fields(&"hello world");
fn_two_expr_fields("hello world");
});
}
@ -95,12 +95,12 @@ fn clashy_expr_field() {
.only(),
);
run_test(span, || {
fn_clashy_expr_field(&"hello world");
fn_clashy_expr_field("hello world");
});
let span = span::mock().with_field(mock("s").with_value(&"s").only());
run_test(span, || {
fn_clashy_expr_field2(&"hello world");
fn_clashy_expr_field2("hello world");
});
}

View File

@ -561,7 +561,7 @@ impl Dispatch {
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
#[inline]
pub fn clone_span(&self, id: &span::Id) -> span::Id {
self.subscriber.clone_span(&id)
self.subscriber.clone_span(id)
}
/// Notifies the subscriber that a [span ID] has been dropped.
@ -724,7 +724,7 @@ impl State {
#[inline]
fn enter(&self) -> Option<Entered<'_>> {
if self.can_enter.replace(false) {
Some(Entered(&self))
Some(Entered(self))
} else {
None
}

View File

@ -401,7 +401,7 @@ impl crate::sealed::Sealed for str {}
impl Value for str {
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
visitor.record_str(key, &self)
visitor.record_str(key, self)
}
}

View File

@ -300,7 +300,7 @@ impl Current {
/// Borrows the `Metadata` of the current span, if one exists and is known.
pub fn metadata(&self) -> Option<&'static Metadata<'static>> {
match self.inner {
CurrentInner::Current { ref metadata, .. } => Some(*metadata),
CurrentInner::Current { metadata, .. } => Some(metadata),
_ => None,
}
}

View File

@ -444,7 +444,7 @@ where
}
let samples = self.time_since_last_event();
let first = expect!(ctx.span(&id), "expected: span id exists in registry");
let first = expect!(ctx.span(id), "expected: span id exists in registry");
let mut stack = String::new();
if !self.config.threads_collapsed {

View File

@ -252,7 +252,7 @@ impl Subscriber for TraceLogger {
let parent = self.current_id();
if self.settings.parent_fields {
let mut next_parent = parent.as_ref();
while let Some(ref parent) = next_parent.and_then(|p| spans.get(&p)) {
while let Some(parent) = next_parent.and_then(|p| spans.get(p)) {
write!(&mut fields, "{}", parent.fields).expect("write to string cannot fail");
next_parent = parent.parent.as_ref();
}
@ -298,7 +298,7 @@ impl Subscriber for TraceLogger {
let current_id = self.current_id();
let current_fields = current_id
.as_ref()
.and_then(|id| spans.get(&id))
.and_then(|id| spans.get(id))
.map(|span| span.fields.as_ref())
.unwrap_or("");
if self.settings.log_ids {

View File

@ -74,14 +74,14 @@ impl PreSampledTracer for Tracer {
// Gather trace state
let (no_parent, trace_id, remote_parent, parent_trace_flags) =
current_trace_state(&builder, &parent_cx, &provider);
current_trace_state(builder, parent_cx, &provider);
// Sample or defer to existing sampling decisions
let (flags, trace_state) = if let Some(result) = &builder.sampling_result {
process_sampling_result(result, parent_trace_flags)
} else if no_parent || remote_parent {
builder.sampling_result = Some(provider.config().sampler.should_sample(
Some(&parent_cx),
Some(parent_cx),
trace_id,
&builder.name,
builder.span_kind.as_ref().unwrap_or(&SpanKind::Internal),

View File

@ -156,21 +156,21 @@ where
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Event<'a> {}
impl<'a> RecordFields for Event<'a> {
fn record(&self, visitor: &mut dyn Visit) {
Event::record(&self, visitor)
Event::record(self, visitor)
}
}
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Attributes<'a> {}
impl<'a> RecordFields for Attributes<'a> {
fn record(&self, visitor: &mut dyn Visit) {
Attributes::record(&self, visitor)
Attributes::record(self, visitor)
}
}
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Record<'a> {}
impl<'a> RecordFields for Record<'a> {
fn record(&self, visitor: &mut dyn Visit) {
Record::record(&self, visitor)
Record::record(self, visitor)
}
}

View File

@ -142,7 +142,7 @@ impl Match for Directive {
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
// Does this directive have a target filter, and does it match the
// metadata's target?
if let Some(ref target) = self.target.as_ref() {
if let Some(target) = self.target.as_ref() {
if !meta.target().starts_with(&target[..]) {
return false;
}
@ -561,7 +561,7 @@ impl Match for StaticDirective {
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
// Does this directive have a target filter, and does it match the
// metadata's target?
if let Some(ref target) = self.target.as_ref() {
if let Some(target) = self.target.as_ref() {
if !meta.target().starts_with(&target[..]) {
return false;
}

View File

@ -636,7 +636,7 @@ mod tests {
Kind::SPAN,
);
let interest = filter.register_callsite(&META);
let interest = filter.register_callsite(META);
assert!(interest.is_never());
}
@ -654,7 +654,7 @@ mod tests {
Kind::SPAN,
);
let interest = filter.register_callsite(&META);
let interest = filter.register_callsite(META);
assert!(interest.is_always());
}
@ -673,7 +673,7 @@ mod tests {
Kind::SPAN,
);
let interest = filter.register_callsite(&META);
let interest = filter.register_callsite(META);
assert!(interest.is_always());
}
@ -692,7 +692,7 @@ mod tests {
Kind::SPAN,
);
let interest = filter.register_callsite(&META);
let interest = filter.register_callsite(META);
assert!(interest.is_never());
}

View File

@ -137,7 +137,7 @@ where
// We should probably rework this to use a `serde_json::Value` or something
// similar in a JSON-specific layer, but I'd (david)
// rather have a uglier fix now rather than shipping broken JSON.
match serde_json::from_str::<serde_json::Value>(&data) {
match serde_json::from_str::<serde_json::Value>(data) {
Ok(serde_json::Value::Object(fields)) => {
for field in fields {
serializer.serialize_entry(&field.0, &field.1)?;
@ -429,25 +429,25 @@ impl<'a> field::Visit for JsonVisitor<'a> {
/// Visit a signed 64-bit integer value.
fn record_i64(&mut self, field: &Field, value: i64) {
self.values
.insert(&field.name(), serde_json::Value::from(value));
.insert(field.name(), serde_json::Value::from(value));
}
/// Visit an unsigned 64-bit integer value.
fn record_u64(&mut self, field: &Field, value: u64) {
self.values
.insert(&field.name(), serde_json::Value::from(value));
.insert(field.name(), serde_json::Value::from(value));
}
/// Visit a boolean value.
fn record_bool(&mut self, field: &Field, value: bool) {
self.values
.insert(&field.name(), serde_json::Value::from(value));
.insert(field.name(), serde_json::Value::from(value));
}
/// Visit a string value.
fn record_str(&mut self, field: &Field, value: &str) {
self.values
.insert(&field.name(), serde_json::Value::from(value));
.insert(field.name(), serde_json::Value::from(value));
}
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
@ -487,7 +487,7 @@ impl<'a> io::Write for WriteAdaptor<'a> {
std::str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
self.fmt_write
.write_str(&s)
.write_str(s)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
Ok(s.as_bytes().len())
@ -771,7 +771,7 @@ mod test {
.lines()
.last()
.expect("expected at least one line to be written!");
match serde_json::from_str(&json) {
match serde_json::from_str(json) {
Ok(v) => v,
Err(e) => panic!(
"assertion failed: JSON shouldn't be malformed\n error: {}\n json: {}",
@ -786,7 +786,7 @@ mod test {
buf: &'static Mutex<Vec<u8>>,
producer: impl FnOnce() -> T,
) {
let make_writer = MockMakeWriter::new(&buf);
let make_writer = MockMakeWriter::new(buf);
let subscriber = builder
.with_writer(make_writer.clone())
.with_timer(MockTime)

View File

@ -636,7 +636,7 @@ where
let fmt_ctx = {
#[cfg(feature = "ansi")]
{
FmtCtx::new(&ctx, event.parent(), self.ansi)
FmtCtx::new(ctx, event.parent(), self.ansi)
}
#[cfg(not(feature = "ansi"))]
{
@ -855,7 +855,7 @@ where
let span = self
.span
.and_then(|id| self.ctx.ctx.span(&id))
.and_then(|id| self.ctx.ctx.span(id))
.or_else(|| self.ctx.ctx.lookup_current());
let scope = span.into_iter().flat_map(|span| span.scope().from_root());
@ -925,7 +925,7 @@ where
let span = self
.span
.and_then(|id| self.ctx.ctx.span(&id))
.and_then(|id| self.ctx.ctx.span(id))
.or_else(|| self.ctx.ctx.lookup_current());
let scope = span.into_iter().flat_map(|span| span.scope().from_root());

View File

@ -181,7 +181,7 @@ where
};
let span = event
.parent()
.and_then(|id| ctx.span(&id))
.and_then(|id| ctx.span(id))
.or_else(|| ctx.lookup_current());
let scope = span.into_iter().flat_map(|span| span.scope());

View File

@ -1000,7 +1000,7 @@ where
/// [`Context::enabled`]: #method.enabled
#[inline]
pub fn event(&self, event: &Event<'_>) {
if let Some(ref subscriber) = self.subscriber {
if let Some(subscriber) = self.subscriber {
subscriber.event(event);
}
}
@ -1159,7 +1159,7 @@ where
let subscriber = self.subscriber.as_ref()?;
let current = subscriber.current_span();
let id = current.id()?;
let span = subscriber.span(&id);
let span = subscriber.span(id);
debug_assert!(
span.is_some(),
"the subscriber should have data for the current span ({:?})!",

View File

@ -103,7 +103,6 @@
use tracing_core::span::Id;
#[macro_use]
macro_rules! try_lock {
($lock:expr) => {
try_lock!($lock, else return)

View File

@ -124,7 +124,7 @@ pub trait LookupSpan<'a> {
where
Self: Sized,
{
let data = self.span_data(&id)?;
let data = self.span_data(id)?;
Some(SpanRef {
registry: self,
data,

View File

@ -151,7 +151,7 @@ impl Registry {
});
CloseGuard {
id,
registry: &self,
registry: self,
is_closing: false,
}
}
@ -234,7 +234,7 @@ impl Subscriber for Registry {
fn clone_span(&self, id: &span::Id) -> span::Id {
let span = self
.get(&id)
.get(id)
.unwrap_or_else(|| panic!(
"tried to clone {:?}, but no span exists with that ID\n\
This may be caused by consuming a parent span (`parent: span`) rather than borrowing it (`parent: &span`).",

View File

@ -39,18 +39,18 @@ mod parking_lot_impl {
}
#[inline]
pub(crate) fn read<'a>(&'a self) -> LockResult<RwLockReadGuard<'a, T>> {
pub(crate) fn read(&self) -> LockResult<RwLockReadGuard<'_, T>> {
Ok(self.inner.read())
}
#[inline]
#[allow(dead_code)] // may be used later;
pub(crate) fn try_read<'a>(&'a self) -> TryLockResult<RwLockReadGuard<'a, T>> {
pub(crate) fn try_read(&self) -> TryLockResult<RwLockReadGuard<'_, T>> {
self.inner.try_read().ok_or(TryLockError::WouldBlock)
}
#[inline]
pub(crate) fn write<'a>(&'a self) -> LockResult<RwLockWriteGuard<'a, T>> {
pub(crate) fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>> {
Ok(self.inner.write())
}
}

View File

@ -1040,7 +1040,7 @@ pub mod __macro_support {
#[inline(always)]
fn metadata(&self) -> &Metadata<'static> {
&self.meta
self.meta
}
}
}

View File

@ -907,7 +907,7 @@ impl Span {
}
if_log_enabled! { crate::Level::TRACE, {
if let Some(ref meta) = self.meta {
if let Some(meta) = self.meta {
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("-> {}", meta.name()));
}
}}
@ -924,7 +924,7 @@ impl Span {
}
if_log_enabled! { crate::Level::TRACE, {
if let Some(ref _meta) = self.meta {
if let Some(_meta) = self.meta {
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("<- {}", _meta.name()));
}
}}
@ -1065,7 +1065,7 @@ impl Span {
Q: field::AsField,
V: field::Value,
{
if let Some(ref meta) = self.meta {
if let Some(meta) = self.meta {
if let Some(field) = field.as_field(meta) {
self.record_all(
&meta
@ -1085,7 +1085,7 @@ impl Span {
inner.record(&record);
}
if let Some(ref _meta) = self.meta {
if let Some(_meta) = self.meta {
if_log_enabled! { *_meta.level(), {
let target = if record.is_empty() {
LIFECYCLE_LOG_TARGET
@ -1194,7 +1194,7 @@ impl Span {
#[cfg(feature = "log")]
#[inline]
fn log(&self, target: &str, level: log::Level, message: fmt::Arguments<'_>) {
if let Some(ref meta) = self.meta {
if let Some(meta) = self.meta {
if level_to_log!(*meta.level()) <= log::max_level() {
let logger = log::logger();
let log_meta = log::Metadata::builder().level(level).target(target).build();
@ -1257,7 +1257,7 @@ impl Hash for Span {
impl fmt::Debug for Span {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut span = f.debug_struct("Span");
if let Some(ref meta) = self.meta {
if let Some(meta) = self.meta {
span.field("name", &meta.name())
.field("level", &meta.level())
.field("target", &meta.target());
@ -1327,7 +1327,7 @@ impl Drop for Span {
subscriber.try_close(id.clone());
}
if let Some(ref _meta) = self.meta {
if let Some(_meta) = self.meta {
if_log_enabled! { crate::Level::TRACE, {
self.log(
LIFECYCLE_LOG_TARGET,
@ -1358,7 +1358,7 @@ impl Inner {
/// returns `Ok(())` if the other span was added as a precedent of this
/// span, or an error if this was not possible.
fn follows_from(&self, from: &Id) {
self.subscriber.record_follows_from(&self.id, &from)
self.subscriber.record_follows_from(&self.id, from)
}
/// Returns the span's ID.