如何知道哪个包 Rust 编译失败?
How to know which package failed Rust compilation?
我的 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
我不明白是哪个包依赖链导致了这个编译错误:
为什么要编译socket2 v0.4.0
?我不知道哪个包需要它。我想查看导致 socket2
的依赖链,以了解要降低哪个包的版本以使其编译。
如果我尝试写:
socket2 = "<0.4.0"
它不会阻止cargo
构建socket2 v0.4.0
。因此,它通过 Cargo.toml
中某物的依赖链构建。我认为在实践中没有足够简单的方法来查看完整链。
理想情况下,我想要一个程序,它会自动尝试减少已用软件包的版本,直到它变得可编译为止。那么?
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.
这可以通过 运行 cargo tree -i socket2
(you may have to install the subcommand separately 在较旧的工具链上看到),对我来说看起来像这样:
socket2 v0.4.0
└── hyper v0.14.7
└── warp v0.3.1
└── tests v0.1.0 (C:\Users\kmdreko\Projects\rust-tests)
您可以尝试 warp = "0.2"
而不是 "0.3"
。
我的 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
我不明白是哪个包依赖链导致了这个编译错误:
为什么要编译socket2 v0.4.0
?我不知道哪个包需要它。我想查看导致 socket2
的依赖链,以了解要降低哪个包的版本以使其编译。
如果我尝试写:
socket2 = "<0.4.0"
它不会阻止cargo
构建socket2 v0.4.0
。因此,它通过 Cargo.toml
中某物的依赖链构建。我认为在实践中没有足够简单的方法来查看完整链。
理想情况下,我想要一个程序,它会自动尝试减少已用软件包的版本,直到它变得可编译为止。那么?
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 tosocket2
to know whose package's version to lower to make it compile.
这可以通过 运行 cargo tree -i socket2
(you may have to install the subcommand separately 在较旧的工具链上看到),对我来说看起来像这样:
socket2 v0.4.0
└── hyper v0.14.7
└── warp v0.3.1
└── tests v0.1.0 (C:\Users\kmdreko\Projects\rust-tests)
您可以尝试 warp = "0.2"
而不是 "0.3"
。