Skip to content

Commit 333c580

Browse files
authored
Merge pull request #3052 from scampi/contributing
added a note about the use of the RUST_LOG environment variable
2 parents 2bcc3a9 + d681d5f commit 333c580

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Contributing.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ would need a configuration file named `test-indent.toml` in that directory. As a
6464
example, the `issue-1111.rs` test file is configured by the file
6565
`./tests/config/issue-1111.toml`.
6666

67+
## Debugging
68+
69+
Some `rewrite_*` methods use the `debug!` macro for printing useful information. These messages can be printed by using the environment variable `RUST_LOG=rustfmt=DEBUG`. These traces can be helpful in understanding which part of the code was used and get a better grasp on the execution flow.
6770

6871
## Hack!
6972

@@ -153,6 +156,8 @@ which is how much we are currently indented from the lhs of the page. We also
153156
take a context which contains information used for parsing, the current block
154157
indent, and a configuration (see below).
155158

159+
##### Rewrite and Indent
160+
156161
To understand the indents, consider
157162

158163
```
@@ -195,6 +200,8 @@ checked subtraction: `available_space = budget.checked_sub(overhead)?`.
195200
`checked_sub` returns an `Option`, and if we would underflow `?` returns
196201
`None`, otherwise we proceed with the computed space.
197202

203+
##### Rewrite of list-like expressions
204+
198205
Much syntax in Rust is lists: lists of arguments, lists of fields, lists of
199206
array elements, etc. We have some generic code to handle lists, including how to
200207
space them in horizontal and vertical space, indentation, comments between
@@ -203,6 +210,8 @@ code is a bit complex. Look in [src/lists.rs](src/lists.rs). `write_list` is the
203210
and `ListFormatting` the key structure for configuration. You'll need to make a
204211
`ListItems` for input, this is usually done using `itemize_list`.
205212

213+
##### Configuration
214+
206215
Rustfmt strives to be highly configurable. Often the first part of a patch is
207216
creating a configuration option for the feature you are implementing. All
208217
handling of configuration options is done in [src/config/mod.rs](src/config/mod.rs). Look for the

0 commit comments

Comments
 (0)