全部。我正在运行 VSCodium 版本 1.85.2、rustc 和 rust-analyzer 1.76.0 以及 rust-analyzer Visual Studio Code 扩展版本 0.3.1839。
扩展程序部分运行。例如,我从以下代码中收到语法错误:
fn main() {
let answer = current_favorite_color();
println!("My current favorite color is {}", answer);
}
this doesn't belong here
fn current_favorite_color() -> String {
String::from("blue")
}
它正确地产生了 14 个“问题”,包括:
Syntax Error: expected BANG rust-analyzer (syntax-error)
Syntax Error: expected `{`, `[`, `(` rust-analyzer (syntax-error)
Syntax Error: expected SEMICOLON rust-analyzer (syntax-error)
但是,当我尝试输入实际的 rust 代码时,按
^-spacebar
只能得到“abc”建议。因此,例如,我希望在上面的代码中输入 answer.
,然后输入 ^-spacebar
(假设我首先删除无效代码)以获得包含 trim
函数的列表。
我需要做什么才能使其正常工作?谢谢!
rustlings
cli 工具有一个命令可以让 rust-analyzer 在练习文件夹上工作。
rustlings lsp
它将创建一个
rust-project.json
文件
他们的README中提到了这一点。