Skip to content

Commit

Permalink
master: clean up warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbarsky committed Sep 24, 2024
1 parent 527b4f6 commit 74a3243
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 28 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ members = [
"tracing-journald",
"examples"
]

# This will be ignored with Rust older than 1.74, but for now that's okay;
# we're only using it to fix check-cfg issues that first appeared in Rust 1.80.
[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(flaky_tests)", "cfg(tracing_unstable)"] }
3 changes: 3 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ tempfile = "3.3.0"
# fmt examples
snafu = "0.6.10"
thiserror = "1.0.31"

[lints]
workspace = true
3 changes: 3 additions & 0 deletions tracing-attributes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ rustversion = "1.0.9"

[badges]
maintenance = { status = "experimental" }

[lints]
workspace = true
7 changes: 3 additions & 4 deletions tracing-attributes/tests/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ fn fields() {

#[test]
fn skip() {
#[allow(dead_code)]
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 @@ -135,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
9 changes: 8 additions & 1 deletion tracing-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ once_cell = { version = "1.13.0", optional = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
# enable unstable features in the documentation
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tracing_unstable"]
# it's necessary to _also_ pass `--cfg tracing_unstable` to rustc, or else
# dependencies will not be enabled, and the docs build will fail.
rustc-args = ["--cfg", "tracing_unstable"]

[lints]
workspace = true
10 changes: 4 additions & 6 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,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.
#[allow(dead_code)]
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 @@ -1021,9 +1020,8 @@ mod test {
}
}

#[allow(dead_code)]
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
3 changes: 3 additions & 0 deletions tracing-futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ maintenance = { status = "actively-developed" }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true
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
3 changes: 2 additions & 1 deletion tracing-futures/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ mod futures_01;

#[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::*;
2 changes: 1 addition & 1 deletion tracing-futures/tests/std_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn span_on_drop() {
}
}

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

impl Future for Fut {
Expand Down
2 changes: 2 additions & 0 deletions tracing-journald/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ serde_json = "1.0.82"
serde = { version = "1.0.139", features = ["derive"] }
tracing = { path = "../tracing", version = "0.2" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions tracing-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ maintenance = { status = "actively-maintained" }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions tracing-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ tracing-subscriber = { path = "../tracing-subscriber", version = "0.3" }

[badges]
maintenance = { status = "experimental" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions tracing-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ tokio-stream = "0.1.9"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions tracing-serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ serde_json = "1.0.82"

[badges]
maintenance = { status = "experimental" }

[lints]
workspace = true
6 changes: 3 additions & 3 deletions tracing-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ json = ["tracing-serde", "serde", "serde_json"]
# 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.2", default-features = false }
Expand Down Expand Up @@ -103,6 +104,5 @@ harness = false
name = "enter"
harness = false

[[bench]]
name = "reload"
harness = false
[lints]
workspace = true
1 change: 0 additions & 1 deletion tracing-subscriber/src/fmt/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ impl<F, T> Format<F, T> {
///
/// - [`Format::flatten_event`] can be used to enable flattening event fields into the root
/// object.
///
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(self) -> Format<Json, T> {
Expand Down
7 changes: 2 additions & 5 deletions tracing-subscriber/src/fmt/time/chrono_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,15 @@ impl FormatTime for ChronoUtc {
///
/// [`chrono::format::strftime`]: https://docs.rs/chrono/0.4.9/chrono/format/strftime/index.html
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Default)]
enum ChronoFmtType {
/// Format according to the RFC 3339 convention.
#[default]
Rfc3339,
/// Format according to a custom format string.
Custom(String),
}

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

#[cfg(test)]
mod tests {
Expand Down
6 changes: 5 additions & 1 deletion tracing-subscriber/src/fmt/time/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
// permissive licensing, and of not having licensing issues being an
// obstacle to adoption, that text has been removed.


use std::fmt;

/// A date/time type which exists primarily to convert `SystemTime` timestamps into an ISO 8601
Expand Down Expand Up @@ -332,6 +331,7 @@ impl From<std::time::SystemTime> for DateTime {

#[cfg(test)]
mod tests {
use i32;
use std::time::{Duration, UNIX_EPOCH};

use super::*;
Expand Down Expand Up @@ -381,6 +381,8 @@ mod tests {
1,
);

case("2038-01-19T03:14:07.000000Z", i32::MAX as i64, 0);
case("2038-01-19T03:14:08.000000Z", i32::MAX as i64 + 1, 0);
case("2038-01-19T03:14:07.000000Z", i32::MAX as i64, 0);
case("2038-01-19T03:14:08.000000Z", i32::MAX as i64 + 1, 0);
case("1901-12-13T20:45:52.000000Z", i32::MIN as i64, 0);
Expand All @@ -391,6 +393,8 @@ mod tests {
// high date value tests to panic
#[cfg(not(target_os = "windows"))]
{
case("+292277026596-12-04T15:30:07.000000Z", i64::MAX, 0);
case("+292277026596-12-04T15:30:06.000000Z", i64::MAX - 1, 0);
case("+292277026596-12-04T15:30:07.000000Z", i64::MAX, 0);
case("+292277026596-12-04T15:30:06.000000Z", i64::MAX - 1, 0);
case("-292277022657-01-27T08:29:53.000000Z", i64::MIN + 1, 0);
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ feature! {
/// implementation which tracks per-span data and exposes it to
/// [`Subscribe`]s.
///
/// For more information see [`Registry`].
/// Returns a default [`Registry`].
pub fn registry() -> Registry {
Registry::default()
}
Expand Down
3 changes: 2 additions & 1 deletion tracing-subscriber/src/registry/sharded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl Collect for Registry {
let refs = span.ref_count.fetch_sub(1, Ordering::Release);
if !std::thread::panicking() {
assert!(refs < usize::MAX, "reference count overflow!");
assert!(refs < usize::MAX, "reference count overflow!");
}
if refs > 1 {
return false;
Expand Down Expand Up @@ -588,7 +589,7 @@ mod tests {
closed: Vec<(&'static str, Weak<()>)>,
}

#[allow(dead_code)]
#[allow(dead_code)] // Field is exercised via checking `Arc::downgrade()`
struct SetRemoved(Arc<()>);

impl<C> Subscribe<C> for CloseSubscriber
Expand Down
3 changes: 3 additions & 0 deletions tracing-tower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ maintenance = { status = "experimental" }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true
9 changes: 8 additions & 1 deletion tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,11 @@ maintenance = { status = "actively-developed" }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
# enable unstable features in the documentation
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tracing_unstable"]
# it's necessary to _also_ pass `--cfg tracing_unstable` to rustc, or else
# dependencies will not be enabled, and the docs build will fail.
rustc-args = ["--cfg", "tracing_unstable"]

[lints]
workspace = true
2 changes: 1 addition & 1 deletion tracing/tests/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn span_on_drop() {
}
}

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

impl Future for Fut {
Expand Down

0 comments on commit 74a3243

Please sign in to comment.