Skip to content

Commit 7f09959

Browse files
authored
chore: use [lints] to address unexpected_cfgs lint (#7124)
1 parent fb7dec0 commit 7f09959

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+46
-55
lines changed

.cirrus.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ freebsd_instance:
44
image_family: freebsd-14-1
55
env:
66
RUST_STABLE: stable
7-
RUST_NIGHTLY: nightly-2024-05-05
7+
RUST_NIGHTLY: nightly-2025-01-25
88
RUSTFLAGS: -D warnings
99

1010
# Test FreeBSD in a full VM on cirrus-ci.com. Test the i686 target too, in the

.github/workflows/ci.yml

+2-19
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ env:
1616
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
1717
# Change to specific Rust release to pin
1818
rust_stable: stable
19-
rust_nightly: nightly-2024-05-05
19+
rust_nightly: nightly-2025-01-25
2020
# Pin a specific miri version
21-
rust_miri_nightly: nightly-2024-10-21
21+
rust_miri_nightly: nightly-2025-01-25
2222
rust_clippy: '1.77'
2323
# When updating this, also update:
2424
# - README.md
@@ -1086,23 +1086,6 @@ jobs:
10861086
run: cargo check-external-types --all-features
10871087
working-directory: tokio
10881088

1089-
check-unexpected-lints-cfgs:
1090-
name: check unexpected lints and cfgs
1091-
needs: basics
1092-
runs-on: ubuntu-latest
1093-
steps:
1094-
- uses: actions/checkout@v4
1095-
- name: Install Rust ${{ env.rust_nightly }}
1096-
uses: dtolnay/rust-toolchain@master
1097-
with:
1098-
toolchain: ${{ env.rust_nightly }}
1099-
- name: don't allow warnings
1100-
run: sed -i '/#!\[allow(unknown_lints, unexpected_cfgs)\]/d' */src/lib.rs */tests/*.rs
1101-
- name: check for unknown lints and cfgs
1102-
run: cargo check --all-features --tests
1103-
env:
1104-
RUSTFLAGS: -Dwarnings --check-cfg=cfg(loom,tokio_unstable,tokio_taskdump,fuzzing,mio_unsupported_force_poll_poll,tokio_internal_mt_counters,fs,tokio_no_parking_lot,tokio_no_tuning_tests) -Funexpected_cfgs -Funknown_lints
1105-
11061089
check-fuzzing:
11071090
name: check-fuzzing
11081091
needs: basics

Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@ members = [
1717

1818
[workspace.metadata.spellcheck]
1919
config = "spellcheck.toml"
20+
21+
[workspace.lints.rust]
22+
unexpected_cfgs = { level = "warn", check-cfg = [
23+
'cfg(fuzzing)',
24+
'cfg(loom)',
25+
'cfg(mio_unsupported_force_poll_poll)',
26+
'cfg(tokio_internal_mt_counters)',
27+
'cfg(tokio_no_parking_lot)',
28+
'cfg(tokio_no_tuning_tests)',
29+
'cfg(tokio_taskdump)',
30+
'cfg(tokio_unstable)',
31+
] }

benches/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ harness = false
9595
name = "time_timeout"
9696
path = "time_timeout.rs"
9797
harness = false
98+
99+
[lints]
100+
workspace = true

examples/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ path = "named-pipe-multi-client.rs"
9595
[[example]]
9696
name = "dump"
9797
path = "dump.rs"
98+
99+
[lints]
100+
workspace = true

examples/dump.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
2-
31
//! This example demonstrates tokio's experimental task dumping functionality.
42
//! This application deadlocks. Input CTRL+C to display traces of each task, or
53
//! input CTRL+C twice within 1 second to quit.

stress-test/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ tokio = { version = "1.0.0", path = "../tokio/", features = ["full"] }
1313

1414
[dev-dependencies]
1515
rand = "0.8"
16+
17+
[lints]
18+
workspace = true

tests-build/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ tokio = { version = "1.0.0", path = "../tokio", optional = true }
1515

1616
[dev-dependencies]
1717
trybuild = "1.0"
18+
19+
[lints]
20+
workspace = true

tests-integration/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ tokio-test = { version = "0.4", path = "../tokio-test", optional = true }
6161
doc-comment = "0.3.1"
6262
futures = { version = "0.3.0", features = ["async-await"] }
6363
bytes = "1.0.0"
64+
65+
[lints]
66+
workspace = true

tokio-macros/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ tokio = { version = "1.0.0", path = "../tokio", features = ["full"] }
3131

3232
[package.metadata.docs.rs]
3333
all-features = true
34+
35+
[lints]
36+
workspace = true

tokio-macros/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![allow(clippy::needless_doctest_main)]
32
#![warn(
43
missing_debug_implementations,
@@ -211,7 +210,6 @@ use proc_macro::TokenStream;
211210
/// This option is only compatible with the `current_thread` runtime.
212211
///
213212
/// ```no_run
214-
/// # #![allow(unknown_lints, unexpected_cfgs)]
215213
/// #[cfg(tokio_unstable)]
216214
/// #[tokio::main(flavor = "current_thread", unhandled_panic = "shutdown_runtime")]
217215
/// async fn main() {
@@ -226,7 +224,6 @@ use proc_macro::TokenStream;
226224
/// Equivalent code not using `#[tokio::main]`
227225
///
228226
/// ```no_run
229-
/// # #![allow(unknown_lints, unexpected_cfgs)]
230227
/// #[cfg(tokio_unstable)]
231228
/// fn main() {
232229
/// tokio::runtime::Builder::new_current_thread()
@@ -480,7 +477,6 @@ pub fn main_rt(args: TokenStream, item: TokenStream) -> TokenStream {
480477
/// This option is only compatible with the `current_thread` runtime.
481478
///
482479
/// ```no_run
483-
/// # #![allow(unknown_lints, unexpected_cfgs)]
484480
/// #[cfg(tokio_unstable)]
485481
/// #[tokio::test(flavor = "current_thread", unhandled_panic = "shutdown_runtime")]
486482
/// async fn my_test() {
@@ -495,7 +491,6 @@ pub fn main_rt(args: TokenStream, item: TokenStream) -> TokenStream {
495491
/// Equivalent code not using `#[tokio::test]`
496492
///
497493
/// ```no_run
498-
/// # #![allow(unknown_lints, unexpected_cfgs)]
499494
/// #[cfg(tokio_unstable)]
500495
/// #[test]
501496
/// fn my_test() {

tokio-stream/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ rustdoc-args = ["--cfg", "docsrs"]
5656
# This should allow `docsrs` to be read across projects, so that `tokio-stream`
5757
# can pick up stubbed types exported by `tokio`.
5858
rustc-args = ["--cfg", "docsrs"]
59+
60+
[lints]
61+
workspace = true

tokio-stream/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![allow(
32
clippy::cognitive_complexity,
43
clippy::large_enum_variant,

tokio-test/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ futures-util = "0.3.0"
3030

3131
[package.metadata.docs.rs]
3232
all-features = true
33+
34+
[lints]
35+
workspace = true

tokio-test/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(
32
missing_debug_implementations,
43
missing_docs,

tokio-util/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ rustc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable"]
6868

6969
[package.metadata.playground]
7070
features = ["full"]
71+
72+
[lints]
73+
workspace = true

tokio-util/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![allow(clippy::needless_doctest_main)]
32
#![warn(
43
missing_debug_implementations,

tokio-util/tests/task_join_map.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(feature = "rt", tokio_unstable))]
43

tokio/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,6 @@ allowed_external_types = [
173173
"bytes::buf::buf_mut::BufMut",
174174
"tokio_macros::*",
175175
]
176+
177+
[lints]
178+
workspace = true

tokio/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![allow(
32
clippy::cognitive_complexity,
43
clippy::large_enum_variant,

tokio/src/runtime/blocking/pool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub(crate) struct Task {
128128

129129
#[derive(PartialEq, Eq)]
130130
pub(crate) enum Mandatory {
131-
#[cfg_attr(not(fs), allow(dead_code))]
131+
#[cfg_attr(not(feature = "fs"), allow(dead_code))]
132132
Mandatory,
133133
NonMandatory,
134134
}

tokio/tests/_require_full.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
2-
31
#[cfg(not(any(feature = "full", target_family = "wasm")))]
42
compile_error!("run main Tokio tests with `--features full`");
53

tokio/tests/dump.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![cfg(all(
32
tokio_unstable,
43
tokio_taskdump,

tokio/tests/macros_select.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![cfg(feature = "macros")]
32
#![allow(clippy::disallowed_names)]
43

tokio/tests/macros_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threading
32

43
use tokio::test;

tokio/tests/rt_basic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(feature = "full")]
43
#![cfg(not(miri))] // Possible bug on Miri.

tokio/tests/rt_common.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![allow(clippy::needless_range_loop)]
32
#![warn(rust_2018_idioms)]
43
#![cfg(feature = "full")]

tokio/tests/rt_handle.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(feature = "full")]
43

tokio/tests/rt_local.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(feature = "full", tokio_unstable))]
43

tokio/tests/rt_metrics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(feature = "full", not(target_os = "wasi"), target_has_atomic = "64"))]
43

tokio/tests/rt_threaded.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
// Too slow on miri.
43
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]

tokio/tests/rt_threaded_alt.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(feature = "full", not(target_os = "wasi")))]
43
#![cfg(tokio_unstable)]

tokio/tests/rt_unstable_metrics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(
43
feature = "full",

tokio/tests/task_builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![cfg(all(tokio_unstable, feature = "tracing"))]
32

43
use std::rc::Rc;

tokio/tests/task_hooks.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(all(feature = "full", tokio_unstable, target_has_atomic = "64"))]
43

tokio/tests/task_id.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(feature = "full")]
43

tokio/tests/task_join_set.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(feature = "full")]
43

tokio/tests/task_local_set.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![warn(rust_2018_idioms)]
32
#![cfg(feature = "full")]
43

tokio/tests/task_yield_now.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unknown_lints, unexpected_cfgs)]
21
#![cfg(all(feature = "full", not(target_os = "wasi"), tokio_unstable))]
32

43
use tokio::task;

tokio/tests/tracing_sync.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! These tests ensure that the instrumentation for tokio
44
//! synchronization primitives is correct.
5-
#![allow(unknown_lints, unexpected_cfgs)]
65
#![warn(rust_2018_idioms)]
76
#![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))]
87

tokio/tests/tracing_task.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! These tests ensure that the instrumentation for task spawning and task
44
//! lifecycles is correct.
5-
#![allow(unknown_lints, unexpected_cfgs)]
65
#![warn(rust_2018_idioms)]
76
#![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))]
87

tokio/tests/tracing_time.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! These tests ensure that the instrumentation for tokio
44
//! synchronization primitives is correct.
5-
#![allow(unknown_lints, unexpected_cfgs)]
65
#![warn(rust_2018_idioms)]
76
#![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))]
87

0 commit comments

Comments
 (0)