Skip to content

Commit 70f56e9

Browse files
committed
Add a general introduction to the rustfix library docs.
1 parent 402d072 commit 70f56e9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/rustfix/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
//! Library for applying diagnostic suggestions to source code.
2+
//!
3+
//! This is a low-level library. You pass it the JSON output from `rustc`, and
4+
//! you can then use it to apply suggestions to in-memory strings. This
5+
//! library doesn't execute commands, or read or write from the filesystem.
6+
//!
7+
//! If you are looking for the [`cargo fix`] implementation, the core of it is
8+
//! located in [`cargo::ops::fix`].
9+
//!
10+
//! [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
11+
//! [`cargo::ops::fix`]: https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/fix.rs
12+
//!
13+
//! The general outline of how to use this library is:
14+
//!
15+
//! 1. Call `rustc` and collect the JSON data.
16+
//! 2. Pass the json data to [`get_suggestions_from_json`].
17+
//! 3. Create a [`CodeFix`] with the source of a file to modify.
18+
//! 4. Call [`CodeFix::apply`] to apply a change.
19+
//! 5. Write the source back to disk.
20+
121
use std::collections::HashSet;
222
use std::ops::Range;
323

0 commit comments

Comments
 (0)