Some ideas for editor/IDE features to make working on Rust code more pleasant.

Reading code

  • Go to definition
  • Show where a function is used
  • Show documentation
  • Show type on hover

Writing code

  • Show errors/warnings inline (including those from external lints like clippy)
  • Autocomplete (stand-alone tool: racer)
  • Automatic code formatting (using rustfmt)
  • Insert the usual boilerplate code for impls (the method signatures from the trait definition)
  • Add missing imports/use statements (when they can be guessed)
  • Apply suggestions for “Did you mean …?” errors (e.g. for typos in identifier names)

Refactoring code

  • Apply suggestions from (clippy) lints (experimental tool: rustfix), e.g.:
    • Remove unneeded return statements and redundant closures
    • Replace .or_insert(Vec::new()) with .or_insert_with(Vec::new)
    • Use list.iter().enumerate instead of for i in 0..list.len()
  • Replace glob imports with a concrete list of used imported items
  • Extract impl Type into a new trait
  • Replace a function argument with a type parameter (e.g., with shortcuts for fn foo(x: i32)fn foo<T: Into<i32>>(x: T))
  • Move type definition and impls into new module (i.e., move parts of a large module into new file)
  • Move #[test] functions into a #[cfg(test)] mod test

Some of these things already work with RustyCode, the extension for VSCode I’m currently using.

The official and most promising effort for implementing the features mentioned above in a way that editor/IDE plugins can easily use them is the plan for a Rust Language Server: