rustdependenciesrust-cargo

How to know which package failed Rust compilation?


I have dependencies in my Cargo.toml that fail compilation due to using too new language features.

I am trying to address it by lowering dependency versions, but I'm having trouble understanding whose package's version I need to lower. Here is my Cargo.toml:

[package]
name = "..."
version = "0.1.0"
authors = ["..."]
edition = "2018"

[dependencies]
tokio = { version = "<0.3.0", features = ["macros", "sync"] }
warp = ">=0.0.0"
error[E0658]: `match` is not allowed in a `const fn`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/lib.rs:156:9
    |
156 | /         match address {
157 | |             SocketAddr::V4(_) => Domain::IPV4,
158 | |             SocketAddr::V6(_) => Domain::IPV6,
159 | |         }
    | |_________^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/49146

I do not understand which chain of package dependencies caused this compilation error. Why was socket2 v0.4.0 compiled? I don't know which package requires it. I want to see the chain of dependencies that led to socket2 to know whose package's version to lower to make it compile.

If I try to write:

socket2 = "<0.4.0"

it does not prevent cargo from building socket2 v0.4.0. So it build through a chain of dependencies from something in Cargo.toml. I see no easy enough to use in practice way to see the full chain.

Ideally, I would want a program that would automatically try to reduce versions of used packages till it becomes compilable.


Solution

  • Why was socket2 v0.4.0 compiled? I don't know which package requires it. I want to see the chain of dependencies that led to socket2 to know whose package's version to lower to make it compile.

    This can be seen by running cargo tree -i socket2 (you may have to install the subcommand separately on older toolchains), which for me looks like this:

    socket2 v0.4.0
    └── hyper v0.14.7
        └── warp v0.3.1
            └── tests v0.1.0 (C:\Users\kmdreko\Projects\rust-tests)
    

    You can try out warp = "0.2" instead of "0.3".