Commit 44714a9
substrate-prometheus-endpoint: directly require the feature "tokio/net" (#9355)
The crate `substrate-prometheus-endpoint` use tokio items given by the
feature "net" but it doesn't explictly requires it in the `Cargo.toml`.
It compiles on master because `hyper-util` enables the feature
"tokio/net". But upgrading `hyper-util` break this indirect enabling.
This fix the issue by directly setting "net" feature as required, as it
is used.
We should also backport this ideally. It is not a breaking change given
the code doesn't compile without the feature and only compiles if
indirectly enabled by another crate.
# Reproduce:
To reproduce do `cargo update -p hyper-util && cargo check -p
substrate-prometheus-endpoint`:
You will get the error:
```
error[E0433]: failed to resolve: could not find `TcpListener` in `net`
--> substrate/utils/prometheus/src/lib.rs:89:29
|
89 | let listener = tokio::net::TcpListener::bind(&prometheus_addr).await.map_err(|e| {
| ^^^^^^^^^^^ could not find `TcpListener` in `net`
|
note: found an item that was configured out
--> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:43:28
|
43 | pub use tcp::listener::TcpListener;
| ^^^^^^^^^^^
note: the item is gated behind the `net` feature
--> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:38:1
|
38 | / cfg_net! {
39 | | mod lookup_host;
40 | | pub use lookup_host::lookup_host;
... |
51 | | }
52 | | }
| |_^
= note: this error originates in the macro `cfg_net` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
20 + use std::net::TcpListener;
|
help: if you import `TcpListener`, refer to it directly
|
89 - let listener = tokio::net::TcpListener::bind(&prometheus_addr).await.map_err(|e| {
89 + let listener = TcpListener::bind(&prometheus_addr).await.map_err(|e| {
|
error[E0412]: cannot find type `TcpListener` in module `tokio::net`
--> substrate/utils/prometheus/src/lib.rs:99:24
|
99 | listener: tokio::net::TcpListener,
| ^^^^^^^^^^^ not found in `tokio::net`
|
note: found an item that was configured out
--> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:43:28
|
43 | pub use tcp::listener::TcpListener;
| ^^^^^^^^^^^
note: the item is gated behind the `net` feature
--> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:38:1
|
38 | / cfg_net! {
39 | | mod lookup_host;
40 | | pub use lookup_host::lookup_host;
... |
51 | | }
52 | | }
| |_^
= note: this error originates in the macro `cfg_net` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
20 + use std::net::TcpListener;
|
help: if you import `TcpListener`, refer to it directly
|
99 - listener: tokio::net::TcpListener,
99 + listener: TcpListener,
|
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `substrate-prometheus-endpoint` (lib) due to 2 previous errors
```
---------
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <[email protected]>
(cherry picked from commit fb451c7)1 parent d4a1adc commit 44714a9
2 files changed
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments