English 中文(简体)
为什么不寻找工作空间成员的依赖?
原标题:Why is rust-analyzer not finding dependencies in workspace member?

我有一个货物工作空间,有一间图书馆“/射线”和一个双筒“。 两名工作空间成员有不同的属地。

/raytracing/Cargo.toml:

[package]
name = "raytracer"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "0.8.5"

/cli/Cargo.toml:

[package]
name = "cli"
version = "0.1.0"
edition = "2021"

[dependencies]
raytracer = {path = "../raytracer"}
rand = "0.8.5"
rand_xorshift = "0.3.0"

父母名录 货物:toml(Cargo.toml)

[package]
edition = "2021"
name = "raytracing"
version = "0.1.0"

[workspace]
members = [
    "raytracer",
    "cli",
]

[[bin]]
path = "cli/src/main.rs"
name = "cli"

Compiling both the raytracer and cli packages using cargo build -p works, however in VSCode rust-analyzer complains about my dependencies in the ./cli package when I import them in main.rs: Error

最佳回答

根据您目前的设置,您实际上拥有从同一来源档案中汇编的两本书:一份来自/cli/Cargo.toml,一份来自./Cargo.toml。 当然,你在试图汇编一种双轨形式时,重犯了错误。 你没有解释你试图实现的目标,因此,我可以告诉你解决这一问题的正确方法。 总的来说,你可以做两件事:

  • Make the root package virtual by deleting everything from ./Cargo.toml except the [workspace] section. (normal)
  • Ditch the ./cli/Cargo.toml and move its [dependencies] section to ./Cargo.toml. (bit weird)
问题回答

暂无回答




相关问题
Creating an alias for a variable

I have the following code in Rust (which will not compile but illustrates what I am after). For readability purposes, I would like to refer the same string with two different names so that the name of ...

Rust Visual Studio Code code completion not working

I m trying to learn Rust and installed the Rust extension for VSCode. But I m not seeing auto-completions for any syntax. I d like to call .trim() on String but I get no completion for it. I read that ...

热门标签