简体   繁体   English

怎么知道哪个package Rust 编译失败?

[英]How to know which package failed Rust compilation?

I have dependencies in my Cargo.toml that fail compilation (because of using too new language features).我的Cargo.toml中有编译失败的依赖项(因为使用了太新的语言功能)。

I am trying to solve the trouble by lowering dependency packages versions.我试图通过降低依赖包版本来解决这个问题。

But trying to do it, I also have a trouble to understand whose package's version I need to lower:但是尝试这样做,我也很难理解我需要降低谁的包版本:

Here is my Cargo.toml :这是我的Cargo.toml

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

[dependencies]
tokio = { version = "<0.3.0", features = ["macros", "sync"] }
warp = ">=0.0.0"
...
   Compiling socket2 v0.4.0
     Running `rustc --crate-name socket2 --edition=2018 /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=d227fc33c8864b39 -C extra-filename=-d227fc33c8864b39 --out-dir /home/user/Projects/GoldFever/exchange-server-rust/target/debug/deps -L dependency=/home/user/Projects/GoldFever/exchange-server-rust/target/debug/deps --extern libc=/home/user/Projects/GoldFever/exchange-server-rust/target/debug/deps/liblibc-f603594c75a963a0.rmeta --cap-lints allow`
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:我不明白 package 依赖项的哪个链导致了这个编译错误:

Why was socket2 v0.4.0 compiled?为什么要编译socket2 v0.4.0 I don't know which package requires it.我不知道哪个 package 需要它。 I want to see the chain of dependencies that led to socket2 to know whose package's version to lower to make it compile.我想查看导致socket2知道要降低哪个包的版本以使其编译的依赖链。

If I try to write:如果我尝试写:

socket2 = "<0.4.0"

it does not prevent cargo to build socket2 v0.4.0 .不会阻止cargo构建socket2 v0.4.0 So it build through a chain of dependencies from something in Cargo.toml .所以它是通过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.理想情况下,我想要一个程序,它会自动尝试减少使用过的包的版本,直到它变得可编译。 So?所以?

Why was socket2 v0.4.0 compiled?为什么要编译socket2 v0.4.0 I don't know which package requires it.我不知道哪个 package 需要它。 I want to see the chain of dependencies that led to socket2 to know whose package's version to lower to make it compile.我想查看导致socket2知道要降低哪个包的版本以使其编译的依赖链。

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:这可以通过运行cargo tree -i socket2来看到(您可能必须在旧工具链上单独安装子命令),对我来说看起来像这样:

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" .您可以尝试使用warp = "0.2"而不是"0.3"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM