@@ -543,14 +543,11 @@ The `rustfmt` tool reformats your code according to the community code style.
543543Many collaborative projects use ` rustfmt ` to prevent arguments about which
544544style to use when writing Rust: everyone formats their code using the tool.
545545
546- To install ` rustfmt ` , enter the following:
547-
548- ```
549- $ rustup component add rustfmt
550- ```
551-
552- This command gives you ` rustfmt ` and ` cargo-fmt ` , similar to how Rust gives you
553- both ` rustc ` and ` cargo ` . To format any Cargo project, enter the following:
546+ Rust installations include ` rustfmt ` by default, so you should already have the
547+ programs ` rustfmt ` and ` cargo-fmt ` on your system. These two commands are
548+ analogous to ` rustc ` and ` cargo ` in that ` rustfmt ` allows finer-grained control
549+ and ` cargo-fmt ` understands conventions of a project that uses Cargo. To format
550+ any Cargo project, enter the following:
554551
555552```
556553$ cargo fmt
@@ -562,9 +559,9 @@ on `rustfmt`, see its documentation at *https://github.com/rust-lang/rustfmt*.
562559
563560### Fix Your Code with rustfix
564561
565- The rustfix tool is included with Rust installations and can automatically fix
562+ The ` rustfix ` tool is included with Rust installations and can automatically fix
566563compiler warnings that have a clear way to correct the problem that’s likely
567- what you want. It’s likely you’ve seen compiler warnings before. For example,
564+ what you want. You’ve probably seen compiler warnings before. For example,
568565consider this code:
569566
570567Filename: src/main.rs
@@ -576,8 +573,8 @@ fn main() {
576573}
577574```
578575
579- Here, we’re defining variable ` x ` as mutable, but we never actually mutate it.
580- Rust warns us about that:
576+ Here, we’re defining the variable ` x ` as mutable, but we never actually mutate
577+ it. Rust warns us about that:
581578
582579```
583580$ cargo build
@@ -615,21 +612,16 @@ fn main() {
615612}
616613```
617614
618- The ` x ` variable is now immutable, and the warning no longer appears.
615+ The variable ` x ` is now immutable, and the warning no longer appears.
619616
620617You can also use the ` cargo fix ` command to transition your code between
621618different Rust editions. Editions are covered in Appendix E at * appendix-05-editions.md* .
622619
623620### More Lints with Clippy
624621
625622The Clippy tool is a collection of lints to analyze your code so you can catch
626- common mistakes and improve your Rust code.
627-
628- To install Clippy, enter the following:
629-
630- ```
631- $ rustup component add clippy
632- ```
623+ common mistakes and improve your Rust code. Clippy is included with standard
624+ Rust installations.
633625
634626To run Clippy’s lints on any Cargo project, enter the following:
635627
@@ -640,7 +632,7 @@ $ cargo clippy
640632For example, say you write a program that uses an approximation of a
641633mathematical constant, such as pi, as this program does:
642634
643- Filename: src/main.rs
635+ src/main.rs
644636
645637```
646638fn main() {
@@ -650,6 +642,8 @@ fn main() {
650642}
651643```
652644
645+
646+
653647Running ` cargo clippy ` on this project results in this error:
654648
655649```
@@ -666,10 +660,11 @@ error: approximate value of `f{32, 64}::consts::PI` found
666660
667661This error lets you know that Rust already has a more precise ` PI ` constant
668662defined, and that your program would be more correct if you used the constant
669- instead. You would then change your code to use the ` PI ` constant. The
670- following code doesn’t result in any errors or warnings from Clippy:
663+ instead. You would then change your code to use the ` PI ` constant.
671664
672- Filename: src/main.rs
665+ The following code doesn’t result in any errors or warnings from Clippy:
666+
667+ src/main.rs
673668
674669```
675670fn main() {
@@ -679,19 +674,21 @@ fn main() {
679674}
680675```
681676
677+
678+
682679For more information on Clippy, see its documentation at * https://github.com/rust-lang/rust-clippy * .
683680
684681### IDE Integration Using rust-analyzer
685682
686- To help IDE integration, the Rust community recommends using
683+ To help with IDE integration, the Rust community recommends using
687684` rust-analyzer ` . This tool is a set of
688- compiler-centric utilities that speaks the Language Server Protocol, which is a specification for IDEs and programming languages to
685+ compiler-centric utilities that speak Language Server Protocol, which is a specification for IDEs and programming languages to
689686communicate with each other. Different clients can use ` rust-analyzer ` , such as
690687the Rust analyzer plug-in for Visual Studio Code at * https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer * .
691688
692689Visit the ` rust-analyzer ` project’s home page
693690for installation instructions, then install the language server support in your
694- particular IDE. Your IDE will gain abilities such as autocompletion, jump to
691+ particular IDE. Your IDE will gain capabilities such as autocompletion, jump to
695692definition, and inline errors.
696693
697694## Appendix E - Editions
0 commit comments