Getting the type of the expression under my cursor?

I'd like to be able to run rustc --type-at-pos file/path.rs:line:col and get the type of the expression beneath that position. Does it already exist, or are there plans to build it? Should I file a GitHub issue?

Ah, this is probably more of a job for Racer than rustc.

I know RLS has it (or if it's some other part of the Visual Studio Code plugin). I guess you could try to set it up if your editor works with the language server protocol.

1 Like

Thanks! This is exactly the kind of project I'm looking for.

1 Like

Have to say the type info from Intellij idea's rust plugin is pretty good as well

1 Like

Does IntelliJ not just use RLS under the hood? Looks like VSCode just asks RLS for type information; I'd assume IntelliJ does the same.

They do their own thing actually, see https://intellij-rust.github.io/docs/faq.html

2 Likes
  • Visual Studio Code supports this with the official Rust extension.
  • Atom supports this with autocomplete-racer, or Atom 1.21 with the tokamak IDE.

Seems to work for (neo)vim as well: https://www.reddit.com/r/rust/comments/72a1p4/how_the_rls_rust_language_server_works/dnha0s4/.