diff --git a/.cirrus.yml b/.cirrus.yml index 8aea3efa74b..bdf3af74098 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,7 +4,7 @@ freebsd_instance: image_family: freebsd-14-0 env: RUST_STABLE: stable - RUST_NIGHTLY: nightly-2023-10-21 + RUST_NIGHTLY: nightly-2024-05-05 RUSTFLAGS: -D warnings # Test FreeBSD in a full VM on cirrus-ci.com. Test the i686 target too, in the diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f5e9004959..1d799a54083 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ env: RUST_BACKTRACE: 1 # Change to specific Rust release to pin rust_stable: stable - rust_nightly: nightly-2023-10-21 + rust_nightly: nightly-2024-05-05 rust_clippy: '1.77' # When updating this, also update: # - README.md @@ -995,6 +995,23 @@ 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 diff --git a/target-specs/README.md b/target-specs/README.md new file mode 100644 index 00000000000..f5db16b78c5 --- /dev/null +++ b/target-specs/README.md @@ -0,0 +1,9 @@ +This is used for the `no-atomic-u64-test` ci check that verifies that Tokio +works even if the `AtomicU64` type is missing. + +When increasing the nightly compiler version, you may need to regenerate this +target using the following command: +``` +rustc +nightly -Z unstable-options --print target-spec-json --target i686-unknown-linux-gnu | grep -v 'is-builtin' | sed 's/"max-atomic-width": 64/"max-atomic-width": 32/' > target-specs/i686-unknown-linux-gnu.json +``` + diff --git a/target-specs/i686-unknown-linux-gnu.json b/target-specs/i686-unknown-linux-gnu.json index 4eebe7afb57..7a70e7474f3 100644 --- a/target-specs/i686-unknown-linux-gnu.json +++ b/target-specs/i686-unknown-linux-gnu.json @@ -1,29 +1,35 @@ { "arch": "x86", "cpu": "pentium4", + "crt-objects-fallback": "false", "crt-static-respected": true, - "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128", + "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128", "dynamic-linking": true, "env": "gnu", "has-rpath": true, "has-thread-local": true, + "linker-flavor": "gnu-cc", "llvm-target": "i686-unknown-linux-gnu", "max-atomic-width": 32, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "linux", "position-independent-executables": true, "pre-link-args": { - "gcc": [ + "gnu-cc": [ + "-m32" + ], + "gnu-lld-cc": [ "-m32" ] }, "relro-level": "full", "stack-probes": { - "kind": "inline-or-call", - "min-llvm-version-for-inline": [ - 16, - 0, - 0 - ] + "kind": "inline" }, "supported-sanitizers": [ "address" diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index ab7b083d381..c108d8c46a2 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![allow(clippy::needless_doctest_main)] #![warn( missing_debug_implementations, diff --git a/tokio-stream/src/lib.rs b/tokio-stream/src/lib.rs index 6ff1085a552..11ccd8c6aee 100644 --- a/tokio-stream/src/lib.rs +++ b/tokio-stream/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![allow( clippy::cognitive_complexity, clippy::large_enum_variant, diff --git a/tokio-test/src/lib.rs b/tokio-test/src/lib.rs index 87e63861210..9f60faf7952 100644 --- a/tokio-test/src/lib.rs +++ b/tokio-test/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn( missing_debug_implementations, missing_docs, diff --git a/tokio-util/src/codec/length_delimited.rs b/tokio-util/src/codec/length_delimited.rs index 92d76b2cd28..c37f5863bd4 100644 --- a/tokio-util/src/codec/length_delimited.rs +++ b/tokio-util/src/codec/length_delimited.rs @@ -639,7 +639,6 @@ mod builder { impl LengthFieldType for u64 {} #[cfg(any( - target_pointer_width = "8", target_pointer_width = "16", target_pointer_width = "32", target_pointer_width = "64", diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 1df4de1b459..34f69fd14e3 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![allow(clippy::needless_doctest_main)] #![warn( missing_debug_implementations, diff --git a/tokio-util/tests/task_join_map.rs b/tokio-util/tests/task_join_map.rs index 1ab5f9ba832..8757f8b5c6e 100644 --- a/tokio-util/tests/task_join_map.rs +++ b/tokio-util/tests/task_join_map.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "rt", tokio_unstable))] diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 52b098986fb..f15f8763e36 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![allow( clippy::cognitive_complexity, clippy::large_enum_variant, @@ -446,13 +447,9 @@ // least 32 bits, which a lot of components in Tokio currently assumes. // // TODO: improve once we have MSRV access to const eval to make more flexible. -#[cfg(not(any( - target_pointer_width = "32", - target_pointer_width = "64", - target_pointer_width = "128" -)))] +#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64")))] compile_error! { - "Tokio requires the platform pointer width to be 32, 64, or 128 bits" + "Tokio requires the platform pointer width to be at least 32 bits" } #[cfg(all( diff --git a/tokio/src/signal/mod.rs b/tokio/src/signal/mod.rs index 59f71db0e46..5778f22ed12 100644 --- a/tokio/src/signal/mod.rs +++ b/tokio/src/signal/mod.rs @@ -45,7 +45,9 @@ use crate::sync::watch::Receiver; use std::task::{Context, Poll}; +#[cfg(feature = "signal")] mod ctrl_c; +#[cfg(feature = "signal")] pub use ctrl_c::ctrl_c; pub(crate) mod registry; diff --git a/tokio/src/signal/unix.rs b/tokio/src/signal/unix.rs index 52a9cbaac40..c4a196a660f 100644 --- a/tokio/src/signal/unix.rs +++ b/tokio/src/signal/unix.rs @@ -485,10 +485,12 @@ impl Signal { } // Work around for abstracting streams internally +#[cfg(feature = "process")] pub(crate) trait InternalStream { fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll>; } +#[cfg(feature = "process")] impl InternalStream for Signal { fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll> { self.poll_recv(cx) diff --git a/tokio/tests/_require_full.rs b/tokio/tests/_require_full.rs index d33943a960d..81c25179615 100644 --- a/tokio/tests/_require_full.rs +++ b/tokio/tests/_require_full.rs @@ -1,3 +1,5 @@ +#![allow(unknown_lints, unexpected_cfgs)] + #[cfg(not(any(feature = "full", target_family = "wasm")))] compile_error!("run main Tokio tests with `--features full`"); diff --git a/tokio/tests/dump.rs b/tokio/tests/dump.rs index c946f38436c..68b53aaf291 100644 --- a/tokio/tests/dump.rs +++ b/tokio/tests/dump.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![cfg(all( tokio_unstable, tokio_taskdump, diff --git a/tokio/tests/fs_open_options.rs b/tokio/tests/fs_open_options.rs index 41cfb45460c..84b63a504cf 100644 --- a/tokio/tests/fs_open_options.rs +++ b/tokio/tests/fs_open_options.rs @@ -55,8 +55,13 @@ async fn open_options_create_new() { #[tokio::test] #[cfg(unix)] async fn open_options_mode() { + let mode = format!("{:?}", OpenOptions::new().mode(0o644)); // TESTING HACK: use Debug output to check the stored data - assert!(format!("{:?}", OpenOptions::new().mode(0o644)).contains("mode: 420 ")); + assert!( + mode.contains("mode: 420 ") || mode.contains("mode: 0o000644 "), + "mode is: {}", + mode + ); } #[tokio::test] diff --git a/tokio/tests/macros_select.rs b/tokio/tests/macros_select.rs index f65cbdf2267..cbad971ab1f 100644 --- a/tokio/tests/macros_select.rs +++ b/tokio/tests/macros_select.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![cfg(feature = "macros")] #![allow(clippy::disallowed_names)] diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 47bf2dfdc12..a5204bd83f7 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index a71fc4a735e..75a20057166 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![allow(clippy::needless_range_loop)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] diff --git a/tokio/tests/rt_handle.rs b/tokio/tests/rt_handle.rs index 92fa777e321..9efe9b4bde9 100644 --- a/tokio/tests/rt_handle.rs +++ b/tokio/tests/rt_handle.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] diff --git a/tokio/tests/rt_metrics.rs b/tokio/tests/rt_metrics.rs index 4dfed06fed4..58869c530ae 100644 --- a/tokio/tests/rt_metrics.rs +++ b/tokio/tests/rt_metrics.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))] diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index 6e769fc831f..26690550f93 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] diff --git a/tokio/tests/rt_threaded_alt.rs b/tokio/tests/rt_threaded_alt.rs index 8b7143b2f97..9eed1fe78b6 100644 --- a/tokio/tests/rt_threaded_alt.rs +++ b/tokio/tests/rt_threaded_alt.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] #![cfg(tokio_unstable)] diff --git a/tokio/tests/task_abort.rs b/tokio/tests/task_abort.rs index 481cc96f2ef..09414f094ed 100644 --- a/tokio/tests/task_abort.rs +++ b/tokio/tests/task_abort.rs @@ -7,8 +7,10 @@ use tokio::time::Duration; use tokio::runtime::Builder; +#[cfg(panic = "unwind")] struct PanicOnDrop; +#[cfg(panic = "unwind")] impl Drop for PanicOnDrop { fn drop(&mut self) { panic!("Well what did you expect would happen..."); diff --git a/tokio/tests/task_builder.rs b/tokio/tests/task_builder.rs index c700f229f9f..4d1248500ab 100644 --- a/tokio/tests/task_builder.rs +++ b/tokio/tests/task_builder.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![cfg(all(tokio_unstable, feature = "tracing"))] use std::rc::Rc; diff --git a/tokio/tests/task_id.rs b/tokio/tests/task_id.rs index 95e48f4901d..574a050b0c1 100644 --- a/tokio/tests/task_id.rs +++ b/tokio/tests/task_id.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable))] diff --git a/tokio/tests/task_join_set.rs b/tokio/tests/task_join_set.rs index 8a42be17b49..e87135337ba 100644 --- a/tokio/tests/task_join_set.rs +++ b/tokio/tests/task_join_set.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] diff --git a/tokio/tests/task_local_set.rs b/tokio/tests/task_local_set.rs index d965eb341eb..ac46291a36c 100644 --- a/tokio/tests/task_local_set.rs +++ b/tokio/tests/task_local_set.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(feature = "full")] diff --git a/tokio/tests/task_yield_now.rs b/tokio/tests/task_yield_now.rs index b16bca52819..3cb8cb16e70 100644 --- a/tokio/tests/task_yield_now.rs +++ b/tokio/tests/task_yield_now.rs @@ -1,3 +1,4 @@ +#![allow(unknown_lints, unexpected_cfgs)] #![cfg(all(feature = "full", tokio_unstable))] use tokio::task;