Getting the type of the expression under my cursor?


I’d like to be able to run rustc --type-at-pos file/ 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.


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


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


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

  • 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: