That’s not how it’s supposed to be.
but for example Vec::new() doesn’t highlight anything at all.
If I do Vec::new(foo, bar)
, I get expected 0 arguments, found 2 (rust-analyzer E0107)
.
but things like passing too many arguments into the println macro doesn’t throw an error.
I don’t get that either, but I’m still running with the Vim configuration I setup on my previous PC from 2011, where I turned off checks that require calling cargo check
or cargo clippy
in the background. From what I remember, a properly functioning default rust-analyzer config should pick up and display anything cargo check
will catch and you can switch it to cargo clippy
for even stricter results.
Or how shown in this example, it did not autocomplete the clone method, while also just accepting .clo; at the end of a String (it also didn’t autocomplete “String”).
I get clone()
, clone_into()
, and clone_from()
as proposed completions for .clo
on my as-you-type completions for foo
where let foo = String::new();
and it proposed a whole bunch of things, with String
at the top when I typed Stri
. (eg. the stringify!
macro, OsString
, mixed in with various results from other crates in the project like serde
)
Ahh, yeah. In the beginning, Rust was built around the idea that individual files and invoking
rustc
are internal details, only relevant for integration into some other build system like Bazel, and that “normal” Rust projects need to be inside a Cargo project structure.There is in-development work to have official support for something along the lines of rust-script, but it’s still just that… in development. If you want to keep an eye on it, here is the tracking issue.