Skip to content

Remove version #4235

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

Merged
merged 5 commits into from
Jun 6, 2020
Merged
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 @@ -2610,22 +2610,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](https://github.com/rust-lang/rustfmt/issues/3383))

### Example

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

## `where_single_line`

Forces the `where` clause to be laid out on a single line.
Expand Down
1 change: 1 addition & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ args = [
]

[tasks.test-all]
dependencies = ["build-bin"]
run_task = { name = ["test", "test-ignored"] }

[tasks.test-ignored]
Expand Down
4 changes: 3 additions & 1 deletion config_proc_macro/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target/
target/

Cargo.lock
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.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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 @@ -615,7 +614,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
7 changes: 4 additions & 3 deletions src/config/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ use std::fs::File;
use std::io;
use std::io::Read;

use itertools::Itertools;
use regex::Regex;

use self::ParsingState::*;

#[derive(Debug)]
pub(crate) enum LicenseError {
IO(io::Error),
Expand Down Expand Up @@ -44,8 +47,6 @@ enum ParsingState {
Abort(String),
}

use self::ParsingState::*;

pub(crate) struct TemplateParser {
parsed: String,
buffer: String,
Expand Down Expand Up @@ -111,7 +112,7 @@ impl TemplateParser {
/// ```
pub(crate) fn parse(template: &str) -> Result<String, LicenseError> {
let mut parser = Self::new();
for chr in template.chars() {
for chr in template.lines().join("\n").chars() {
if chr == '\n' {
parser.linum += 1;
}
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
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
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
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 → tests/source/issue-3227.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
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 → tests/source/issue-3272.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
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
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 → tests/source/issue-3701.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
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
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 → tests/source/issue-3904.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
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
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
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
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
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
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 → tests/target/issue-3227.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
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 → tests/target/issue-3272.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rustfmt-version: Two

fn main() {
assert!(
HAYSTACK
Expand Down
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
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
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 → tests/target/issue-3701.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
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
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 → tests/target/issue-3904.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 " */
}
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
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
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