Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 378994b

Browse files
committed
Add a version option
1 parent 4609252 commit 378994b

File tree

8 files changed

+41
-16
lines changed

8 files changed

+41
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "rustfmt-nightly"
44
version = "1.0.0"
55
authors = ["Nicholas Cameron <[email protected]>", "The Rustfmt developers"]
66
description = "Tool to find and fix Rust formatting issues"
7-
repository = "https://github.com/rust-lang-nursery/rustfmt"
7+
repository = "https://github.com/rust-lang/rustfmt"
88
readme = "README.md"
99
license = "Apache-2.0/MIT"
1010
build = "build.rs"

Configurations.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,22 @@ If you want to format code that requires edition 2018, add the following to your
23672367
edition = "2018"
23682368
```
23692369

2370+
## `version`
2371+
2372+
Which version of the formatting rules to use. `Version::One` is backwards-compatible
2373+
with Rustfmt 1.0. Other versions are only backwards compatible within a major
2374+
version number.
2375+
2376+
- **Default value**: `One`
2377+
- **Possible values**: `One`, `Two`
2378+
- **Stable**: No
2379+
2380+
### Example
2381+
2382+
```toml
2383+
version = "Two"
2384+
```
2385+
23702386
## `normalize_doc_attributes`
23712387

23722388
Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.

Contributing.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
There are many ways to contribute to Rustfmt. This document lays out what they
44
are and has information for how to get started. If you have any questions about
5-
contributing or need help with anything, please ping nrc on irc, #rust-dev-tools
6-
on irc.mozilla.org is probably the best channel. Feel free to also ask questions
5+
contributing or need help with anything, please ask in the WG-Rustfmt channel
6+
on [Discord](https://discordapp.com/invite/rust-lang). Feel free to also ask questions
77
on issues, or file new issues specifically to get help.
88

99
All contributors are expected to follow our [Code of
@@ -14,14 +14,6 @@ Conduct](CODE_OF_CONDUCT.md).
1414
It would be really useful to have people use rustfmt on their projects and file
1515
issues where it does something you don't expect.
1616

17-
A really useful thing to do that on a crate from the Rust repo. If it does
18-
something unexpected, file an issue; if not, make a PR to the Rust repo with the
19-
reformatted code. We hope to get the whole repo consistently rustfmt'ed and to
20-
replace `make tidy` with rustfmt as a medium-term goal. Issues with stack traces
21-
for bugs and/or minimal test cases are especially useful.
22-
23-
See this [blog post](http://ncameron.org/blog/rustfmt-ing-rust/) for more details.
24-
2517

2618
## Create test cases
2719

@@ -66,11 +58,14 @@ example, the `issue-1111.rs` test file is configured by the file
6658

6759
## Debugging
6860

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.
61+
Some `rewrite_*` methods use the `debug!` macro for printing useful information.
62+
These messages can be printed by using the environment variable `RUST_LOG=rustfmt=DEBUG`.
63+
These traces can be helpful in understanding which part of the code was used
64+
and get a better grasp on the execution flow.
7065

7166
## Hack!
7267

73-
Here are some [good starting issues](https://github.com/rust-lang-nursery/rustfmt/issues?q=is%3Aopen+is%3Aissue+label%3Agood-first-issue).
68+
Here are some [good starting issues](https://github.com/rust-lang/rustfmt/issues?q=is%3Aopen+is%3Aissue+label%3Agood-first-issue).
7469

7570
If you've found areas which need polish and don't have issues, please submit a
7671
PR, don't feel there needs to be an issue.
@@ -86,6 +81,12 @@ Talking of tests, if you add a new feature or fix a bug, please also add a test.
8681
It's really easy, see above for details. Please run `cargo test` before
8782
submitting a PR to ensure your patch passes all tests, it's pretty quick.
8883

84+
Rustfmt is post-1.0 and within major version releases we strive for backwards
85+
compatibility (at least when using the default options). That means any code
86+
which changes Rustfmt's output must be guarded by either an option or a version
87+
check. The latter is implemented as an option called `option`. See the section on
88+
[configuration](#Configuration) below.
89+
8990
Please try to avoid leaving `TODO`s in the code. There are a few around, but I
9091
wish there weren't. You can leave `FIXME`s, preferably with an issue number.
9192

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rustfmt [![Build Status](https://travis-ci.org/rust-lang-nursery/rustfmt.svg)](https://travis-ci.org/rust-lang-nursery/rustfmt) [![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang-nursery/rustfmt?svg=true)](https://ci.appveyor.com/project/nrc/rustfmt) [![crates.io](https://img.shields.io/crates/v/rustfmt-nightly.svg)](https://crates.io/crates/rustfmt-nightly) [![Travis Configuration Status](https://img.shields.io/travis/davidalber/rustfmt-travis.svg?label=travis%20example)](https://travis-ci.org/davidalber/rustfmt-travis)
1+
# rustfmt [![Build Status](https://travis-ci.org/rust-lang/rustfmt.svg)](https://travis-ci.org/rust-lang/rustfmt) [![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang/rustfmt?svg=true)](https://ci.appveyor.com/project/nrc/rustfmt) [![crates.io](https://img.shields.io/crates/v/rustfmt-nightly.svg)](https://crates.io/crates/rustfmt-nightly) [![Travis Configuration Status](https://img.shields.io/travis/davidalber/rustfmt-travis.svg?label=travis%20example)](https://travis-ci.org/davidalber/rustfmt-travis)
22

33
A tool for formatting Rust code according to style guidelines.
44

src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ create_config! {
113113
blank_lines_lower_bound: usize, 0, false,
114114
"Minimum number of blank lines which must be put between items";
115115
edition: Edition, Edition::Edition2015, true, "The edition of the parser (RFC 2052)";
116+
version: Version, Version::One, false, "Version of formatting rules";
116117

117118
// Options that can change the source code beyond whitespace/blocks (somewhat linty things)
118119
merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";

src/config/options.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ configuration_option_enum! { Color:
291291
Auto,
292292
}
293293

294+
configuration_option_enum! { Version:
295+
// 1.x.y
296+
One,
297+
// 2.x.y
298+
Two,
299+
}
300+
294301
impl Color {
295302
/// Whether we should use a coloured terminal.
296303
pub fn use_colored_tty(self) -> bool {

tests/target/configs/combine_control_expr/false.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// rustfmt-indent_style: Block
22
// rustfmt-combine_control_expr: false
3-
// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
3+
// Combining openings and closings. See https://github.com/rust-lang/fmt-rfcs/issues/61.
44

55
fn main() {
66
// Call

tests/target/configs/combine_control_expr/true.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// rustfmt-indent_style: Block
22
// rustfmt-combine_control_expr: true
3-
// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
3+
// Combining openings and closings. See https://github.com/rust-lang/fmt-rfcs/issues/61.
44

55
fn main() {
66
// Call

0 commit comments

Comments
 (0)