Skip to content

Commit 74a3243

Browse files
committed
master: clean up warnings
1 parent 527b4f6 commit 74a3243

File tree

24 files changed

+72
-28
lines changed

24 files changed

+72
-28
lines changed

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ members = [
1818
"tracing-journald",
1919
"examples"
2020
]
21+
22+
# This will be ignored with Rust older than 1.74, but for now that's okay;
23+
# we're only using it to fix check-cfg issues that first appeared in Rust 1.80.
24+
[workspace.lints.rust]
25+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(flaky_tests)", "cfg(tracing_unstable)"] }

examples/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ tempfile = "3.3.0"
5050
# fmt examples
5151
snafu = "0.6.10"
5252
thiserror = "1.0.31"
53+
54+
[lints]
55+
workspace = true

tracing-attributes/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ rustversion = "1.0.9"
6060

6161
[badges]
6262
maintenance = { status = "experimental" }
63+
64+
[lints]
65+
workspace = true

tracing-attributes/tests/instrument.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ fn fields() {
100100

101101
#[test]
102102
fn skip() {
103-
#[allow(dead_code)]
104-
struct UnDebug(pub u32);
103+
struct UnDebug();
105104

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

137136
with_default(collector, || {
138-
my_fn(2, UnDebug(0), UnDebug(1));
139-
my_fn(3, UnDebug(0), UnDebug(1));
137+
my_fn(2, UnDebug(), UnDebug());
138+
my_fn(3, UnDebug(), UnDebug());
140139
});
141140

142141
handle.assert_finished();

tracing-core/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@ once_cell = { version = "1.13.0", optional = true }
3939

4040
[package.metadata.docs.rs]
4141
all-features = true
42-
rustdoc-args = ["--cfg", "docsrs"]
42+
# enable unstable features in the documentation
43+
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tracing_unstable"]
44+
# it's necessary to _also_ pass `--cfg tracing_unstable` to rustc, or else
45+
# dependencies will not be enabled, and the docs build will fail.
46+
rustc-args = ["--cfg", "tracing_unstable"]
47+
48+
[lints]
49+
workspace = true

tracing-core/src/field.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,8 @@ mod test {
999999
use crate::metadata::{Kind, Level, Metadata};
10001000

10011001
// Make sure TEST_CALLSITE_* have non-zero size, so they can't be located at the same address.
1002-
#[allow(dead_code)]
1003-
struct TestCallsite1(u8);
1004-
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1(0);
1002+
struct TestCallsite1();
1003+
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1();
10051004
static TEST_META_1: Metadata<'static> = metadata! {
10061005
name: "field_test1",
10071006
target: module_path!(),
@@ -1021,9 +1020,8 @@ mod test {
10211020
}
10221021
}
10231022

1024-
#[allow(dead_code)]
1025-
struct TestCallsite2(u8);
1026-
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2(0);
1023+
struct TestCallsite2();
1024+
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2();
10271025
static TEST_META_2: Metadata<'static> = metadata! {
10281026
name: "field_test2",
10291027
target: module_path!(),

tracing-futures/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ maintenance = { status = "actively-developed" }
5252
[package.metadata.docs.rs]
5353
all-features = true
5454
rustdoc-args = ["--cfg", "docsrs"]
55+
56+
[lints]
57+
workspace = true

tracing-futures/src/executor/futures_01.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ where
3535
}
3636

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

4141
#[cfg(feature = "tokio")]

tracing-futures/src/executor/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ mod futures_01;
33

44
#[cfg(feature = "futures-03")]
55
mod futures_03;
6+
#[allow(unreachable_pub, unused_imports)]
67
#[cfg(feature = "futures-03")]
7-
pub use self::futures_03::*;
8+
pub use futures_03::*;

tracing-futures/tests/std_future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn span_on_drop() {
5555
}
5656
}
5757

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

6161
impl Future for Fut {

tracing-journald/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ serde_json = "1.0.82"
2525
serde = { version = "1.0.139", features = ["derive"] }
2626
tracing = { path = "../tracing", version = "0.2" }
2727

28+
[lints]
29+
workspace = true

tracing-log/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ maintenance = { status = "actively-maintained" }
3737
[package.metadata.docs.rs]
3838
all-features = true
3939
rustdoc-args = ["--cfg", "docsrs"]
40+
41+
[lints]
42+
workspace = true

tracing-macros/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ tracing-subscriber = { path = "../tracing-subscriber", version = "0.3" }
2525

2626
[badges]
2727
maintenance = { status = "experimental" }
28+
29+
[lints]
30+
workspace = true

tracing-mock/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ tokio-stream = "0.1.9"
2828
[package.metadata.docs.rs]
2929
all-features = true
3030
rustdoc-args = ["--cfg", "docsrs"]
31+
32+
[lints]
33+
workspace = true

tracing-serde/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ serde_json = "1.0.82"
3131

3232
[badges]
3333
maintenance = { status = "experimental" }
34+
35+
[lints]
36+
workspace = true

tracing-subscriber/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ json = ["tracing-serde", "serde", "serde_json"]
3636
# Enables support for local time when using the `time` crate timestamp
3737
# formatters.
3838
local-time = ["time/local-offset"]
39+
nu-ansi-term = ["dep:nu-ansi-term"]
3940

4041
[dependencies]
4142
tracing-core = { path = "../tracing-core", version = "0.2", default-features = false }
@@ -103,6 +104,5 @@ harness = false
103104
name = "enter"
104105
harness = false
105106

106-
[[bench]]
107-
name = "reload"
108-
harness = false
107+
[lints]
108+
workspace = true

tracing-subscriber/src/fmt/format/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ impl<F, T> Format<F, T> {
679679
///
680680
/// - [`Format::flatten_event`] can be used to enable flattening event fields into the root
681681
/// object.
682-
///
683682
#[cfg(feature = "json")]
684683
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
685684
pub fn json(self) -> Format<Json, T> {

tracing-subscriber/src/fmt/time/chrono_crate.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,15 @@ impl FormatTime for ChronoUtc {
109109
///
110110
/// [`chrono::format::strftime`]: https://docs.rs/chrono/0.4.9/chrono/format/strftime/index.html
111111
#[derive(Debug, Clone, Eq, PartialEq)]
112+
#[derive(Default)]
112113
enum ChronoFmtType {
113114
/// Format according to the RFC 3339 convention.
115+
#[default]
114116
Rfc3339,
115117
/// Format according to a custom format string.
116118
Custom(String),
117119
}
118120

119-
impl Default for ChronoFmtType {
120-
fn default() -> Self {
121-
ChronoFmtType::Rfc3339
122-
}
123-
}
124121

125122
#[cfg(test)]
126123
mod tests {

tracing-subscriber/src/fmt/time/datetime.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@
192192
// permissive licensing, and of not having licensing issues being an
193193
// obstacle to adoption, that text has been removed.
194194

195-
196195
use std::fmt;
197196

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

333332
#[cfg(test)]
334333
mod tests {
334+
use i32;
335335
use std::time::{Duration, UNIX_EPOCH};
336336

337337
use super::*;
@@ -381,6 +381,8 @@ mod tests {
381381
1,
382382
);
383383

384+
case("2038-01-19T03:14:07.000000Z", i32::MAX as i64, 0);
385+
case("2038-01-19T03:14:08.000000Z", i32::MAX as i64 + 1, 0);
384386
case("2038-01-19T03:14:07.000000Z", i32::MAX as i64, 0);
385387
case("2038-01-19T03:14:08.000000Z", i32::MAX as i64 + 1, 0);
386388
case("1901-12-13T20:45:52.000000Z", i32::MIN as i64, 0);
@@ -391,6 +393,8 @@ mod tests {
391393
// high date value tests to panic
392394
#[cfg(not(target_os = "windows"))]
393395
{
396+
case("+292277026596-12-04T15:30:07.000000Z", i64::MAX, 0);
397+
case("+292277026596-12-04T15:30:06.000000Z", i64::MAX - 1, 0);
394398
case("+292277026596-12-04T15:30:07.000000Z", i64::MAX, 0);
395399
case("+292277026596-12-04T15:30:06.000000Z", i64::MAX - 1, 0);
396400
case("-292277022657-01-27T08:29:53.000000Z", i64::MIN + 1, 0);

tracing-subscriber/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ feature! {
214214
/// implementation which tracks per-span data and exposes it to
215215
/// [`Subscribe`]s.
216216
///
217-
/// For more information see [`Registry`].
217+
/// Returns a default [`Registry`].
218218
pub fn registry() -> Registry {
219219
Registry::default()
220220
}

tracing-subscriber/src/registry/sharded.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ impl Collect for Registry {
349349
let refs = span.ref_count.fetch_sub(1, Ordering::Release);
350350
if !std::thread::panicking() {
351351
assert!(refs < usize::MAX, "reference count overflow!");
352+
assert!(refs < usize::MAX, "reference count overflow!");
352353
}
353354
if refs > 1 {
354355
return false;
@@ -588,7 +589,7 @@ mod tests {
588589
closed: Vec<(&'static str, Weak<()>)>,
589590
}
590591

591-
#[allow(dead_code)]
592+
#[allow(dead_code)] // Field is exercised via checking `Arc::downgrade()`
592593
struct SetRemoved(Arc<()>);
593594

594595
impl<C> Subscribe<C> for CloseSubscriber

tracing-tower/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ maintenance = { status = "experimental" }
4040
[package.metadata.docs.rs]
4141
all-features = true
4242
rustdoc-args = ["--cfg", "docsrs"]
43+
44+
[lints]
45+
workspace = true

tracing/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ maintenance = { status = "actively-developed" }
108108

109109
[package.metadata.docs.rs]
110110
all-features = true
111-
rustdoc-args = ["--cfg", "docsrs"]
111+
# enable unstable features in the documentation
112+
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tracing_unstable"]
113+
# it's necessary to _also_ pass `--cfg tracing_unstable` to rustc, or else
114+
# dependencies will not be enabled, and the docs build will fail.
115+
rustc-args = ["--cfg", "tracing_unstable"]
116+
117+
[lints]
118+
workspace = true

tracing/tests/instrument.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn span_on_drop() {
2121
}
2222
}
2323

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

2727
impl Future for Fut {

0 commit comments

Comments
 (0)