Skip to content

Commit 4b54cbc

Browse files
authored
chore: fix nightly clippy warnings (#991) (#1025)
This backports PR #991 to v0.1.x. This is primarily necessary for the MSRV bump, since some dependencies no longer compile on Rust 1.40.0. This has already been approved on `master`, in PR #991, so it should be fine to ship. ## Motivation This will avoid breaking CI on new releases of clippy. It also makes the code a little easier to read. ## Solution - Convert `match val { pat => true, _ => false }` to `matches!(val, pat)` - Remove unnecessary closures - Convert `self: &mut Self` to `&mut self` This bumps the MSRV to 1.42.0 for `matches!`. The latest version of rust is 1.46.0, so as per https://github.com/tokio-rs/tracing#supported-rust-versions this is not considered a breaking change. I didn't fix the following warning because the fix was not trivial/needed a decision: ``` warning: you are deriving `Ord` but have implemented `PartialOrd` explicitly --> tracing-subscriber/src/filter/env/field.rs:16:32 | 16 | #[derive(Debug, Eq, PartialEq, Ord)] | ^^^ | = note: `#[warn(clippy::derive_ord_xor_partial_ord)]` on by default note: `PartialOrd` implemented here --> tracing-subscriber/src/filter/env/field.rs:98:1 | 98 | / impl PartialOrd for Match { 99 | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { 100 | | // Ordering for `Match` directives is based first on _whether_ a value 101 | | // is matched or not. This is semantically meaningful --- we would ... | 121 | | } 122 | | } | |_^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord ``` As a side note, this found a bug in clippy 😆 rust-lang/rust-clippy#6089
1 parent a14ff8d commit 4b54cbc

File tree

34 files changed

+71
-123
lines changed

34 files changed

+71
-123
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
rust: [stable, 1.40.0]
15+
rust: [stable, 1.42.0]
1616
steps:
1717
- uses: actions/checkout@main
1818
- uses: actions-rs/toolchain@v1
@@ -145,7 +145,7 @@ jobs:
145145
runs-on: ubuntu-latest
146146
strategy:
147147
matrix:
148-
rust: [stable, beta, nightly, 1.40.0]
148+
rust: [stable, beta, nightly, 1.42.0]
149149
steps:
150150
- uses: actions/checkout@main
151151
- uses: actions-rs/toolchain@v1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ attachment that `Future::instrument` does.
256256
## Supported Rust Versions
257257

258258
Tracing is built against the latest stable release. The minimum supported
259-
version is 1.40. The current Tracing version is not guaranteed to build on Rust
259+
version is 1.42. The current Tracing version is not guaranteed to build on Rust
260260
versions earlier than the minimum supported version.
261261

262262
Tracing follows the same compiler support policies as the rest of the Tokio

tracing-appender/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ allows events and spans to be recorded in a non-blocking manner through a
3636
dedicated logging thread. It also provides a [`RollingFileAppender`][file_appender]
3737
that can be used with _or_ without the non-blocking writer.
3838

39-
*Compiler support: [requires `rustc` 1.40+][msrv]*
39+
*Compiler support: [requires `rustc` 1.42+][msrv]*
4040

4141
[msrv]: #supported-rust-versions
4242

@@ -146,7 +146,7 @@ fn main() {
146146
## Supported Rust Versions
147147

148148
Tracing is built against the latest stable release. The minimum supported
149-
version is 1.40. The current Tracing version is not guaranteed to build on Rust
149+
version is 1.42. The current Tracing version is not guaranteed to build on Rust
150150
versions earlier than the minimum supported version.
151151

152152
Tracing follows the same compiler support policies as the rest of the Tokio

tracing-appender/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! a dedicated logging thread. It also provides a [`RollingFileAppender`][file_appender] that can
88
//! be used with _or_ without the non-blocking writer.
99
//!
10-
//! *Compiler support: [requires `rustc` 1.40+][msrv]*
10+
//! *Compiler support: [requires `rustc` 1.42+][msrv]*
1111
//!
1212
//! [msrv]: #supported-rust-versions
1313
//! [file_appender]: ./rolling/struct.RollingFileAppender.html
@@ -111,7 +111,7 @@
111111
//! ## Supported Rust Versions
112112
//!
113113
//! Tracing is built against the latest stable release. The minimum supported
114-
//! version is 1.40. The current Tracing version is not guaranteed to build on
114+
//! version is 1.42. The current Tracing version is not guaranteed to build on
115115
//! Rust versions earlier than the minimum supported version.
116116
//!
117117
//! Tracing follows the same compiler support policies as the rest of the Tokio

tracing-attributes/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ structured, event-based diagnostic information. This crate provides the
3737

3838
Note that this macro is also re-exported by the main `tracing` crate.
3939

40-
*Compiler support: [requires `rustc` 1.40+][msrv]*
40+
*Compiler support: [requires `rustc` 1.42+][msrv]*
4141

4242
[msrv]: #supported-rust-versions
4343

@@ -69,7 +69,7 @@ pub fn my_function(my_arg: usize) {
6969
## Supported Rust Versions
7070

7171
Tracing is built against the latest stable release. The minimum supported
72-
version is 1.40. The current Tracing version is not guaranteed to build on Rust
72+
version is 1.42. The current Tracing version is not guaranteed to build on Rust
7373
versions earlier than the minimum supported version.
7474

7575
Tracing follows the same compiler support policies as the rest of the Tokio

tracing-attributes/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//!
77
//! Note that this macro is also re-exported by the main `tracing` crate.
88
//!
9-
//! *Compiler support: [requires `rustc` 1.40+][msrv]*
9+
//! *Compiler support: [requires `rustc` 1.42+][msrv]*
1010
//!
1111
//! [msrv]: #supported-rust-versions
1212
//!
@@ -41,7 +41,7 @@
4141
//! ## Supported Rust Versions
4242
//!
4343
//! Tracing is built against the latest stable release. The minimum supported
44-
//! version is 1.40. The current Tracing version is not guaranteed to build on
44+
//! version is 1.42. The current Tracing version is not guaranteed to build on
4545
//! Rust versions earlier than the minimum supported version.
4646
//!
4747
//! Tracing follows the same compiler support policies as the rest of the Tokio

tracing-attributes/tests/async_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() {
223223
async fn call_with_self(&self) {}
224224

225225
#[instrument(fields(Self=std::any::type_name::<Self>()))]
226-
async fn call_with_mut_self(self: &mut Self) {}
226+
async fn call_with_mut_self(&mut self) {}
227227
}
228228

229229
//let span = span::mock().named("call");

tracing-core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The crate provides:
5353
In addition, it defines the global callsite registry and per-thread current
5454
dispatcher which other components of the tracing system rely on.
5555

56-
*Compiler support: [requires `rustc` 1.40+][msrv]*
56+
*Compiler support: [requires `rustc` 1.42+][msrv]*
5757

5858
[msrv]: #supported-rust-versions
5959

@@ -99,7 +99,7 @@ The following crate feature flags are available:
9999
## Supported Rust Versions
100100

101101
Tracing is built against the latest stable release. The minimum supported
102-
version is 1.40. The current Tracing version is not guaranteed to build on Rust
102+
version is 1.42. The current Tracing version is not guaranteed to build on Rust
103103
versions earlier than the minimum supported version.
104104

105105
Tracing follows the same compiler support policies as the rest of the Tokio

tracing-core/src/event.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ impl<'a> Event<'a> {
101101

102102
/// Returns true if the new event should be a root.
103103
pub fn is_root(&self) -> bool {
104-
match self.parent {
105-
Parent::Root => true,
106-
_ => false,
107-
}
104+
matches!(self.parent, Parent::Root)
108105
}
109106

110107
/// Returns true if the new event's parent should be determined based on the
@@ -115,10 +112,7 @@ impl<'a> Event<'a> {
115112
/// thread is _not_ inside a span, then the new event will be the root of its
116113
/// own trace tree.
117114
pub fn is_contextual(&self) -> bool {
118-
match self.parent {
119-
Parent::Current => true,
120-
_ => false,
121-
}
115+
matches!(self.parent, Parent::Current)
122116
}
123117

124118
/// Returns the new event's explicitly-specified parent, if there is one.

tracing-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! In addition, it defines the global callsite registry and per-thread current
2424
//! dispatcher which other components of the tracing system rely on.
2525
//!
26-
//! *Compiler support: [requires `rustc` 1.40+][msrv]*
26+
//! *Compiler support: [requires `rustc` 1.42+][msrv]*
2727
//!
2828
//! [msrv]: #supported-rust-versions
2929
//!
@@ -61,7 +61,7 @@
6161
//! ## Supported Rust Versions
6262
//!
6363
//! Tracing is built against the latest stable release. The minimum supported
64-
//! version is 1.40. The current Tracing version is not guaranteed to build on
64+
//! version is 1.42. The current Tracing version is not guaranteed to build on
6565
//! Rust versions earlier than the minimum supported version.
6666
//!
6767
//! Tracing follows the same compiler support policies as the rest of the Tokio

0 commit comments

Comments
 (0)