From 7b4c999341809588a427a9a80d310ee4aa1c1a21 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 22 Nov 2019 15:55:10 -0800 Subject: [PATCH] default all feature flags to off (#1811) Changes the set of `default` feature flags to `[]`. By default, only core traits are included without specifying feature flags. This makes it easier for users to pick the components they need. For convenience, a `full` feature flag is included that includes all components. Tests are configured to require the `full` feature. Testing individual feature flags will need to be moved to a separate crate. Closes #1791 --- README.md | 10 ++++------ ci/azure-test-stable.yml | 16 ---------------- examples/Cargo.toml | 4 ++-- tests-integration/Cargo.toml | 3 ++- tests-integration/src/lib.rs | 4 ++++ tokio-macros/Cargo.toml | 2 +- tokio-test/Cargo.toml | 3 ++- tokio-tls/Cargo.toml | 2 ++ tokio-util/Cargo.toml | 13 ++++++++++++- tokio-util/src/cfg.rs | 19 +++++++++++++++++++ tokio-util/src/lib.rs | 13 +++++++++++-- tokio-util/src/udp/frame.rs | 1 + tokio/Cargo.toml | 7 ++++--- tokio/README.md | 9 +++++++++ tokio/src/lib.rs | 7 +++++++ tokio/src/sync/mod.rs | 8 +++++--- tokio/tests/_require_full.rs | 2 ++ tokio/tests/buffered.rs | 1 + tokio/tests/fs_dir.rs | 1 + tokio/tests/fs_file.rs | 1 + tokio/tests/fs_file_mocked.rs | 1 + tokio/tests/fs_link.rs | 1 + tokio/tests/io_async_read.rs | 3 +++ tokio/tests/io_chain.rs | 1 + tokio/tests/io_copy.rs | 1 + tokio/tests/io_driver.rs | 1 + tokio/tests/io_driver_drop.rs | 1 + tokio/tests/io_lines.rs | 1 + tokio/tests/io_read.rs | 1 + tokio/tests/io_read_exact.rs | 1 + tokio/tests/io_read_line.rs | 1 + tokio/tests/io_read_to_end.rs | 1 + tokio/tests/io_read_to_string.rs | 1 + tokio/tests/io_read_until.rs | 1 + tokio/tests/io_split.rs | 3 +++ tokio/tests/io_take.rs | 1 + tokio/tests/io_write.rs | 1 + tokio/tests/io_write_all.rs | 1 + tokio/tests/net_bind_resource.rs | 3 +++ tokio/tests/process_issue_42.rs | 4 ++-- tokio/tests/process_smoke.rs | 2 +- tokio/tests/rt_basic.rs | 1 + tokio/tests/rt_common.rs | 5 +++-- tokio/tests/rt_threaded.rs | 1 + tokio/tests/signal_ctrl_c.rs | 3 ++- tokio/tests/signal_drop_recv.rs | 3 ++- tokio/tests/signal_drop_rt.rs | 3 ++- tokio/tests/signal_drop_signal.rs | 3 ++- tokio/tests/signal_multi_rt.rs | 3 ++- tokio/tests/signal_no_rt.rs | 3 ++- tokio/tests/signal_notify_both.rs | 3 ++- tokio/tests/signal_twice.rs | 3 ++- tokio/tests/signal_usr1.rs | 3 ++- tokio/tests/sync_barrier.rs | 1 + tokio/tests/sync_errors.rs | 1 + tokio/tests/sync_mpsc.rs | 1 + tokio/tests/sync_mutex.rs | 1 + tokio/tests/sync_oneshot.rs | 1 + tokio/tests/sync_watch.rs | 1 + tokio/tests/tcp_accept.rs | 1 + tokio/tests/tcp_connect.rs | 1 + tokio/tests/tcp_echo.rs | 1 + tokio/tests/tcp_peek.rs | 1 + tokio/tests/tcp_shutdown.rs | 1 + tokio/tests/time_interval.rs | 1 + tokio/tests/time_rt.rs | 1 + tokio/tests/time_timeout.rs | 1 + tokio/tests/udp.rs | 1 + tokio/tests/uds_cred.rs | 5 +++-- tokio/tests/uds_datagram.rs | 30 ++---------------------------- tokio/tests/uds_split.rs | 3 ++- tokio/tests/uds_stream.rs | 3 ++- 72 files changed, 165 insertions(+), 82 deletions(-) create mode 100644 tests-integration/src/lib.rs create mode 100644 tokio-util/src/cfg.rs create mode 100644 tokio/tests/_require_full.rs diff --git a/README.md b/README.md index c2aa98afde2..75e6f2642e2 100644 --- a/README.md +++ b/README.md @@ -54,15 +54,13 @@ an asynchronous application. A basic TCP echo server with Tokio: -```rust +```rust,no_run use tokio::net::TcpListener; use tokio::prelude::*; -use std::net::SocketAddr; #[tokio::main] async fn main() -> Result<(), Box> { - let addr = "127.0.0.1:8080".parse::()?; - let mut listener = TcpListener::bind(&addr).await?; + let mut listener = TcpListener::bind("127.0.0.1:8080").await?; loop { let (mut socket, _) = listener.accept().await?; @@ -77,14 +75,14 @@ async fn main() -> Result<(), Box> { Ok(n) if n == 0 => return, Ok(n) => n, Err(e) => { - println!("failed to read from socket; err = {:?}", e); + eprintln!("failed to read from socket; err = {:?}", e); return; } }; // Write the data back if let Err(e) = socket.write_all(&buf[0..n]).await { - println!("failed to write to socket; err = {:?}", e); + eprintln!("failed to write to socket; err = {:?}", e); return; } } diff --git a/ci/azure-test-stable.yml b/ci/azure-test-stable.yml index 5d806a6ae9b..3e5a181b832 100644 --- a/ci/azure-test-stable.yml +++ b/ci/azure-test-stable.yml @@ -22,14 +22,6 @@ jobs: - template: azure-is-release.yml - ${{ each crate in parameters.crates }}: - # Run with default crate features - - script: cargo test - env: - LOOM_MAX_PREEMPTIONS: 2 - CI: 'True' - displayName: ${{ crate }} - cargo test - workingDirectory: $(Build.SourcesDirectory)/${{ crate }} - # Run with all crate features - script: cargo test --all-features env: @@ -41,14 +33,6 @@ jobs: - template: azure-patch-crates.yml - ${{ each crate in parameters.crates }}: - # Run with default crate features - - script: cargo test - env: - LOOM_MAX_PREEMPTIONS: 2 - CI: 'True' - displayName: ${{ crate }} - cargo test - workingDirectory: $(Build.SourcesDirectory)/${{ crate }} - # Run with all crate features - script: cargo test --all-features env: diff --git a/examples/Cargo.toml b/examples/Cargo.toml index ed273590802..21b42ff73a2 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -5,8 +5,8 @@ publish = false edition = "2018" [dev-dependencies] -tokio = { version = "=0.2.0-alpha.6", path = "../tokio" } -tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util" } +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] } +tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util", features = ["full"] } bytes = { git = "https://github.com/tokio-rs/bytes" } futures = "0.3.0" diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index 2a6af097ed5..265d7d6de9a 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -6,9 +6,10 @@ edition = "2018" publish = false [dependencies] +tokio = { path = "../tokio", features = ["full"] } +doc-comment = "0.3.1" [dev-dependencies] -tokio = { path = "../tokio" } tokio-test = { path = "../tokio-test" } futures = { version = "0.3.0", features = ["async-await"] } diff --git a/tests-integration/src/lib.rs b/tests-integration/src/lib.rs new file mode 100644 index 00000000000..74795f297dd --- /dev/null +++ b/tests-integration/src/lib.rs @@ -0,0 +1,4 @@ +use doc_comment::doc_comment; + +// #[doc = include_str!("../../README.md")] +doc_comment!(include_str!("../../README.md")); diff --git a/tokio-macros/Cargo.toml b/tokio-macros/Cargo.toml index 4bf87927ea3..7e8d9513cbb 100644 --- a/tokio-macros/Cargo.toml +++ b/tokio-macros/Cargo.toml @@ -29,7 +29,7 @@ quote = "1" syn = { version = "1.0.3", features = ["full"] } [dev-dependencies] -tokio = { version = "=0.2.0-alpha.6", path = "../tokio" } +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] } [package.metadata.docs.rs] all-features = true diff --git a/tokio-test/Cargo.toml b/tokio-test/Cargo.toml index b1ac4de1003..cd0f4044c24 100644 --- a/tokio-test/Cargo.toml +++ b/tokio-test/Cargo.toml @@ -20,12 +20,13 @@ Testing utilities for Tokio- and futures-based code categories = ["asynchronous", "testing"] [dependencies] -tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["test-util"] } +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["rt-core", "sync", "time", "test-util"] } bytes = { git = "https://github.com/tokio-rs/bytes" } futures-core = "0.3.0" [dev-dependencies] +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] } futures-util = "0.3.0" [package.metadata.docs.rs] diff --git a/tokio-tls/Cargo.toml b/tokio-tls/Cargo.toml index 022f6edae72..fee03cc6ee3 100644 --- a/tokio-tls/Cargo.toml +++ b/tokio-tls/Cargo.toml @@ -29,6 +29,8 @@ native-tls = "0.2" tokio = { version = "=0.2.0-alpha.6", path = "../tokio" } [dev-dependencies] +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["macros", "stream", "rt-core", "io-util", "net"] } + cfg-if = "0.1" env_logger = { version = "0.6", default-features = false } futures = { version = "0.3.0", features = ["async-await"] } diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index 8e5542be924..356712c6561 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -19,6 +19,16 @@ Additional utilities for working with Tokio. """ categories = ["asynchronous"] +[features] +# No features on by default +default = [] + +# Shorthand for enabling everything +full = ["codec", "udp"] + +codec = [] +udp = ["tokio/udp"] + [dependencies] tokio = { version = "=0.2.0-alpha.6", path = "../tokio" } @@ -29,10 +39,11 @@ log = "0.4" pin-project-lite = "0.1.1" [dev-dependencies] -tokio = { version = "=0.2.0-alpha.6", path = "../tokio" } +tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] } tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" } futures = "0.3.0" [package.metadata.docs.rs] all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/tokio-util/src/cfg.rs b/tokio-util/src/cfg.rs new file mode 100644 index 00000000000..13fabd36383 --- /dev/null +++ b/tokio-util/src/cfg.rs @@ -0,0 +1,19 @@ +macro_rules! cfg_codec { + ($($item:item)*) => { + $( + #[cfg(feature = "codec")] + #[cfg_attr(docsrs, doc(cfg(feature = "codec")))] + $item + )* + } +} + +macro_rules! cfg_udp { + ($($item:item)*) => { + $( + #[cfg(all(feature = "udp", feature = "codec"))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "udp", feature = "codec"))))] + $item + )* + } +} diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 5a64673c8d1..d4ed5a7b48a 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -10,8 +10,17 @@ no_crate_inject, attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) ))] +#![cfg_attr(docsrs, feature(doc_cfg))] //! Utilities for working with Tokio. -pub mod codec; -pub mod udp; +#[macro_use] +mod cfg; + +cfg_codec! { + pub mod codec; +} + +cfg_udp! { + pub mod udp; +} diff --git a/tokio-util/src/udp/frame.rs b/tokio-util/src/udp/frame.rs index d37b20cd554..a6c6f220704 100644 --- a/tokio-util/src/udp/frame.rs +++ b/tokio-util/src/udp/frame.rs @@ -27,6 +27,7 @@ use std::task::{Context, Poll}; /// calling `split` on the `UdpFramed` returned by this method, which will break /// them into separate objects, allowing them to interact more easily. #[must_use = "sinks do nothing unless polled"] +#[cfg_attr(docsrs, doc(feature = "codec-udp"))] #[derive(Debug)] pub struct UdpFramed { socket: UdpSocket, diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 320e5b38738..4f0161ae6ec 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -24,7 +24,8 @@ categories = ["asynchronous", "network-programming"] keywords = ["io", "async", "non-blocking", "futures"] [features] -default = ["full"] +# Include nothing by default +default = [] # enable everything full = [ @@ -48,7 +49,7 @@ full = [ blocking = ["rt-core"] dns = ["rt-core"] fs = ["rt-core"] -io-driver = ["rt-core", "mio", "lazy_static"] +io-driver = ["mio", "lazy_static"] io-util = ["memchr"] # stdin, stdout, stderr io-std = ["rt-core"] @@ -83,7 +84,7 @@ stream = ["futures-core"] sync = ["fnv"] test-util = [] tcp = ["io-driver"] -time = ["rt-core", "slab"] +time = ["slab"] udp = ["io-driver"] uds = ["io-driver", "mio-uds", "libc"] diff --git a/tokio/README.md b/tokio/README.md index 087ab0258d0..530f0bacb6a 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -52,6 +52,15 @@ an asynchronous application. ## Example +To get started, add the following to `Cargo.toml`. + +```toml +tokio = { version = "0.2.0", features = ["full"] } +``` + +Tokio requires components to be explicitly enabled using feature flags. As a +shorthand, the `full` feature enables all components. + A basic TCP echo server with Tokio: ```rust diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index c213ee89091..cd7a62ea021 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -52,6 +52,13 @@ //! control what features are present, so that unused code can be eliminated. //! This documentation also lists what feature flags are necessary to enable each API. //! +//! The easiest way to get started is to enable all features. Do this by +//! enabling the `full` feature flag: +//! +//! ```toml +//! tokio = { version = "0.2", features = ["full"] } +//! ``` +//! //! [features]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section //! //! ## Working With Tasks diff --git a/tokio/src/sync/mod.rs b/tokio/src/sync/mod.rs index 2954eb85f43..0db703bbe15 100644 --- a/tokio/src/sync/mod.rs +++ b/tokio/src/sync/mod.rs @@ -40,9 +40,11 @@ cfg_not_sync! { pub(crate) use task::AtomicWaker; } - cfg_rt_core! { - pub(crate) mod oneshot; - } + #[cfg(any( + feature = "rt-core", + feature = "process", + feature = "signal"))] + pub(crate) mod oneshot; cfg_signal! { pub(crate) mod mpsc; diff --git a/tokio/tests/_require_full.rs b/tokio/tests/_require_full.rs new file mode 100644 index 00000000000..98455bedefe --- /dev/null +++ b/tokio/tests/_require_full.rs @@ -0,0 +1,2 @@ +#![cfg(not(feature = "full"))] +compile_error!("run main Tokio tests with `--features full`"); diff --git a/tokio/tests/buffered.rs b/tokio/tests/buffered.rs index 5d77f866bd0..7ce3d01cf27 100644 --- a/tokio/tests/buffered.rs +++ b/tokio/tests/buffered.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::prelude::*; diff --git a/tokio/tests/fs_dir.rs b/tokio/tests/fs_dir.rs index 40e20bdb6b5..c8b32fc6b0e 100644 --- a/tokio/tests/fs_dir.rs +++ b/tokio/tests/fs_dir.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs; use tokio_test::assert_ok; diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index 555a1e64a0f..3a56276e182 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs::File; use tokio::prelude::*; diff --git a/tokio/tests/fs_file_mocked.rs b/tokio/tests/fs_file_mocked.rs index 12463cfc34a..0c5722404ea 100644 --- a/tokio/tests/fs_file_mocked.rs +++ b/tokio/tests/fs_file_mocked.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] macro_rules! ready { ($e:expr $(,)?) => { diff --git a/tokio/tests/fs_link.rs b/tokio/tests/fs_link.rs index faf6e75e448..cbbe27efe42 100644 --- a/tokio/tests/fs_link.rs +++ b/tokio/tests/fs_link.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs; diff --git a/tokio/tests/io_async_read.rs b/tokio/tests/io_async_read.rs index 0b9509e19e4..2be2aa1a118 100644 --- a/tokio/tests/io_async_read.rs +++ b/tokio/tests/io_async_read.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::io::AsyncRead; use tokio_test::task; use tokio_test::{assert_ready_err, assert_ready_ok}; diff --git a/tokio/tests/io_chain.rs b/tokio/tests/io_chain.rs index d7cb47caa50..e2d59411a11 100644 --- a/tokio/tests/io_chain.rs +++ b/tokio/tests/io_chain.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_copy.rs b/tokio/tests/io_copy.rs index a9df7430294..75d77435828 100644 --- a/tokio/tests/io_copy.rs +++ b/tokio/tests/io_copy.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncRead, AsyncReadExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_driver.rs b/tokio/tests/io_driver.rs index ec51373f44e..b85abd8c2ac 100644 --- a/tokio/tests/io_driver.rs +++ b/tokio/tests/io_driver.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_driver_drop.rs b/tokio/tests/io_driver_drop.rs index 6b923dd3b2c..0a5ce62513b 100644 --- a/tokio/tests/io_driver_drop.rs +++ b/tokio/tests/io_driver_drop.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_lines.rs b/tokio/tests/io_lines.rs index 83240d62336..3775cae05de 100644 --- a/tokio/tests/io_lines.rs +++ b/tokio/tests/io_lines.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read.rs b/tokio/tests/io_read.rs index 01cd2fd6cc9..d18615e452a 100644 --- a/tokio/tests/io_read.rs +++ b/tokio/tests/io_read.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncRead, AsyncReadExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_exact.rs b/tokio/tests/io_read_exact.rs index 8b2f20ec41d..d0e659bd339 100644 --- a/tokio/tests/io_read_exact.rs +++ b/tokio/tests/io_read_exact.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_line.rs b/tokio/tests/io_read_line.rs index 684eb14a3fc..57ae37cef3e 100644 --- a/tokio/tests/io_read_line.rs +++ b/tokio/tests/io_read_line.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_to_end.rs b/tokio/tests/io_read_to_end.rs index 89782aa32f0..ee636ba5963 100644 --- a/tokio/tests/io_read_to_end.rs +++ b/tokio/tests/io_read_to_end.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_to_string.rs b/tokio/tests/io_read_to_string.rs index 270d1e486ed..6b384b89104 100644 --- a/tokio/tests/io_read_to_string.rs +++ b/tokio/tests/io_read_to_string.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_until.rs b/tokio/tests/io_read_until.rs index 270d0221512..4e0e0d10d34 100644 --- a/tokio/tests/io_read_until.rs +++ b/tokio/tests/io_read_until.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index 054a415f6f8..0080f46af59 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf}; use std::io; diff --git a/tokio/tests/io_take.rs b/tokio/tests/io_take.rs index 7b3363e0174..683606f7272 100644 --- a/tokio/tests/io_take.rs +++ b/tokio/tests/io_take.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_write.rs b/tokio/tests/io_write.rs index 15c5be7c216..96cebc3313b 100644 --- a/tokio/tests/io_write.rs +++ b/tokio/tests/io_write.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_write_all.rs b/tokio/tests/io_write_all.rs index fea46dc3b9a..7ca02228a3c 100644 --- a/tokio/tests/io_write_all.rs +++ b/tokio/tests/io_write_all.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/net_bind_resource.rs b/tokio/tests/net_bind_resource.rs index bb507fcc6ca..d4a0b8dab08 100644 --- a/tokio/tests/net_bind_resource.rs +++ b/tokio/tests/net_bind_resource.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::net::TcpListener; use std::convert::TryFrom; diff --git a/tokio/tests/process_issue_42.rs b/tokio/tests/process_issue_42.rs index 1b8dcc9531a..f84c204f1b4 100644 --- a/tokio/tests/process_issue_42.rs +++ b/tokio/tests/process_issue_42.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "process")] -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] use tokio::process::Command; use tokio::runtime; diff --git a/tokio/tests/process_smoke.rs b/tokio/tests/process_smoke.rs index a952f7f6145..d16d1d72c1b 100644 --- a/tokio/tests/process_smoke.rs +++ b/tokio/tests/process_smoke.rs @@ -1,5 +1,5 @@ -#![cfg(feature = "process")] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::process::Command; use tokio_test::assert_ok; diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 700f1029e7c..68e09ef33f3 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::runtime::Runtime; use tokio::sync::oneshot; diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index b360158d254..fe0cf84a71d 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -1,6 +1,7 @@ -// Tests to run on both current-thread & therad-pool runtime variants. - #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + +// Tests to run on both current-thread & therad-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index 4b4c880ece5..2b67b5a403f 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/signal_ctrl_c.rs b/tokio/tests/signal_ctrl_c.rs index 13eeaa81cfa..4b057ee7e14 100644 --- a/tokio/tests/signal_ctrl_c.rs +++ b/tokio/tests/signal_ctrl_c.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_recv.rs b/tokio/tests/signal_drop_recv.rs index 06dffe1257b..b0d9213e618 100644 --- a/tokio/tests/signal_drop_recv.rs +++ b/tokio/tests/signal_drop_recv.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_rt.rs b/tokio/tests/signal_drop_rt.rs index fc790c28d93..aeedd96e4e6 100644 --- a/tokio/tests/signal_drop_rt.rs +++ b/tokio/tests/signal_drop_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_signal.rs b/tokio/tests/signal_drop_signal.rs index b5bc7dd8210..92ac4050d57 100644 --- a/tokio/tests/signal_drop_signal.rs +++ b/tokio/tests/signal_drop_signal.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_multi_rt.rs b/tokio/tests/signal_multi_rt.rs index e34e7c098ac..9d78469578c 100644 --- a/tokio/tests/signal_multi_rt.rs +++ b/tokio/tests/signal_multi_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_no_rt.rs b/tokio/tests/signal_no_rt.rs index b512e5e7987..b0f32b2d10f 100644 --- a/tokio/tests/signal_no_rt.rs +++ b/tokio/tests/signal_no_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] use tokio::signal::unix::{signal, SignalKind}; diff --git a/tokio/tests/signal_notify_both.rs b/tokio/tests/signal_notify_both.rs index 7d830686307..3481f808b36 100644 --- a/tokio/tests/signal_notify_both.rs +++ b/tokio/tests/signal_notify_both.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_twice.rs b/tokio/tests/signal_twice.rs index 171d18e6050..8f33d22a82d 100644 --- a/tokio/tests/signal_twice.rs +++ b/tokio/tests/signal_twice.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_usr1.rs b/tokio/tests/signal_usr1.rs index 95fc6c10478..d74c7d31ab5 100644 --- a/tokio/tests/signal_usr1.rs +++ b/tokio/tests/signal_usr1.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/sync_barrier.rs b/tokio/tests/sync_barrier.rs index 170e8c2b3d7..e6f32c7a55e 100644 --- a/tokio/tests/sync_barrier.rs +++ b/tokio/tests/sync_barrier.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::Barrier; diff --git a/tokio/tests/sync_errors.rs b/tokio/tests/sync_errors.rs index 8cc0c0cd99a..260f3be6c02 100644 --- a/tokio/tests/sync_errors.rs +++ b/tokio/tests/sync_errors.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] fn is_error() {} diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs index 040904e4acd..127e757263b 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::mpsc; use tokio::sync::mpsc::error::TrySendError; diff --git a/tokio/tests/sync_mutex.rs b/tokio/tests/sync_mutex.rs index b100f270b48..e4be400eb5c 100644 --- a/tokio/tests/sync_mutex.rs +++ b/tokio/tests/sync_mutex.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::Mutex; use tokio_test::task::spawn; diff --git a/tokio/tests/sync_oneshot.rs b/tokio/tests/sync_oneshot.rs index c1d44db8a8e..13e526d48e8 100644 --- a/tokio/tests/sync_oneshot.rs +++ b/tokio/tests/sync_oneshot.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::oneshot; use tokio_test::*; diff --git a/tokio/tests/sync_watch.rs b/tokio/tests/sync_watch.rs index 7ccad5c2adf..f13b145da2a 100644 --- a/tokio/tests/sync_watch.rs +++ b/tokio/tests/sync_watch.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::watch; use tokio_test::task::spawn; diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index 09a2a60352b..eec4338ffde 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_connect.rs b/tokio/tests/tcp_connect.rs index daf0b3c9438..de1cead829e 100644 --- a/tokio/tests/tcp_connect.rs +++ b/tokio/tests/tcp_connect.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_echo.rs b/tokio/tests/tcp_echo.rs index 0325ecbb928..38377702d08 100644 --- a/tokio/tests/tcp_echo.rs +++ b/tokio/tests/tcp_echo.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::prelude::*; diff --git a/tokio/tests/tcp_peek.rs b/tokio/tests/tcp_peek.rs index 34f1ba3a428..c5781daf283 100644 --- a/tokio/tests/tcp_peek.rs +++ b/tokio/tests/tcp_peek.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio::net::TcpStream; diff --git a/tokio/tests/tcp_shutdown.rs b/tokio/tests/tcp_shutdown.rs index 7e0597c971b..cc5ea26f409 100644 --- a/tokio/tests/tcp_shutdown.rs +++ b/tokio/tests/tcp_shutdown.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncWriteExt; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/time_interval.rs b/tokio/tests/time_interval.rs index 70709f4a8a8..6a1c756fe0d 100644 --- a/tokio/tests/time_interval.rs +++ b/tokio/tests/time_interval.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::time::{self, Duration, Instant}; use tokio_test::{assert_pending, assert_ready_eq, task}; diff --git a/tokio/tests/time_rt.rs b/tokio/tests/time_rt.rs index 7de9c345593..b739f1b2f68 100644 --- a/tokio/tests/time_rt.rs +++ b/tokio/tests/time_rt.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::time::*; diff --git a/tokio/tests/time_timeout.rs b/tokio/tests/time_timeout.rs index 408f794e3bf..4efcd8ca82f 100644 --- a/tokio/tests/time_timeout.rs +++ b/tokio/tests/time_timeout.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::oneshot; use tokio::time::{self, timeout, timeout_at, Instant}; diff --git a/tokio/tests/udp.rs b/tokio/tests/udp.rs index a2e4f3a6c6c..71c282a5cd7 100644 --- a/tokio/tests/udp.rs +++ b/tokio/tests/udp.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::UdpSocket; diff --git a/tokio/tests/uds_cred.rs b/tokio/tests/uds_cred.rs index 0b8cb79a156..c02b2aee4a7 100644 --- a/tokio/tests/uds_cred.rs +++ b/tokio/tests/uds_cred.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] -#![cfg(not(target_os = "dragonfly"))] +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(all(unix, not(target_os = "dragonfly")))] use tokio::net::UnixStream; diff --git a/tokio/tests/uds_datagram.rs b/tokio/tests/uds_datagram.rs index 51697b1af1c..504ede520de 100644 --- a/tokio/tests/uds_datagram.rs +++ b/tokio/tests/uds_datagram.rs @@ -1,37 +1,11 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] use tokio::net::unix::*; use std::io; -// struct StringDatagramCodec; - -// /// A codec to decode datagrams from a unix domain socket as utf-8 text messages. -// impl Encoder for StringDatagramCodec { -// type Item = String; -// type Error = io::Error; - -// fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { -// dst.extend_from_slice(&item.into_bytes()); -// Ok(()) -// } -// } - -// /// A codec to decode datagrams from a unix domain socket as utf-8 text messages. -// impl Decoder for StringDatagramCodec { -// type Item = String; -// type Error = io::Error; - -// fn decode(&mut self, buf: &mut BytesMut) -> Result, Self::Error> { -// let decoded = str::from_utf8(buf) -// .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))? -// .to_string(); - -// Ok(Some(decoded)) -// } -// } - async fn echo_server(mut socket: UnixDatagram) -> io::Result<()> { let mut recv_buf = vec![0u8; 1024]; loop { diff --git a/tokio/tests/uds_split.rs b/tokio/tests/uds_split.rs index 46602d5da54..76ff4613cd2 100644 --- a/tokio/tests/uds_split.rs +++ b/tokio/tests/uds_split.rs @@ -1,5 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] #![cfg(unix)] -#![deny(warnings, rust_2018_idioms)] use tokio::net::UnixStream; use tokio::prelude::*; diff --git a/tokio/tests/uds_stream.rs b/tokio/tests/uds_stream.rs index 45ee4557587..3327959027d 100644 --- a/tokio/tests/uds_stream.rs +++ b/tokio/tests/uds_stream.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] +#![cfg(feature = "full")] #![warn(rust_2018_idioms)] +#![cfg(unix)] use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::unix::*;