Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: apply some clippy suggestions #2931

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 3 additions & 17 deletions tracing-attributes/src/expand.rs
Expand Up @@ -4,9 +4,9 @@ use proc_macro2::TokenStream;
use quote::{quote, quote_spanned, ToTokens};
use syn::visit_mut::VisitMut;
use syn::{
punctuated::Punctuated, spanned::Spanned, Block, Expr, ExprAsync, ExprCall, FieldPat, FnArg,
Ident, Item, ItemFn, Pat, PatIdent, PatReference, PatStruct, PatTuple, PatTupleStruct, PatType,
Path, ReturnType, Signature, Stmt, Token, Type, TypePath,
punctuated::Punctuated, spanned::Spanned, Expr, ExprAsync, ExprCall, FieldPat, FnArg, Ident,
Item, ItemFn, Pat, PatIdent, PatReference, PatStruct, PatTuple, PatTupleStruct, PatType, Path,
ReturnType, Signature, Stmt, Token, Type, TypePath,
};

use crate::{
Expand Down Expand Up @@ -794,20 +794,6 @@ impl<'a> VisitMut for IdentAndTypesRenamer<'a> {
}
}

// A visitor struct that replace an async block by its patched version
struct AsyncTraitBlockReplacer<'a> {
block: &'a Block,
patched_block: Block,
}

impl<'a> VisitMut for AsyncTraitBlockReplacer<'a> {
fn visit_block_mut(&mut self, i: &mut Block) {
if i == self.block {
*i = self.patched_block.clone();
}
}
}

// Replaces any `impl Trait` with `_` so it can be used as the type in
// a `let` statement's LHS.
struct ImplTraitEraser;
Expand Down
6 changes: 3 additions & 3 deletions tracing-attributes/tests/instrument.rs
Expand Up @@ -100,7 +100,7 @@ fn fields() {

#[test]
fn skip() {
struct UnDebug(pub u32);
struct UnDebug;

#[instrument(target = "my_target", level = "debug", skip(_arg2, _arg3))]
fn my_fn(arg1: usize, _arg2: UnDebug, _arg3: UnDebug) {}
Expand Down Expand Up @@ -134,8 +134,8 @@ fn skip() {
.run_with_handle();

with_default(collector, || {
my_fn(2, UnDebug(0), UnDebug(1));
my_fn(3, UnDebug(0), UnDebug(1));
my_fn(2, UnDebug, UnDebug);
my_fn(3, UnDebug, UnDebug);
});

handle.assert_finished();
Expand Down
1 change: 0 additions & 1 deletion tracing-core/src/callsite.rs
Expand Up @@ -169,7 +169,6 @@ mod inner {
use super::*;
use once_cell::sync::Lazy;
use std::sync::RwLock;
use std::vec::Vec;

type Dispatchers = Vec<dispatch::Registrar>;

Expand Down
1 change: 1 addition & 0 deletions tracing-core/src/dispatch.rs
Expand Up @@ -510,6 +510,7 @@ pub(crate) fn get_global() -> &'static Dispatch {
unsafe {
// This is safe given the invariant that setting the global dispatcher
// also sets `GLOBAL_INIT` to `INITIALIZED`.
#[allow(static_mut_refs)]
&GLOBAL_DISPATCH
}
}
Expand Down
8 changes: 4 additions & 4 deletions tracing-core/src/field.rs
Expand Up @@ -966,8 +966,8 @@ mod test {
use crate::metadata::{Kind, Level, Metadata};

// Make sure TEST_CALLSITE_* have non-zero size, so they can't be located at the same address.
struct TestCallsite1(u8);
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1(0);
struct TestCallsite1;
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1;
static TEST_META_1: Metadata<'static> = metadata! {
name: "field_test1",
target: module_path!(),
Expand All @@ -987,8 +987,8 @@ mod test {
}
}

struct TestCallsite2(u8);
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2(0);
struct TestCallsite2;
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2;
static TEST_META_2: Metadata<'static> = metadata! {
name: "field_test2",
target: module_path!(),
Expand Down
2 changes: 1 addition & 1 deletion tracing-futures/src/executor/futures_01.rs
Expand Up @@ -35,7 +35,7 @@ where
}

#[cfg(feature = "tokio")]
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
#[allow(unreachable_pub,unused_imports)] // https://github.com/rust-lang/rust/issues/57411
pub use self::tokio::*;

#[cfg(feature = "tokio")]
Expand Down
1 change: 1 addition & 0 deletions tracing-futures/src/executor/mod.rs
Expand Up @@ -9,4 +9,5 @@ pub use self::futures_preview::*;
#[cfg(feature = "futures-03")]
mod futures_03;
#[cfg(feature = "futures-03")]
#[allow(unreachable_pub,unused_imports)]
pub use self::futures_03::*;
1 change: 1 addition & 0 deletions tracing-futures/tests/std_future.rs
Expand Up @@ -55,6 +55,7 @@ fn span_on_drop() {
}
}

#[allow(dead_code)] // We use it to test drop behavior.
struct Fut(Option<AssertSpanOnDrop>);

impl Future for Fut {
Expand Down
9 changes: 2 additions & 7 deletions tracing-subscriber/src/fmt/time/chrono_crate.rs
Expand Up @@ -108,20 +108,15 @@ impl FormatTime for ChronoUtc {
/// the supported syntax.
///
/// [`chrono::format::strftime`]: https://docs.rs/chrono/0.4.9/chrono/format/strftime/index.html
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, Default)]
enum ChronoFmtType {
#[default]
/// Format according to the RFC 3339 convention.
Rfc3339,
/// Format according to a custom format string.
Custom(String),
}

impl Default for ChronoFmtType {
fn default() -> Self {
ChronoFmtType::Rfc3339
}
}

#[cfg(test)]
mod tests {
use crate::fmt::format::Writer;
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/src/registry/sharded.rs
Expand Up @@ -592,6 +592,7 @@ mod tests {
closed: Vec<(&'static str, Weak<()>)>,
}

#[allow(dead_code)] // Used in test.
struct SetRemoved(Arc<()>);

impl<C> Subscribe<C> for CloseSubscriber
Expand Down
1 change: 0 additions & 1 deletion tracing/src/instrument.rs
@@ -1,7 +1,6 @@
use crate::span::Span;
use core::{
future::Future,
marker::Sized,
mem::ManuallyDrop,
pin::Pin,
task::{Context, Poll},
Expand Down
1 change: 1 addition & 0 deletions tracing/tests/instrument.rs
Expand Up @@ -21,6 +21,7 @@ fn span_on_drop() {
}
}

#[allow(dead_code)] // We use it to test drop behavior.
struct Fut(Option<AssertSpanOnDrop>);

impl Future for Fut {
Expand Down