VSCode, Rust, debugging

I'm learning Rust and I'm trying to configure VSCode.

First off, Some people recommend to use the extension rust-analyzer instead of the official extension, but when I use it, in my IDE and for some files I see this warning(?) file not included in module tree I don't know what it means and how to fix it.

Second, I'm reading The Rust programming language book, so I created a project (package?) where I created sub-directories into src directory, every sub-directory contains RS files to be run individually. I'm using Code Runner extension for that purpose without any problems. Now I'm trying to debug every file separately so I installed codelldb extension. When debugging the IDE recognizes the main.rs under src directory only, and not my target file (for example, helloworld.rs) located in another sub-directory. How should I configure my launch.json file for such goal?

Third, I come from Dart and it has beautiful features in the IDE like showing which libraries need to be imported for that command being typed, and showing errors in real-time (not after some seconds o when you save the file). Does Rust have these features on the IDE?

Fourth, I have installed Bracket Pair Colorized extension, but it seems to be deactivated when rust or rust-analyzer extension are enabled, how to fix it?

1 and 2: Read through CH07 of the Book. Each toplevel module has to be declared from main.rs or lib.rs. If you have a folder, you either need a toplevel .rs file with the same name as the folder, or a mod.rs file within the folder. Examples:

// main.rs
mod types;
  1. Yep, rust-analyzer handles this from what I understand. Anything in the standard library or imported as a dependency crate in your Cargo.toml will be detected as you type, importing proper module types/functions/etc where necessary. It will not detect non-imported crates and ask you if you want to import them however. You'll want to identify the crate on your own.
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.