3 Rust tooling

 

This chapter covers:

  • Introducing core Rust language tools:
    • RLS (Rust language server)
    • rust-analyzer
    • Rustfmt
    • Clippy
    • sccache
  • Integrating Rust tools with VS Code
  • Using stable versus nightly toolchains
  • Exploring additional non-core tools you may find useful

Rust has a number of tools available to improve productivity and reduce the amount of busywork one must engage in to produce high quality software. Rust’s compiler, rustc, is built upon LLVM, so Rust inherits the features provided by LLVM, such as LLVM’s debugger, LLDB. In addition to the tools you expect to find from other languages, Rust includes a number of its own Rust-specific tools, which are discussed in this chapter.

The core tools discussed in this chapter are RLS, rust-analyzer, rustfmt, Clippy, and sccache. These are tools you’ll likely use every time you work with Rust. Additionally, I have included instructions for a few other tools, which you may find yourself using occasionally: cargo-update, cargo-expand, cargo-fuzz, cargo-watch, and cargo-tree.

3.1 Overview of Rust tooling

3.2 Using Rust Language Server (RLS) for Rust IDE integration

3.2.1 Installing RLS

3.3 Using rust-analyzer for Rust IDE integration

3.3.1 Magic completions

3.4 Using rustfmt to keep code tidy

3.4.1 Installing rustfmt

3.4.2 Configuring rustfmt

3.5 Using Clippy to improve code quality

3.5.1 Installing Clippy

3.5.2 Clippy’s lints

3.5.3 Configuring Clippy

3.5.4 Automatically applying Clippy’s suggestions

3.5.5 Using Clippy in CI/CD

3.6 Reducing compile times with sccache

3.6.1 Installing sccache

3.6.2 Configuring sccache

3.7 Integration with IDEs, including VS Code

3.8 Using toolchains: stable vs nightly