Skip to content

Commit

Permalink
chore: fix clippy warnings for v0.1.x (#2552)
Browse files Browse the repository at this point in the history
## Motivation

Clippy check fails in recent CI runs in v0.1.x branch PRs, for example
this run:
https://github.com/tokio-rs/tracing/actions/runs/4641107803/jobs/8215263838


Relevant error logs:
```
error: lint `const_err` has been removed: converted into hard error, see issue #71800 <rust-lang/rust#71800> for more information
   --> tracing-core/src/lib.rs:132:5
    |
132 |     const_err,
    |     ^^^^^^^^^
    |
    = note: `-D renamed-and-removed-lints` implied by `-D warnings`


error: deref which would be done by auto-deref
   --> tracing-core/src/dispatcher.rs:371:26
    |
371 |                 return f(&*entered.current());
    |                          ^^^^^^^^^^^^^^^^^^^ help: try this: `&entered.current()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
    = note: `-D clippy::explicit-auto-deref` implied by `-D warnings`


error: deref which would be done by auto-deref
   --> tracing-core/src/dispatcher.rs:393:20
    |
393 |             Some(f(&*entered.current()))
    |                    ^^^^^^^^^^^^^^^^^^^ help: try this: `&entered.current()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
```

## Solution

Fix the warnings based on the suggestions for Clippy.
  • Loading branch information
keepsimple1 committed Apr 12, 2023
1 parent b28c935 commit d2f47f1
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion tracing-appender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
2 changes: 1 addition & 1 deletion tracing-attributes/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn gen_block<B: ToTokens>(
.into_iter()
.flat_map(|param| match param {
FnArg::Typed(PatType { pat, ty, .. }) => {
param_names(*pat, RecordType::parse_from_ty(&*ty))
param_names(*pat, RecordType::parse_from_ty(&ty))
}
FnArg::Receiver(_) => Box::new(iter::once((
Ident::new("self", param.span()),
Expand Down
1 change: 0 additions & 1 deletion tracing-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
2 changes: 1 addition & 1 deletion tracing-attributes/tests/ui/async_instrument.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ error[E0308]: mismatched types
42 | async fn extra_semicolon() -> i32 {
| ___________________________________^
43 | | 1;
| | - help: remove this semicolon
| | - help: remove this semicolon to return this value
44 | | }
| |_^ expected `i32`, found `()`
4 changes: 2 additions & 2 deletions tracing-core/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ where
CURRENT_STATE
.try_with(|state| {
if let Some(entered) = state.enter() {
return f(&*entered.current());
return f(&entered.current());
}

f(&Dispatch::none())
Expand All @@ -390,7 +390,7 @@ pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
CURRENT_STATE
.try_with(|state| {
let entered = state.enter()?;
Some(f(&*entered.current()))
Some(f(&entered.current()))
})
.ok()?
}
Expand Down
1 change: 0 additions & 1 deletion tracing-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing-flame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing-futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing-serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/filter/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl Targets {
/// assert_eq!(filter.default_level(), Some(LevelFilter::OFF));
/// ```
pub fn default_level(&self) -> Option<LevelFilter> {
self.0.directives().into_iter().find_map(|d| {
self.0.directives().find_map(|d| {
if d.target.is_none() {
Some(d.level)
} else {
Expand Down
1 change: 0 additions & 1 deletion tracing-subscriber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/registry/sharded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl<'a> SpanData<'a> for Data<'a> {
}

fn metadata(&self) -> &'static Metadata<'static> {
(*self).inner.metadata
self.inner.metadata
}

fn parent(&self) -> Option<&Id> {
Expand Down
1 change: 0 additions & 1 deletion tracing-tower/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down
1 change: 0 additions & 1 deletion tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
Expand Down

0 comments on commit d2f47f1

Please sign in to comment.