Hello I just started coding with Rust today so please forgive my lack of knowledge. I followed the "Getting Started" portion on the main website with regards to using dependencies. The code here compiles and runs successfully, but in VS Code it shows I have an error: "can't find crate for ferris_says
".
Is there something I can do to fix it?
I'm not sure if this is it, but there isn't really a need to use an extern crate
directive any more; after rust 1.32
it's been updated to just need to
use ferris_says::say;
and no longer need the extern crate
. (On any crate, other than macro crates, but that's a special case.
Thanks for the reply. Unfortunately that too returns a parser error: "use of undeclared type or module". Builds and runs fine but VS thinks it's wrong.
Have you tried restarting RLS? I think it's Ctrl+Shift+P, then search for "Restart RLS" in the list. RLS is... dodgy at the best of times, and sometimes it just straight-up doesn't notice a crate has been added.
3 Likes
Hmm, that seems to be an error with VSCode then, or maybe the extension, or most likely the version of rust/rls (R ust L anguage S erver). Would you mind providing the output of
rustc -V
(In a shell of some sort)
Restarting RLS via your instructions worked! Thanks for the help.
No problem. I have to use that command so often, when I hit Ctrl+Shift+P, it's literally the first thing VS Code suggests.
1 Like