首页 > 解决方案 > 我的 Cargo.toml 显示一些带有错误的红线无法编译 serde_derive

问题描述

我最近尝试使用 rust-lang 构建一个项目(这是我的第一个 rust 项目,我的老板支持我在公司使用新技术)。但是,我的 Cargo.toml 突然出现了一些红线:

could not compile `serde_derive`.
error: could not compile `async-trait`.

To learn more, run the command again with --verbose.
error: could not compile `rand_chacha`.

To learn more, run the command again with --verbose.
error: could not compile `proc-macro-hack`.

To learn more, run the command again with --verbose.
error: could not compile `diesel_derives`.

To learn more, run the command again with --verbose.

我运行命令 Cargo Run 并且我的项目运行良好,但是这些红线阻止我跟踪项目中其他代码的错误(因此,如果代码中有错误,它不会显示,因为仍然存在另一个文件中的一些错误,它是 Cargo.toml)

我正在使用 cargo 1.43.0-nightly (bda50510d 2020-03-02)、rustc 1.43.0-nightly (c20d7eecb 2020-03-11) 和 vs code 1.43 版本。

这是我的 Cargo.toml :

[package]
name = "app_base"
version = "0.1.0"
authors = ["yonathan"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rocket = "0.4.3"
rocket_codegen = "0.4.3"
rocket_contrib = "0.4.3"
rocket_http = "0.4.3"
cookie = "0.11.2"
rocket-json-response = "0.5.10"
diesel = { version = "1.4.3", features = ["postgres"] }
dotenv = "0.15.0"
postgres = { version = "0.17.2", features = ["with-chrono-0_4"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
json-gettext = "3.1.7"
debug-helper = "0.3.8"
serializers  = "0.2.3"
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }
chrono = "0.4"

标签: rustrust-cargo

解决方案


由于这是一个 RLS(rust 语言服务器)错误 [显然已关闭,请参见此处],因此可以使用rust-analyzer扩展名 [此处的网站] 作为临时替代方案。

要安装扩展,您可以启动 VSCode,单击Extensions左侧的选项卡并rust-analyzer在 Marketplace 中搜索。

请注意,如网站上所述[截至 04/01/2020],该项目仍处于ALPHA中,这意味着它可能容易损坏。


推荐阅读