Skip to content

Commit

Permalink
lint: enable unexpected cfg checking in all in-repo builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 7, 2024
1 parent 6fcd9c0 commit 8ce3735
Show file tree
Hide file tree
Showing 29 changed files with 60 additions and 37 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -995,23 +995,6 @@ jobs:
run: cargo check-external-types --all-features
working-directory: tokio

check-unexpected-lints-cfgs:
name: check unexpected lints and cfgs
needs: basics
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_nightly }}
- name: don't allow warnings
run: sed -i '/#!\[allow(unknown_lints, unexpected_cfgs)\]/d' */src/lib.rs */tests/*.rs
- name: check for unknown lints and cfgs
run: cargo check --all-features --tests
env:
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

check-fuzzing:
name: check-fuzzing
needs: basics
Expand Down
1 change: 0 additions & 1 deletion tokio-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![allow(clippy::needless_doctest_main)]
#![warn(
missing_debug_implementations,
Expand Down
1 change: 1 addition & 0 deletions tokio-stream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description = """
Utilities to work with `Stream` and `tokio`.
"""
categories = ["asynchronous"]
exclude = ["build.rs"]

[features]
default = ["time"]
Expand Down
7 changes: 7 additions & 0 deletions tokio-stream/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
// Warning: build.rs is not published to crates.io.

println!("cargo:rustc-cfg=check_cfg");
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
println!("cargo:rustc-check-cfg=cfg(loom)");
}
2 changes: 1 addition & 1 deletion tokio-stream/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![allow(
clippy::cognitive_complexity,
clippy::large_enum_variant,
Expand Down
1 change: 1 addition & 0 deletions tokio-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description = """
Testing utilities for Tokio- and futures-based code
"""
categories = ["asynchronous", "development-tools::testing"]
exclude = ["build.rs"]

[dependencies]
tokio = { version = "1.2.0", path = "../tokio", features = ["rt", "sync", "time", "test-util"] }
Expand Down
7 changes: 7 additions & 0 deletions tokio-test/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
// Warning: build.rs is not published to crates.io.

println!("cargo:rustc-cfg=check_cfg");
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
println!("cargo:rustc-check-cfg=cfg(loom)");
}
2 changes: 1 addition & 1 deletion tokio-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(
missing_debug_implementations,
missing_docs,
Expand Down
1 change: 1 addition & 0 deletions tokio-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description = """
Additional utilities for working with Tokio.
"""
categories = ["asynchronous"]
exclude = ["build.rs"]

[features]
# No features on by default
Expand Down
8 changes: 8 additions & 0 deletions tokio-util/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
// Warning: build.rs is not published to crates.io.

println!("cargo:rustc-cfg=check_cfg");
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
println!("cargo:rustc-check-cfg=cfg(loom)");
println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");
}
2 changes: 1 addition & 1 deletion tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![allow(clippy::needless_doctest_main)]
#![warn(
missing_debug_implementations,
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/task_join_map.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "rt", tokio_unstable))]

Expand Down
1 change: 1 addition & 0 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ backed applications.
"""
categories = ["asynchronous", "network-programming"]
keywords = ["io", "async", "non-blocking", "futures"]
exclude = ["build.rs"]

[features]
# Include nothing by default
Expand Down
15 changes: 15 additions & 0 deletions tokio/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fn main() {
// Warning: build.rs is not published to crates.io.

println!("cargo:rustc-cfg=check_cfg");
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
println!("cargo:rustc-check-cfg=cfg(fs)");
println!("cargo:rustc-check-cfg=cfg(fuzzing)");
println!("cargo:rustc-check-cfg=cfg(loom)");
println!("cargo:rustc-check-cfg=cfg(mio_unsupported_force_poll_poll)");
println!("cargo:rustc-check-cfg=cfg(tokio_internal_mt_counters)");
println!("cargo:rustc-check-cfg=cfg(tokio_no_parking_lot)");
println!("cargo:rustc-check-cfg=cfg(tokio_no_tuning_tests)");
println!("cargo:rustc-check-cfg=cfg(tokio_taskdump)");
println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");
}
2 changes: 1 addition & 1 deletion tokio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![allow(
clippy::cognitive_complexity,
clippy::large_enum_variant,
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/_require_full.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]

#[cfg(not(any(feature = "full", target_family = "wasm")))]
compile_error!("run main Tokio tests with `--features full`");
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/dump.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![cfg(all(
tokio_unstable,
tokio_taskdump,
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/macros_select.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![cfg(feature = "macros")]
#![allow(clippy::disallowed_names)]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![allow(clippy::needless_range_loop)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_handle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_threaded.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_threaded_alt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(tokio_unstable)]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![cfg(all(tokio_unstable, feature = "tracing"))]

use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", tokio_unstable))]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_join_set.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_local_set.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_yield_now.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![cfg_attr(not(check_cfg), allow(unknown_lints, unexpected_cfgs))]
#![cfg(all(feature = "full", tokio_unstable))]

use tokio::task;
Expand Down

0 comments on commit 8ce3735

Please sign in to comment.