Skip to content

Commit d0d8707

Browse files
authored
Fix sometimes-unused dependencies (#603)
`tower` currently has required dependencies that may not be used unless certain features are enabled. This change updates `tower` to make these dependencies optional. Furthermore, this change removes use of `html_root_url`, which is no longer recommended (rust-lang/api-guidelines#230), and updates the documented release instructions.
1 parent 7f004da commit d0d8707

File tree

8 files changed

+23
-29
lines changed

8 files changed

+23
-29
lines changed

tower-layer/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[package]
22
name = "tower-layer"
33
# When releasing to crates.io:
4-
# - Remove path dependencies
5-
# - Update html_root_url.
64
# - Update doc url
75
# - Cargo.toml
86
# - README.md

tower-layer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![doc(html_root_url = "https://docs.rs/tower-layer/0.3.1")]
21
#![warn(
32
missing_debug_implementations,
43
missing_docs,

tower-service/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[package]
22
name = "tower-service"
33
# When releasing to crates.io:
4-
# - Remove path dependencies
5-
# - Update html_root_url.
64
# - Update doc url
75
# - Cargo.toml
86
# - README.md

tower-service/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![doc(html_root_url = "https://docs.rs/tower-service/0.3.1")]
21
#![warn(
32
missing_debug_implementations,
43
missing_docs,

tower-test/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[package]
22
name = "tower-test"
33
# When releasing to crates.io:
4-
# - Remove path dependencies
5-
# - Update html_root_url.
64
# - Update doc url
75
# - Cargo.toml
86
# - README.md

tower-test/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![doc(html_root_url = "https://docs.rs/tower-test/0.4.0")]
21
#![warn(
32
missing_debug_implementations,
43
missing_docs,

tower/Cargo.toml

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[package]
22
name = "tower"
33
# When releasing to crates.io:
4-
# - Remove path dependencies
5-
# - Update html_root_url.
64
# - Update doc url
75
# - Cargo.toml
86
# - README.md
@@ -25,6 +23,10 @@ edition = "2018"
2523

2624
[features]
2725
default = ["log"]
26+
27+
# Internal
28+
__common = ["futures-core", "pin-project-lite"]
29+
2830
full = [
2931
"balance",
3032
"buffer",
@@ -43,30 +45,30 @@ full = [
4345
"timeout",
4446
"util",
4547
]
48+
# FIXME: Use weak dependency once available (https://github.com/rust-lang/cargo/issues/8832)
4649
log = ["tracing/log"]
47-
balance = ["discover", "load", "ready-cache", "make", "rand", "slab", "tokio-stream"]
48-
buffer = ["tokio/sync", "tokio/rt", "tokio-util", "tracing"]
49-
discover = []
50-
filter = ["futures-util"]
50+
balance = ["discover", "load", "ready-cache", "make", "rand", "slab"]
51+
buffer = ["__common", "tokio/sync", "tokio/rt", "tokio-util", "tracing"]
52+
discover = ["__common"]
53+
filter = ["__common", "futures-util"]
5154
hedge = ["util", "filter", "futures-util", "hdrhistogram", "tokio/time", "tracing"]
52-
limit = ["tokio/time", "tokio/sync", "tokio-util", "tracing"]
53-
load = ["tokio/time", "tracing"]
54-
load-shed = []
55-
make = ["tokio/io-std", "futures-util"]
56-
ready-cache = ["futures-util", "indexmap", "tokio/sync", "tracing"]
55+
limit = ["__common", "tokio/time", "tokio/sync", "tokio-util", "tracing"]
56+
load = ["__common", "tokio/time", "tracing"]
57+
load-shed = ["__common"]
58+
make = ["futures-util", "pin-project-lite", "tokio/io-std"]
59+
ready-cache = ["futures-core", "futures-util", "indexmap", "tokio/sync", "tracing"]
5760
reconnect = ["make", "tokio/io-std", "tracing"]
58-
retry = ["tokio/time"]
59-
spawn-ready = ["futures-util", "tokio/sync", "tokio/rt", "util", "tracing"]
60-
steer = ["futures-util"]
61-
timeout = ["tokio/time"]
62-
util = ["futures-util"]
61+
retry = ["__common", "tokio/time"]
62+
spawn-ready = ["__common", "futures-util", "tokio/sync", "tokio/rt", "util", "tracing"]
63+
steer = []
64+
timeout = ["pin-project-lite", "tokio/time"]
65+
util = ["__common", "futures-util", "pin-project"]
6366

6467
[dependencies]
65-
futures-core = "0.3"
66-
pin-project = "1"
6768
tower-layer = { version = "0.3.1", path = "../tower-layer" }
6869
tower-service = { version = "0.3.1", path = "../tower-service" }
6970

71+
futures-core = { version = "0.3", optional = true }
7072
futures-util = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
7173
hdrhistogram = { version = "7.0", optional = true }
7274
indexmap = { version = "1.0.2", optional = true }
@@ -76,11 +78,13 @@ tokio = { version = "1", optional = true, features = ["sync"] }
7678
tokio-stream = { version = "0.1.0", optional = true }
7779
tokio-util = { version = "0.6.3", default-features = false, optional = true }
7880
tracing = { version = "0.1.2", default-features = false, features = ["std"], optional = true }
79-
pin-project-lite = "0.2.7"
81+
pin-project = { version = "1", optional = true }
82+
pin-project-lite = { version = "0.2.7", optional = true }
8083

8184
[dev-dependencies]
8285
futures = "0.3"
8386
hdrhistogram = "7.0"
87+
pin-project-lite = "0.2.7"
8488
tokio = { version = "1", features = ["macros", "sync", "test-util", "rt-multi-thread"] }
8589
tokio-stream = "0.1"
8690
tokio-test = "0.4"

tower/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![doc(html_root_url = "https://docs.rs/tower/0.4.11")]
21
#![warn(
32
missing_debug_implementations,
43
missing_docs,

0 commit comments

Comments
 (0)