Type Lookup in IDE

I code Rust in Visual Studio Code. I have Rust Official extension. When I direct mouse over some keyword then I get some documentation popup.

But I what I often really liked to see is type of variable when I direct mouse over it. e.g. String, str, [u8], Result<String, Box>, etc

Sometimes I can see variable type when I try to build code and it prints error in terminal. But it is not the same.

Apologies if you are hardcore VS Code with no intention to switch.

I find IntelliJ's handling of type inference to be amazing. It displays inferred types (local variables, args to | ... | { ... }'s) in blue as some type of "label" (so you can see it, but the cursor skips over it when navigating).

2 Likes

I don’t know if the official rust extension can offer what you want since I never really used it myself. You might like to try out Rust analyzer as an alternative; works great with vscode and does definitely offer type information when hovering over variables (or any kind of expression for that matter).

5 Likes

I found rust-analyzer very helpful comparing to default extension but it was not catching most of my projects in sub-directories
I added entry to settings.json

"rust-analyzer.linkedProjects": [
"/Users/userx/src....proj1/Cargo.toml",
"/Users/userx/src....proj2/Cargo.toml"
]

loadOutDirsFromCheck - was not helpful.