Skip to content

Remove related version implements and document #3978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2364,22 +2364,6 @@ fn main() {
}
```

## `version`

Which version of the formatting rules to use. `Version::One` is backwards-compatible
with Rustfmt 1.0. Other versions are only backwards compatible within a major
version number.

- **Default value**: `One`
- **Possible values**: `One`, `Two`
- **Stable**: No (tracking issue: #3383)

### Example

```toml
version = "Two"
```

## `where_single_line`

Forces the `where` clause to be laid out on a single line.
Expand Down
28 changes: 0 additions & 28 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,6 @@ check. The latter is implemented as an option called `option`. See the section o
Please try to avoid leaving `TODO`s in the code. There are a few around, but I
wish there weren't. You can leave `FIXME`s, preferably with an issue number.


### Version-gate formatting changes

A change that introduces a different code-formatting should be gated on the
`version` configuration. This is to ensure the formatting of the current major
release is preserved, while allowing fixes to be implemented for the next
release.

This is done by conditionally guarding the change like so:

```rust
if config.version() == Version::One { // if the current major release is 1.x
// current formatting
} else {
// new formatting
}
```

This allows the user to apply the next formatting explicitly via the
configuration, while being stable by default.

When the next major release is done, the code block of the previous formatting
can be deleted, e.g., the first block in the example above when going from `1.x`
to `2.x`.

| Note: Only formatting changes with default options need to be gated. |
| --- |

### A quick tour of Rustfmt

Rustfmt is basically a pretty printer - that is, its mode of operation is to
Expand Down
1 change: 0 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
error_on_line_overflow = true
error_on_unformatted = true
version = "Two"
2 changes: 0 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ create_config! {
blank_lines_lower_bound: usize, 0, false,
"Minimum number of blank lines which must be put between items";
edition: Edition, Edition::Edition2018, true, "The edition of the parser (RFC 2052)";
version: Version, Version::One, false, "Version of formatting rules";
inline_attribute_width: usize, 0, false,
"Write an item and its attribute on the same line \
if their combined width is below a threshold";
Expand Down Expand Up @@ -569,7 +568,6 @@ match_block_trailing_comma = false
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2018"
version = "One"
inline_attribute_width = 0
merge_derives = true
use_try_shorthand = false
Expand Down
9 changes: 0 additions & 9 deletions src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ pub enum Color {
Auto,
}

#[config_type]
/// rustfmt format style version.
pub enum Version {
/// 1.x.y. When specified, rustfmt will format in the same style as 1.0.0.
One,
/// 2.x.y. When specified, rustfmt will format in the the latest style.
Two,
}

impl Color {
/// Whether we should use a coloured terminal.
pub fn use_colored_tty(self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-error_on_line_overflow: false
// rustfmt-indent_style: Block

Expand Down
1 change: 0 additions & 1 deletion tests/source/fn-single-line/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// rustfmt-fn_single_line: true
// rustfmt-version: Two
// Test single-line functions.

fn foo_expr() {
Expand Down
1 change: 0 additions & 1 deletion tests/source/issue-2179/two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-error_on_line_overflow: false

fn issue_2179() {
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3213/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn foo() {
match 0 {
0 => return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3227/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
thread::spawn(|| {
while true {
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3270/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

pub fn main() {
/* let s = String::from(
"
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3272/v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
assert!(HAYSTACK
.par_iter()
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3278/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

pub fn parse_conditional<'a, I: 'a>()
-> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
where
Expand Down
1 change: 0 additions & 1 deletion tests/source/issue-3295/two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
pub enum TestEnum {
a,
b,
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3302.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

macro_rules! moo1 {
() => {
bar! {
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3701/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn build_sorted_static_get_entry_names(
mut entries: Vec<(u8, &'static str)>,
) -> (impl Fn(
Expand Down
1 change: 0 additions & 1 deletion tests/source/issue-3840/version-two_hard-tabs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// rustfmt-hard_tabs: true
// rustfmt-version: Two

impl<Target: FromEvent<A> + FromEvent<B>, A: Widget2<Ctx = C>, B: Widget2<Ctx = C>, C: for<'a> CtxFamily<'a>> Widget2 for WidgetEventLifter<Target, A, B>
{
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3840/version-two_soft-tabs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

impl<Target: FromEvent<A> + FromEvent<B>, A: Widget2<Ctx = C>, B: Widget2<Ctx = C>, C: for<'a> CtxFamily<'a>> Widget2 for WidgetEventLifter<Target, A, B>
{
type Ctx = C;
Expand Down
2 changes: 0 additions & 2 deletions tests/source/issue-3904/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
let checkkwd = (0x2i32 | 0x1i32) as i64; /* unrecognized "\z": print both chars unless ' or " */

Expand Down
1 change: 0 additions & 1 deletion tests/source/long-fn-1/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// Tests that a function which is almost short enough, but not quite, gets
// formatted correctly.

Expand Down
2 changes: 0 additions & 2 deletions tests/source/one_line_if_v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn plain_if(x: bool) -> u8 {
if x {
0
Expand Down
2 changes: 0 additions & 2 deletions tests/source/single-line-macro/v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

// #2652
// Preserve trailing comma inside macro, even if it looks an array.
macro_rules! bar {
Expand Down
1 change: 0 additions & 1 deletion tests/source/trailing_comments/hard_tabs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-wrap_comments: true
// rustfmt-hard_tabs: true

Expand Down
1 change: 0 additions & 1 deletion tests/source/trailing_comments/soft_tabs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-wrap_comments: true

pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-error_on_line_overflow: false
// rustfmt-indent_style: Block

Expand Down
1 change: 0 additions & 1 deletion tests/target/fn-single-line/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// rustfmt-fn_single_line: true
// rustfmt-version: Two
// Test single-line functions.

fn foo_expr() { 1 }
Expand Down
1 change: 0 additions & 1 deletion tests/target/issue-2179/two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-error_on_line_overflow: false

fn issue_2179() {
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3132.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn test() {
/*
a
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3213/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn foo() {
match 0 {
0 => {
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3227/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
thread::spawn(|| {
while true {
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3270/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

pub fn main() {
/* let s = String::from(
"
Expand Down
1 change: 0 additions & 1 deletion tests/target/issue-3270/wrap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// rustfmt-wrap_comments: true
// rustfmt-version: Two

// check that a line below max_width does not get over the limit when wrapping
// it in a block comment
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3272/v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
assert!(
HAYSTACK
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3278/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

pub fn parse_conditional<'a, I: 'a>()
-> impl Parser<Input = I, Output = Expr, PartialState = ()> + 'a
where
Expand Down
1 change: 0 additions & 1 deletion tests/target/issue-3295/two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
pub enum TestEnum {
a,
b,
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3302.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

macro_rules! moo1 {
() => {
bar! {
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3614/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
let toto = || {
if true { 42 } else { 24 }
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3701/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn build_sorted_static_get_entry_names(
mut entries: Vec<(u8, &'static str)>,
) -> (
Expand Down
1 change: 0 additions & 1 deletion tests/target/issue-3840/version-two_hard-tabs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// rustfmt-hard_tabs: true
// rustfmt-version: Two

impl<
Target: FromEvent<A> + FromEvent<B>,
Expand Down
2 changes: 0 additions & 2 deletions tests/target/issue-3840/version-two_soft-tabs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

impl<
Target: FromEvent<A> + FromEvent<B>,
A: Widget2<Ctx = C>,
Expand Down
1 change: 0 additions & 1 deletion tests/target/issue-3882.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
fn bar(_t: T, // bar
) {
}
2 changes: 0 additions & 2 deletions tests/target/issue-3904/two.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
let checkkwd = (0x2i32 | 0x1i32) as i64; /* unrecognized "\z": print both chars unless ' or " */
}
1 change: 0 additions & 1 deletion tests/target/long-fn-1/version_two.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// Tests that a function which is almost short enough, but not quite, gets
// formatted correctly.

Expand Down
2 changes: 0 additions & 2 deletions tests/target/one_line_if_v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn plain_if(x: bool) -> u8 {
if x { 0 } else { 1 }
}
Expand Down
2 changes: 0 additions & 2 deletions tests/target/single-line-macro/v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

// #2652
// Preserve trailing comma inside macro, even if it looks an array.
macro_rules! bar {
Expand Down
1 change: 0 additions & 1 deletion tests/target/trailing_comments/hard_tabs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-wrap_comments: true
// rustfmt-hard_tabs: true

Expand Down
1 change: 0 additions & 1 deletion tests/target/trailing_comments/soft_tabs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// rustfmt-version: Two
// rustfmt-wrap_comments: true

pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast
Expand Down