diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e71d85239c..6b163dfba4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [stable, 1.40.0] + rust: [stable, 1.42.0] steps: - uses: actions/checkout@main - uses: actions-rs/toolchain@v1 @@ -145,7 +145,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [stable, beta, nightly, 1.40.0] + rust: [stable, beta, nightly, 1.42.0] steps: - uses: actions/checkout@main - uses: actions-rs/toolchain@v1 diff --git a/tracing-attributes/tests/async_fn.rs b/tracing-attributes/tests/async_fn.rs index ac95e94d2e..f7e5f3b743 100644 --- a/tracing-attributes/tests/async_fn.rs +++ b/tracing-attributes/tests/async_fn.rs @@ -223,7 +223,7 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() { async fn call_with_self(&self) {} #[instrument(fields(Self=std::any::type_name::()))] - async fn call_with_mut_self(self: &mut Self) {} + async fn call_with_mut_self(&mut self) {} } //let span = span::mock().named("call"); diff --git a/tracing-core/src/event.rs b/tracing-core/src/event.rs index 1c4b7a7936..8c17c3b70f 100644 --- a/tracing-core/src/event.rs +++ b/tracing-core/src/event.rs @@ -103,10 +103,7 @@ impl<'a> Event<'a> { /// Returns true if the new event should be a root. pub fn is_root(&self) -> bool { - match self.parent { - Parent::Root => true, - _ => false, - } + matches!(self.parent, Parent::Root) } /// Returns true if the new event's parent should be determined based on the @@ -117,10 +114,7 @@ impl<'a> Event<'a> { /// thread is _not_ inside a span, then the new event will be the root of its /// own trace tree. pub fn is_contextual(&self) -> bool { - match self.parent { - Parent::Current => true, - _ => false, - } + matches!(self.parent, Parent::Current) } /// Returns the new event's explicitly-specified parent, if there is one. diff --git a/tracing-core/src/metadata.rs b/tracing-core/src/metadata.rs index c575a55b45..02d3d3469b 100644 --- a/tracing-core/src/metadata.rs +++ b/tracing-core/src/metadata.rs @@ -251,18 +251,12 @@ impl Kind { /// Return true if the callsite kind is `Span` pub fn is_span(&self) -> bool { - match self { - Kind(KindInner::Span) => true, - _ => false, - } + matches!(self, Kind(KindInner::Span)) } /// Return true if the callsite kind is `Event` pub fn is_event(&self) -> bool { - match self { - Kind(KindInner::Event) => true, - _ => false, - } + matches!(self, Kind(KindInner::Event)) } } @@ -553,8 +547,7 @@ impl FromStr for LevelFilter { s if s.eq_ignore_ascii_case("trace") => Some(LevelFilter::TRACE), s if s.eq_ignore_ascii_case("off") => Some(LevelFilter::OFF), _ => None, - }) - .ok_or_else(|| ParseLevelFilterError(())) + }).ok_or(ParseLevelFilterError(())) } } diff --git a/tracing-core/src/span.rs b/tracing-core/src/span.rs index 6dfc41dca6..27dda2475c 100644 --- a/tracing-core/src/span.rs +++ b/tracing-core/src/span.rs @@ -153,10 +153,7 @@ impl<'a> Attributes<'a> { /// Returns true if the new span should be a root. pub fn is_root(&self) -> bool { - match self.parent { - Parent::Root => true, - _ => false, - } + matches!(self.parent, Parent::Root) } /// Returns true if the new span's parent should be determined based on the @@ -167,10 +164,7 @@ impl<'a> Attributes<'a> { /// thread is _not_ inside a span, then the new span will be the root of its /// own trace tree. pub fn is_contextual(&self) -> bool { - match self.parent { - Parent::Current => true, - _ => false, - } + matches!(self.parent, Parent::Current) } /// Returns the new span's explicitly-specified parent, if there is one. @@ -270,10 +264,7 @@ impl Current { /// [`metadata`]: #method.metadata /// [`into_inner`]: #method.into_inner pub fn is_known(&self) -> bool { - match self.inner { - CurrentInner::Unknown => false, - _ => true, - } + !matches!(self.inner, CurrentInner::Unknown) } /// Consumes `self` and returns the span `Id` and `Metadata` of the current diff --git a/tracing-core/src/subscriber.rs b/tracing-core/src/subscriber.rs index 2b56f8d483..cc62ee8584 100644 --- a/tracing-core/src/subscriber.rs +++ b/tracing-core/src/subscriber.rs @@ -528,30 +528,21 @@ impl Interest { /// about this callsite. #[inline] pub fn is_never(&self) -> bool { - match self.0 { - InterestKind::Never => true, - _ => false, - } + matches!(self.0, InterestKind::Never) } /// Returns `true` if the subscriber is sometimes interested in being notified /// about this callsite. #[inline] pub fn is_sometimes(&self) -> bool { - match self.0 { - InterestKind::Sometimes => true, - _ => false, - } + matches!(self.0, InterestKind::Sometimes) } /// Returns `true` if the subscriber is always interested in being notified /// about this callsite. #[inline] pub fn is_always(&self) -> bool { - match self.0 { - InterestKind::Always => true, - _ => false, - } + matches!(self.0, InterestKind::Always) } /// Returns the common interest between these two Interests. diff --git a/tracing-subscriber/src/fmt/format/mod.rs b/tracing-subscriber/src/fmt/format/mod.rs index ed825af12a..5f57711cb5 100644 --- a/tracing-subscriber/src/fmt/format/mod.rs +++ b/tracing-subscriber/src/fmt/format/mod.rs @@ -1052,22 +1052,13 @@ impl FmtSpanConfig { } } pub(super) fn trace_new(&self) -> bool { - match self.kind { - FmtSpan::FULL => true, - _ => false, - } + matches!(self.kind, FmtSpan::FULL) } pub(super) fn trace_active(&self) -> bool { - match self.kind { - FmtSpan::ACTIVE | FmtSpan::FULL => true, - _ => false, - } + matches!(self.kind, FmtSpan::ACTIVE | FmtSpan::FULL) } pub(super) fn trace_close(&self) -> bool { - match self.kind { - FmtSpan::CLOSE | FmtSpan::FULL => true, - _ => false, - } + matches!(self.kind, FmtSpan::CLOSE | FmtSpan::FULL) } } diff --git a/tracing-subscriber/src/reload.rs b/tracing-subscriber/src/reload.rs index 961f60acb3..14a069dae0 100644 --- a/tracing-subscriber/src/reload.rs +++ b/tracing-subscriber/src/reload.rs @@ -210,19 +210,13 @@ impl Error { /// Returns `true` if this error occurred because the layer was poisoned by /// a panic on another thread. pub fn is_poisoned(&self) -> bool { - match self.kind { - ErrorKind::Poisoned => true, - _ => false, - } + matches!(self.kind, ErrorKind::Poisoned) } /// Returns `true` if this error occurred because the `Subscriber` /// containing the reloadable layer was dropped. pub fn is_dropped(&self) -> bool { - match self.kind { - ErrorKind::SubscriberGone => true, - _ => false, - } + matches!(self.kind, ErrorKind::SubscriberGone) } } diff --git a/tracing/tests/support/subscriber.rs b/tracing/tests/support/subscriber.rs index 3f90e8daf9..172e99db21 100644 --- a/tracing/tests/support/subscriber.rs +++ b/tracing/tests/support/subscriber.rs @@ -213,11 +213,7 @@ where "[{}] record: {}; id={:?}; values={:?};", self.name, span.name, id, values ); - let was_expected = if let Some(Expect::Visit(_, _)) = expected.front() { - true - } else { - false - }; + let was_expected = matches!(expected.front(), Some(Expect::Visit(_, _))); if was_expected { if let Expect::Visit(expected_span, mut expected_values) = expected.pop_front().unwrap() { @@ -319,10 +315,7 @@ where id ); let mut expected = self.expected.lock().unwrap(); - let was_expected = match expected.front() { - Some(Expect::NewSpan(_)) => true, - _ => false, - }; + let was_expected = matches!(expected.front(), Some(Expect::NewSpan(_))); let mut spans = self.spans.lock().unwrap(); if was_expected { if let Expect::NewSpan(mut expected) = expected.pop_front().unwrap() {