Description
I am trying to use a crate that depends on trust-dns-proto
which has tokio listed as an optional dependency: https://github.com/bluejekyll/trust-dns/blob/0.19.4/crates/proto/Cargo.toml#L77 tokio = { version = "0.2.16", optional = true }
When compiling a simple test project with the Cargo.toml file below, it works as expected as long as I am using the standard Rust crates.io registry. However, when I try to use an external file system registry created by https://github.com/ChrisGreenaway/cargo-local-registry I receive a compile error.
Error example:
error[E0433]: failed to resolve: use of undeclared type or module `tokio`
--> /home/[email protected]/.cargo/registry/src/-7c1c43276983337d/trust-dns-proto-0.19.4/src/lib.rs:25:5
|
25 | use tokio::runtime::Runtime;
| ^^^^^ use of undeclared type or module `tokio`
I ran the cargo tree
command and have attached the two output files. As you can see, the tree_output_cratesio.txt
file listed the tokio
crate as a dependency of trust-dns-proto
while the tree_output_external_reg.txt
file does not list the tokio
crate. I have tried multiple variations in my Cargo.toml
file to make sure the tokio-runtime
feature is selected and from what I can tell, it is being selected since the line of code that imports the tokio::runtime::Runtime
line is being executed but for some reason when using an external registry the optional tokio package is not being added in.
I have used the external registry for several months and use other crates that have optional dependencies on other crates like serde
, etc.. and those work as expected. I am not sure why I am seeing this behavior.
Meta
rustc --version --verbose
:
rustc 1.44.0 (49cae5576 2020-06-01)
binary: rustc
commit-hash: 49cae55760da0a43428eba73abcb659bb70cf2e4
commit-date: 2020-06-01
host: x86_64-unknown-linux-gnu
release: 1.44.0
LLVM version: 9.0
Cargo.toml example:
[package]
name = "tester"
version = "0.1.0"
edition = "2018"
[dependencies]
tokio = {version = "0.2.21", features = ["full"]}
trust-dns-proto = {version = "=0.19.4", default-features = false, features = ["tokio-runtime"]}