diff --git a/Configurations.md b/Configurations.md index f0ab14d1eb1..1cc3bcbed78 100644 --- a/Configurations.md +++ b/Configurations.md @@ -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. diff --git a/Contributing.md b/Contributing.md index 131f38dd06a..f41f1e40e6a 100644 --- a/Contributing.md +++ b/Contributing.md @@ -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 diff --git a/rustfmt.toml b/rustfmt.toml index eccd5f9bd19..9b935b0a287 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,2 @@ error_on_line_overflow = true error_on_unformatted = true -version = "Two" diff --git a/src/config/mod.rs b/src/config/mod.rs index b0c99c049e3..19c8c02fdf1 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -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"; @@ -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 diff --git a/src/config/options.rs b/src/config/options.rs index 605198ab05b..650d0e5a8f1 100644 --- a/src/config/options.rs +++ b/src/config/options.rs @@ -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 { diff --git a/tests/source/configs/indent_style/block_trailing_comma_call/two.rs b/tests/source/configs/indent_style/block_trailing_comma_call/two.rs index 7a62d722c6e..c907ec50d45 100644 --- a/tests/source/configs/indent_style/block_trailing_comma_call/two.rs +++ b/tests/source/configs/indent_style/block_trailing_comma_call/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-error_on_line_overflow: false // rustfmt-indent_style: Block diff --git a/tests/source/fn-single-line/version_two.rs b/tests/source/fn-single-line/version_two.rs index bf381ff1065..6d7f764d280 100644 --- a/tests/source/fn-single-line/version_two.rs +++ b/tests/source/fn-single-line/version_two.rs @@ -1,5 +1,4 @@ // rustfmt-fn_single_line: true -// rustfmt-version: Two // Test single-line functions. fn foo_expr() { diff --git a/tests/source/issue-2179/two.rs b/tests/source/issue-2179/two.rs index f4cc9cc488b..ade953971ec 100644 --- a/tests/source/issue-2179/two.rs +++ b/tests/source/issue-2179/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-error_on_line_overflow: false fn issue_2179() { diff --git a/tests/source/issue-3213/version_two.rs b/tests/source/issue-3213/version_two.rs index 0f068c19d74..a00ec4d3661 100644 --- a/tests/source/issue-3213/version_two.rs +++ b/tests/source/issue-3213/version_two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn foo() { match 0 { 0 => return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, diff --git a/tests/source/issue-3227/two.rs b/tests/source/issue-3227/two.rs index c1572c00d57..cd23ef05134 100644 --- a/tests/source/issue-3227/two.rs +++ b/tests/source/issue-3227/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { thread::spawn(|| { while true { diff --git a/tests/source/issue-3270/two.rs b/tests/source/issue-3270/two.rs index 0eb756471e7..9b1a66a63b7 100644 --- a/tests/source/issue-3270/two.rs +++ b/tests/source/issue-3270/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - pub fn main() { /* let s = String::from( " diff --git a/tests/source/issue-3272/v2.rs b/tests/source/issue-3272/v2.rs index 0148368edc8..ff3e6e8cb56 100644 --- a/tests/source/issue-3272/v2.rs +++ b/tests/source/issue-3272/v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { assert!(HAYSTACK .par_iter() diff --git a/tests/source/issue-3278/version_two.rs b/tests/source/issue-3278/version_two.rs index c17b1742d39..07219295a7a 100644 --- a/tests/source/issue-3278/version_two.rs +++ b/tests/source/issue-3278/version_two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - pub fn parse_conditional<'a, I: 'a>() -> impl Parser + 'a where diff --git a/tests/source/issue-3295/two.rs b/tests/source/issue-3295/two.rs index 0eaf022249b..77d450d9a8d 100644 --- a/tests/source/issue-3295/two.rs +++ b/tests/source/issue-3295/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two pub enum TestEnum { a, b, diff --git a/tests/source/issue-3302.rs b/tests/source/issue-3302.rs index c037584fd71..686851d6041 100644 --- a/tests/source/issue-3302.rs +++ b/tests/source/issue-3302.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - macro_rules! moo1 { () => { bar! { diff --git a/tests/source/issue-3701/two.rs b/tests/source/issue-3701/two.rs index 8e15c58b8b2..254a8c2ca51 100644 --- a/tests/source/issue-3701/two.rs +++ b/tests/source/issue-3701/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn build_sorted_static_get_entry_names( mut entries: Vec<(u8, &'static str)>, ) -> (impl Fn( diff --git a/tests/source/issue-3840/version-two_hard-tabs.rs b/tests/source/issue-3840/version-two_hard-tabs.rs index 7b505fda87c..bf7ea7da0eb 100644 --- a/tests/source/issue-3840/version-two_hard-tabs.rs +++ b/tests/source/issue-3840/version-two_hard-tabs.rs @@ -1,5 +1,4 @@ // rustfmt-hard_tabs: true -// rustfmt-version: Two impl + FromEvent, A: Widget2, B: Widget2, C: for<'a> CtxFamily<'a>> Widget2 for WidgetEventLifter { diff --git a/tests/source/issue-3840/version-two_soft-tabs.rs b/tests/source/issue-3840/version-two_soft-tabs.rs index 39c8ef31292..3fc26224d50 100644 --- a/tests/source/issue-3840/version-two_soft-tabs.rs +++ b/tests/source/issue-3840/version-two_soft-tabs.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - impl + FromEvent, A: Widget2, B: Widget2, C: for<'a> CtxFamily<'a>> Widget2 for WidgetEventLifter { type Ctx = C; diff --git a/tests/source/issue-3904/two.rs b/tests/source/issue-3904/two.rs index 45eeb90e2fe..529ef3f9cbf 100644 --- a/tests/source/issue-3904/two.rs +++ b/tests/source/issue-3904/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { let checkkwd = (0x2i32 | 0x1i32) as i64; /* unrecognized "\z": print both chars unless ' or " */ diff --git a/tests/source/long-fn-1/version_two.rs b/tests/source/long-fn-1/version_two.rs index f402a26e8b6..1f53d78802d 100644 --- a/tests/source/long-fn-1/version_two.rs +++ b/tests/source/long-fn-1/version_two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // Tests that a function which is almost short enough, but not quite, gets // formatted correctly. diff --git a/tests/source/one_line_if_v2.rs b/tests/source/one_line_if_v2.rs index 40c834959f9..7c57577badd 100644 --- a/tests/source/one_line_if_v2.rs +++ b/tests/source/one_line_if_v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn plain_if(x: bool) -> u8 { if x { 0 diff --git a/tests/source/single-line-macro/v2.rs b/tests/source/single-line-macro/v2.rs index 51a665f7560..da777361620 100644 --- a/tests/source/single-line-macro/v2.rs +++ b/tests/source/single-line-macro/v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - // #2652 // Preserve trailing comma inside macro, even if it looks an array. macro_rules! bar { diff --git a/tests/source/trailing_comments/hard_tabs.rs b/tests/source/trailing_comments/hard_tabs.rs index 88249aa5fb9..a1b493a1b53 100644 --- a/tests/source/trailing_comments/hard_tabs.rs +++ b/tests/source/trailing_comments/hard_tabs.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-wrap_comments: true // rustfmt-hard_tabs: true diff --git a/tests/source/trailing_comments/soft_tabs.rs b/tests/source/trailing_comments/soft_tabs.rs index 7845f713b8a..ba13944f0c9 100644 --- a/tests/source/trailing_comments/soft_tabs.rs +++ b/tests/source/trailing_comments/soft_tabs.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-wrap_comments: true pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast diff --git a/tests/target/configs/indent_style/block_trailing_comma_call/two.rs b/tests/target/configs/indent_style/block_trailing_comma_call/two.rs index 4f4292e5f48..7dd4c8dccea 100644 --- a/tests/target/configs/indent_style/block_trailing_comma_call/two.rs +++ b/tests/target/configs/indent_style/block_trailing_comma_call/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-error_on_line_overflow: false // rustfmt-indent_style: Block diff --git a/tests/target/fn-single-line/version_two.rs b/tests/target/fn-single-line/version_two.rs index b8053d4c2f5..2a4509acc19 100644 --- a/tests/target/fn-single-line/version_two.rs +++ b/tests/target/fn-single-line/version_two.rs @@ -1,5 +1,4 @@ // rustfmt-fn_single_line: true -// rustfmt-version: Two // Test single-line functions. fn foo_expr() { 1 } diff --git a/tests/target/issue-2179/two.rs b/tests/target/issue-2179/two.rs index 96531509ea2..ad405f05878 100644 --- a/tests/target/issue-2179/two.rs +++ b/tests/target/issue-2179/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-error_on_line_overflow: false fn issue_2179() { diff --git a/tests/target/issue-3132.rs b/tests/target/issue-3132.rs index 4dffe0ab836..c3d24fc10f6 100644 --- a/tests/target/issue-3132.rs +++ b/tests/target/issue-3132.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn test() { /* a diff --git a/tests/target/issue-3213/version_two.rs b/tests/target/issue-3213/version_two.rs index de93d04ba95..bd2ee48138a 100644 --- a/tests/target/issue-3213/version_two.rs +++ b/tests/target/issue-3213/version_two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn foo() { match 0 { 0 => { diff --git a/tests/target/issue-3227/two.rs b/tests/target/issue-3227/two.rs index 374ab54305d..e87c28f9ca1 100644 --- a/tests/target/issue-3227/two.rs +++ b/tests/target/issue-3227/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { thread::spawn(|| { while true { diff --git a/tests/target/issue-3270/two.rs b/tests/target/issue-3270/two.rs index e48b5921329..4f624f1193b 100644 --- a/tests/target/issue-3270/two.rs +++ b/tests/target/issue-3270/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - pub fn main() { /* let s = String::from( " diff --git a/tests/target/issue-3270/wrap.rs b/tests/target/issue-3270/wrap.rs index 7435c5f0866..3dbacab3384 100644 --- a/tests/target/issue-3270/wrap.rs +++ b/tests/target/issue-3270/wrap.rs @@ -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 diff --git a/tests/target/issue-3272/v2.rs b/tests/target/issue-3272/v2.rs index a42a2fccd5b..6f40ef42dda 100644 --- a/tests/target/issue-3272/v2.rs +++ b/tests/target/issue-3272/v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { assert!( HAYSTACK diff --git a/tests/target/issue-3278/version_two.rs b/tests/target/issue-3278/version_two.rs index c17b1742d39..07219295a7a 100644 --- a/tests/target/issue-3278/version_two.rs +++ b/tests/target/issue-3278/version_two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - pub fn parse_conditional<'a, I: 'a>() -> impl Parser + 'a where diff --git a/tests/target/issue-3295/two.rs b/tests/target/issue-3295/two.rs index 3e669a0bb75..cf6f9e2ad8b 100644 --- a/tests/target/issue-3295/two.rs +++ b/tests/target/issue-3295/two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two pub enum TestEnum { a, b, diff --git a/tests/target/issue-3302.rs b/tests/target/issue-3302.rs index 146cb983819..536e2dab40b 100644 --- a/tests/target/issue-3302.rs +++ b/tests/target/issue-3302.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - macro_rules! moo1 { () => { bar! { diff --git a/tests/target/issue-3614/version_two.rs b/tests/target/issue-3614/version_two.rs index 5d6f8e7a313..a316be84cac 100644 --- a/tests/target/issue-3614/version_two.rs +++ b/tests/target/issue-3614/version_two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { let toto = || { if true { 42 } else { 24 } diff --git a/tests/target/issue-3701/two.rs b/tests/target/issue-3701/two.rs index 62ffc9d823d..8e0d7e62dad 100644 --- a/tests/target/issue-3701/two.rs +++ b/tests/target/issue-3701/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn build_sorted_static_get_entry_names( mut entries: Vec<(u8, &'static str)>, ) -> ( diff --git a/tests/target/issue-3840/version-two_hard-tabs.rs b/tests/target/issue-3840/version-two_hard-tabs.rs index 084db3d1465..0dd57c93163 100644 --- a/tests/target/issue-3840/version-two_hard-tabs.rs +++ b/tests/target/issue-3840/version-two_hard-tabs.rs @@ -1,5 +1,4 @@ // rustfmt-hard_tabs: true -// rustfmt-version: Two impl< Target: FromEvent + FromEvent, diff --git a/tests/target/issue-3840/version-two_soft-tabs.rs b/tests/target/issue-3840/version-two_soft-tabs.rs index bc59b0baa56..44e979629b7 100644 --- a/tests/target/issue-3840/version-two_soft-tabs.rs +++ b/tests/target/issue-3840/version-two_soft-tabs.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - impl< Target: FromEvent + FromEvent, A: Widget2, diff --git a/tests/target/issue-3882.rs b/tests/target/issue-3882.rs index 5eb442af974..1a6749c7c6c 100644 --- a/tests/target/issue-3882.rs +++ b/tests/target/issue-3882.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two fn bar(_t: T, // bar ) { } diff --git a/tests/target/issue-3904/two.rs b/tests/target/issue-3904/two.rs index 00fe4b1a629..054f892fc1f 100644 --- a/tests/target/issue-3904/two.rs +++ b/tests/target/issue-3904/two.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn main() { let checkkwd = (0x2i32 | 0x1i32) as i64; /* unrecognized "\z": print both chars unless ' or " */ } diff --git a/tests/target/long-fn-1/version_two.rs b/tests/target/long-fn-1/version_two.rs index 32794bccde2..320617f2772 100644 --- a/tests/target/long-fn-1/version_two.rs +++ b/tests/target/long-fn-1/version_two.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // Tests that a function which is almost short enough, but not quite, gets // formatted correctly. diff --git a/tests/target/one_line_if_v2.rs b/tests/target/one_line_if_v2.rs index 81ca4c8b8b4..695f63c2453 100644 --- a/tests/target/one_line_if_v2.rs +++ b/tests/target/one_line_if_v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - fn plain_if(x: bool) -> u8 { if x { 0 } else { 1 } } diff --git a/tests/target/single-line-macro/v2.rs b/tests/target/single-line-macro/v2.rs index 9c6bcf33ad5..f9f980000b1 100644 --- a/tests/target/single-line-macro/v2.rs +++ b/tests/target/single-line-macro/v2.rs @@ -1,5 +1,3 @@ -// rustfmt-version: Two - // #2652 // Preserve trailing comma inside macro, even if it looks an array. macro_rules! bar { diff --git a/tests/target/trailing_comments/hard_tabs.rs b/tests/target/trailing_comments/hard_tabs.rs index 9044ef6c334..f55862398fe 100644 --- a/tests/target/trailing_comments/hard_tabs.rs +++ b/tests/target/trailing_comments/hard_tabs.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-wrap_comments: true // rustfmt-hard_tabs: true diff --git a/tests/target/trailing_comments/soft_tabs.rs b/tests/target/trailing_comments/soft_tabs.rs index 116f55f6aab..c6c4e7be244 100644 --- a/tests/target/trailing_comments/soft_tabs.rs +++ b/tests/target/trailing_comments/soft_tabs.rs @@ -1,4 +1,3 @@ -// rustfmt-version: Two // rustfmt-wrap_comments: true pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast