Skip to content

Commit c6d39a2

Browse files
authored
doc: fix instruction about running Rustfmt from source code (rust-lang#5838)
Update docs to include an example of running `rustfmt` built from src, and show how users can set the `RUSTFMT` environment variable to test `cargo-fmt` using the `rustfmt` they built from src.
1 parent b944a32 commit c6d39a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Contributing.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@ wish there weren't. You can leave `FIXME`s, preferably with an issue number.
9595

9696
You may want to run a version of rustfmt from source code as part of a test or
9797
hacking on the rustfmt codebase. It's strongly discouraged to install a version
98-
of rustfmt from source. Instead, run it using `cargo run`, and `--manifest-path`.
98+
of rustfmt from source.
99+
100+
To run `rustfmt` on a file:
101+
102+
```
103+
cargo run --bin rustfmt -- path/to/file.rs
104+
```
105+
106+
If you want to test modified `cargo-fmt`, or run `rustfmt` on the whole project (You may need to build rustfmt first):
99107

100108
```
101-
cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
109+
RUSTFMT="./target/debug/rustfmt" cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
102110
```
103111

104112
### Version-gate formatting changes

0 commit comments

Comments
 (0)