Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default all feature flags to off #1811

Merged
merged 11 commits into from
Nov 22, 2019
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>> {
let addr = "127.0.0.1:8080".parse::<SocketAddr>()?;
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?;
Expand All @@ -77,14 +75,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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;
}
}
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pr: ["master"]

variables:
RUSTFLAGS: -Dwarnings
nightly: 2019-11-16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why what?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we now pinning the nightly?


jobs:
# Test top level crate
Expand Down
16 changes: 0 additions & 16 deletions ci/azure-test-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,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 }}

jonhoo marked this conversation as resolved.
Show resolved Hide resolved
# Run with all crate features
- script: cargo test --all-features
env:
Expand All @@ -54,14 +46,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:
Expand Down
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
4 changes: 4 additions & 0 deletions tests-integration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use doc_comment::doc_comment;

// #[doc = include_str!("../../README.md")]
doc_comment!(include_str!("../../README.md"));
2 changes: 1 addition & 1 deletion tokio-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tokio-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ 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"
Expand Down
2 changes: 2 additions & 0 deletions tokio-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
11 changes: 11 additions & 0 deletions tokio-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand All @@ -36,3 +46,4 @@ futures = "0.3.0"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
19 changes: 19 additions & 0 deletions tokio-util/src/cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
macro_rules! cfg_codec {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does tokio-util need these helpers when none of the other crates (afaict) do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokio needs the helpers too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, tokio-util is kind of under developed ATM. We may want it to be tokio-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
)*
}
}
13 changes: 11 additions & 2 deletions tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions tokio-util/src/udp/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> {
socket: UdpSocket,
Expand Down
8 changes: 5 additions & 3 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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"]
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -123,6 +124,7 @@ futures = { version = "0.3.0", features = ["async-await"] }
loom = { version = "0.2.13", features = ["futures", "checkpoint"] }
proptest = "0.9.4"
tempfile = "3.1.0"
doc-comment = "0.3.1"
carllerche marked this conversation as resolved.
Show resolved Hide resolved

[package.metadata.docs.rs]
all-features = true
Expand Down
9 changes: 9 additions & 0 deletions tokio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
carllerche marked this conversation as resolved.
Show resolved Hide resolved
//! 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
Expand Down
2 changes: 2 additions & 0 deletions tokio/tests/_require_full.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![cfg(not(feature = "full"))]
compile_error!("run main Tokio tests with `--features full`");
1 change: 1 addition & 0 deletions tokio/tests/buffered.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::net::TcpListener;
use tokio::prelude::*;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_dir.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::fs;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::fs::File;
use tokio::prelude::*;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_file_mocked.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

macro_rules! ready {
($e:expr $(,)?) => {
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_link.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::fs;

Expand Down
3 changes: 3 additions & 0 deletions tokio/tests/io_async_read.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_chain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_copy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_driver.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_driver_drop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_lines.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncBufReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_exact.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncBufReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_to_end.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_to_string.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_until.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncBufReadExt;
use tokio_test::assert_ok;
Expand Down
3 changes: 3 additions & 0 deletions tokio/tests/io_split.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};

use std::io;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_take.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_write.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_write_all.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
Expand Down
Loading