Rust IDE Features Wishlist
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
impl
s (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 offor 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
impl
s 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:
- RFC #1317
- rustls (experimental implementation, not to be confused with the Rust TLS stack)
- rustls_vscode (VSCode extension using language server)