From 91c531d7feb0bc178c70b0047a98b38bbbd89318 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 27 Mar 2019 19:41:18 +0100 Subject: [PATCH 1/3] Update Rustfmt to 1.2 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df68d63aead..dca75bafaac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1424,7 +1424,7 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-workspace-hack 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfmt-nightly 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1671,7 +1671,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2470,7 +2470,7 @@ dependencies = [ "checksum rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c5a95edfa0c893236ae4778bb7c4752760e4c0d245e19b5eff33c5aa5eb9dc" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustfix 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "af7c21531a91512a4a51b490be6ba1c8eff34fdda0dc5bf87dc28d86748aac56" -"checksum rustfmt-nightly 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b91974beb2a9b08408acc62f81d77cb3982902dd2109f3667e45cb126ac74514" +"checksum rustfmt-nightly 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5134bc4a11ada7c3ba88ac3ff054caee2719e62c37fe36da0df2961c1dc34fed" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56" diff --git a/Cargo.toml b/Cargo.toml index ed60d1da8f9..2aa7ea42dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ racer = { version = "2.1.21", default-features = false } rand = "0.6" rayon = "1" rustc_tools_util = "0.1.1" -rustfmt-nightly = "1.1" +rustfmt-nightly = "1.2" rustc-serialize = "0.3" serde = "1.0" serde_json = "1.0" From 590c4dc5639ace46787e5f6c55347277633d28da Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 5 Apr 2019 13:41:38 +0200 Subject: [PATCH 2/3] Adjust range-formatting test --- tests/client.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/client.rs b/tests/client.rs index 31b2cc28eef..8dc8bacc2b9 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -1788,8 +1788,8 @@ fn client_reformat_with_range() { uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(), }, range: Range { - start: Position { line: 2, character: 0 }, - end: Position { line: 3, character: 0 }, + start: Position { line: 1, character: 0 }, + end: Position { line: 2, character: 0 }, }, options: FormattingOptions { tab_size: 4, @@ -1800,8 +1800,15 @@ fn client_reformat_with_range() { ); let newline = if cfg!(windows) { "\r\n" } else { "\n" }; - let formatted = "pub fn main() {\n let world1 = \"world\";\n println!(\"Hello, {}!\", world1);\n let world2 = \"world\";\n println!(\"Hello, {}!\", world2);\n let world3 = \"world\";\n println!(\"Hello, {}!\", world3);\n}\n" - .replace("\n", newline); + let formatted = r#"pub fn main() { + let world1 = "world"; + println!("Hello, {}!", world1); +let world2 = "world"; println!("Hello, {}!", world2); +let world3 = "world"; println!("Hello, {}!", world3); + } +"# + .replace("\r", "") + .replace("\n", newline); assert_eq!(result.unwrap()[0].new_text, formatted); } From f4f144434a856202bbe9ac0a08b697aed05d7676 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 5 Apr 2019 16:51:50 +0200 Subject: [PATCH 3/3] Work around Rustfmt bug --- tests/client.rs | 2 ++ tests/fixtures/reformat_with_range/src/main.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/client.rs b/tests/client.rs index 8dc8bacc2b9..57ccf8ccbfd 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -1803,6 +1803,8 @@ fn client_reformat_with_range() { let formatted = r#"pub fn main() { let world1 = "world"; println!("Hello, {}!", world1); + +// Work around rustfmt#3494 let world2 = "world"; println!("Hello, {}!", world2); let world3 = "world"; println!("Hello, {}!", world3); } diff --git a/tests/fixtures/reformat_with_range/src/main.rs b/tests/fixtures/reformat_with_range/src/main.rs index ab9675ab5ef..8d5ba4ba253 100644 --- a/tests/fixtures/reformat_with_range/src/main.rs +++ b/tests/fixtures/reformat_with_range/src/main.rs @@ -1,6 +1,8 @@ pub fn main() { let world1 = "world"; println!("Hello, {}!", world1); + +// Work around rustfmt#3494 let world2 = "world"; println!("Hello, {}!", world2); let world3 = "world"; println!("Hello, {}!", world3); } \ No newline at end of file