Skip to content

Commit

Permalink
chore: clean up warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Aug 29, 2024
1 parent 50ef3f6 commit 571ce97
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 303 deletions.
2 changes: 1 addition & 1 deletion examples/examples/sloggish/sloggish_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct CurrentSpanPerThread {
impl CurrentSpanPerThread {
pub fn new() -> Self {
thread_local! {
static CURRENT: RefCell<Vec<Id>> = RefCell::new(vec![]);
static CURRENT: RefCell<Vec<Id>> = const { RefCell::new(vec![]) };
};
Self { current: &CURRENT }
}
Expand Down
2 changes: 1 addition & 1 deletion tracing-appender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! - Using a [`RollingFileAppender`][rolling_struct] to perform writes to a log file. This will block on writes.
//! - Using *any* type implementing [`std::io::Write`][write] in a non-blocking fashion.
//! - Using a combination of [`NonBlocking`][non_blocking] and [`RollingFileAppender`][rolling_struct] to allow writes to a log file
//! without blocking.
//! without blocking.
//!
//! ## File Appender
//!
Expand Down
6 changes: 3 additions & 3 deletions tracing-appender/src/rolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
//! The following helpers are available for creating a rolling file appender.
//!
//! - [`Rotation::minutely()`][minutely]: A new log file in the format of `some_directory/log_file_name_prefix.yyyy-MM-dd-HH-mm`
//! will be created minutely (once per minute)
//! will be created minutely (once per minute)
//! - [`Rotation::hourly()`][hourly]: A new log file in the format of `some_directory/log_file_name_prefix.yyyy-MM-dd-HH`
//! will be created hourly
//! will be created hourly
//! - [`Rotation::daily()`][daily]: A new log file in the format of `some_directory/log_file_name_prefix.yyyy-MM-dd`
//! will be created daily
//! will be created daily
//! - [`Rotation::never()`][never()]: This will result in log file located at `some_directory/log_file_name`
//!
//!
Expand Down
8 changes: 4 additions & 4 deletions tracing-attributes/tests/instrument.rs
Original file line number Diff line number Diff line change
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 @@ -147,9 +147,9 @@ fn skip() {
.run_with_handle();

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

handle.assert_finished();
Expand Down
6 changes: 0 additions & 6 deletions tracing-core/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ use crate::stdlib::{
error,
};

#[cfg(feature = "alloc")]
use alloc::sync::{Arc, Weak};

#[cfg(feature = "alloc")]
use core::ops::Deref;

/// `Dispatch` trace data to a [`Subscriber`].
#[derive(Clone)]
pub struct Dispatch {
Expand Down
13 changes: 5 additions & 8 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,7 @@ impl FieldSet {
/// Returns the [`Field`] named `name`, or `None` if no such field exists.
///
/// [`Field`]: super::Field
pub fn field<Q: ?Sized>(&self, name: &Q) -> Option<Field>
where
Q: Borrow<str>,
{
pub fn field<Q: Borrow<str> + ?Sized>(&self, name: &Q) -> Option<Field> {
let name = &name.borrow();
self.names.iter().position(|f| f == name).map(|i| Field {
i,
Expand Down Expand Up @@ -1090,8 +1087,8 @@ mod test {
use crate::stdlib::{borrow::ToOwned, string::String};

// 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 @@ -1111,8 +1108,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
6 changes: 3 additions & 3 deletions tracing-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
//!
//! - `traced-error` - Enables the [`TracedError`] type and related Traits
//! - [`InstrumentResult`] and [`InstrumentError`] extension traits, which
//! provide an [`in_current_span()`] method for bundling errors with a
//! [`SpanTrace`].
//! provide an [`in_current_span()`] method for bundling errors with a
//! [`SpanTrace`].
//! - [`ExtractSpanTrace`] extension trait, for extracting `SpanTrace`s from
//! behind `dyn Error` trait objects.
//! behind `dyn Error` trait objects.
//!
//! ## Usage
//!
Expand Down
2 changes: 1 addition & 1 deletion tracing-futures/src/executor/futures_01.rs
Original file line number Diff line number Diff line change
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
121 changes: 0 additions & 121 deletions tracing-futures/src/executor/futures_preview.rs

This file was deleted.

8 changes: 2 additions & 6 deletions tracing-futures/src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[cfg(feature = "futures-01")]
mod futures_01;

#[cfg(feature = "futures_preview")]
mod futures_preview;
#[cfg(feature = "futures_preview")]
pub use self::futures_preview::*;

#[cfg(feature = "futures-03")]
mod futures_03;
#[allow(unreachable_pub, unused_imports)]
#[cfg(feature = "futures-03")]
pub use self::futures_03::*;
pub use futures_03::*;
1 change: 1 addition & 0 deletions tracing-futures/tests/std_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn span_on_drop() {
}
}

#[allow(dead_code)] // Field unused, but logs on `Drop`
struct Fut(Option<AssertSpanOnDrop>);

impl Future for Fut {
Expand Down
2 changes: 1 addition & 1 deletion tracing-log/src/interest_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mod tests {

fn lock_for_test() -> impl Drop {
// We need to make sure only one test runs at a time.
static LOCK: Lazy<Mutex<()>> = Lazy::new(Mutex::new);
static LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

match LOCK.lock() {
Ok(guard) => guard,
Expand Down
12 changes: 0 additions & 12 deletions tracing-serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,6 @@ use tracing_core::{

pub mod fields;

#[derive(Debug)]
pub struct SerializeField(Field);

impl Serialize for SerializeField {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.0.name())
}
}

#[derive(Debug)]
pub struct SerializeFieldSet<'a>(&'a FieldSet);

Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ valuable = ["tracing-core/valuable", "valuable_crate", "valuable-serde", "tracin
# Enables support for local time when using the `time` crate timestamp
# formatters.
local-time = ["time/local-offset"]
nu-ansi-term = ["dep:nu-ansi-term"]

[dependencies]
tracing-core = { path = "../tracing-core", version = "0.1.30", default-features = false }
Expand Down
14 changes: 7 additions & 7 deletions tracing-subscriber/src/filter/env/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ impl Builder {
}

if !disabled.is_empty() {
#[cfg(feature = "nu_ansi_term")]
#[cfg(feature = "nu-ansi-term")]
use nu_ansi_term::{Color, Style};
// NOTE: We can't use a configured `MakeWriter` because the EnvFilter
// has no knowledge of any underlying subscriber or subscriber, which
// may or may not use a `MakeWriter`.
let warn = |msg: &str| {
#[cfg(not(feature = "nu_ansi_term"))]
#[cfg(not(feature = "nu-ansi-term"))]
let msg = format!("warning: {}", msg);
#[cfg(feature = "nu_ansi_term")]
#[cfg(feature = "nu-ansi-term")]
let msg = {
let bold = Style::new().bold();
let mut warning = Color::Yellow.paint("warning");
Expand All @@ -228,9 +228,9 @@ impl Builder {
eprintln!("{}", msg);
};
let ctx_prefixed = |prefix: &str, msg: &str| {
#[cfg(not(feature = "nu_ansi_term"))]
#[cfg(not(feature = "nu-ansi-term"))]
let msg = format!("{} {}", prefix, msg);
#[cfg(feature = "nu_ansi_term")]
#[cfg(feature = "nu-ansi-term")]
let msg = {
let mut equal = Color::Fixed(21).paint("="); // dark blue
equal.style_ref_mut().is_bold = true;
Expand All @@ -241,9 +241,9 @@ impl Builder {
let ctx_help = |msg| ctx_prefixed("help:", msg);
let ctx_note = |msg| ctx_prefixed("note:", msg);
let ctx = |msg: &str| {
#[cfg(not(feature = "nu_ansi_term"))]
#[cfg(not(feature = "nu-ansi-term"))]
let msg = format!("note: {}", msg);
#[cfg(feature = "nu_ansi_term")]
#[cfg(feature = "nu-ansi-term")]
let msg = {
let mut pipe = Color::Fixed(21).paint("|");
pipe.style_ref_mut().is_bold = true;
Expand Down
4 changes: 2 additions & 2 deletions tracing-subscriber/src/filter/env/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl fmt::Display for ValueMatch {
match self {
ValueMatch::Bool(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::F64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::NaN => fmt::Display::fmt(&std::f64::NAN, f),
ValueMatch::NaN => fmt::Display::fmt(&f64::NAN, f),
ValueMatch::I64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::U64(ref inner) => fmt::Display::fmt(inner, f),
ValueMatch::Debug(ref inner) => fmt::Display::fmt(inner, f),
Expand Down Expand Up @@ -507,7 +507,7 @@ impl<'a> Visit for MatchVisitor<'a> {
matched.store(true, Release);
}
Some((ValueMatch::F64(ref e), ref matched))
if (value - *e).abs() < std::f64::EPSILON =>
if (value - *e).abs() < f64::EPSILON =>
{
matched.store(true, Release);
}
Expand Down
6 changes: 3 additions & 3 deletions tracing-subscriber/src/filter/layer_filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ where

impl FilterId {
const fn disabled() -> Self {
Self(std::u64::MAX)
Self(u64::MAX)
}

/// Returns a `FilterId` that will consider _all_ spans enabled.
Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl<F, S> FilterExt<S> for F where F: layer::Filter<S> {}

impl FilterMap {
pub(crate) fn set(self, FilterId(mask): FilterId, enabled: bool) -> Self {
if mask == std::u64::MAX {
if mask == u64::MAX {
return self;
}

Expand All @@ -1051,7 +1051,7 @@ impl FilterMap {

#[inline]
pub(crate) fn any_enabled(self) -> bool {
self.bits != std::u64::MAX
self.bits != u64::MAX
}
}

Expand Down
Loading

0 comments on commit 571ce97

Please sign in to comment.