From e3d0e1da2702c3d786aca72ba12bdc741c280c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Sun, 27 Oct 2019 23:26:39 +0100 Subject: [PATCH 1/5] print deprecation message in case the skip-children CLI option is used --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/bin/main.rs | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5ed591d42be..40979a53bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,14 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "arrayref" version = "0.3.5" @@ -794,6 +802,7 @@ name = "rustfmt-nightly" version = "1.4.10" dependencies = [ "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytecount 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1085,6 +1094,7 @@ dependencies = [ "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" diff --git a/Cargo.toml b/Cargo.toml index 89cd280062b..351486b0a78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ annotate-snippets = { version = "0.6", features = ["ansi_term"] } structopt = "0.3" rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" } lazy_static = "1.0.0" +ansi_term = "0.12" # A noop dependency that changes in the Rust repository, it's a bit of a hack. # See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` diff --git a/src/bin/main.rs b/src/bin/main.rs index 661502a2e0e..ab338830740 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -11,6 +11,8 @@ use std::io::{self, stdout, Read, Write}; use std::path::{Path, PathBuf}; use std::str::FromStr; +use ansi_term::Colour::Red; + use getopts::{Matches, Options}; use crate::rustfmt::{ @@ -513,6 +515,11 @@ struct GetOptsOptions { print_misformatted_file_names: bool, } +fn deprecate_skip_children() { + let msg = "Option --skip-children is deprecated since it is now the default to not format submodules of given files (#3587)"; + eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg); +} + impl GetOptsOptions { pub fn from_matches(matches: &Matches) -> Result { let mut options = GetOptsOptions::default(); @@ -529,6 +536,7 @@ impl GetOptsOptions { if options.unstable_features { if matches.opt_present("skip-children") { + deprecate_skip_children(); options.skip_children = Some(true); } if matches.opt_present("error-on-unformatted") { @@ -540,6 +548,7 @@ impl GetOptsOptions { } else { let mut unstable_options = vec![]; if matches.opt_present("skip-children") { + deprecate_skip_children(); unstable_options.push("`--skip-children`"); } if matches.opt_present("error-on-unformatted") { From 4cbf11acd0eac2d10fc9fb2f1654ae79112ac070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Sun, 27 Oct 2019 23:59:08 +0100 Subject: [PATCH 2/5] deprecate config option skip_children --- Configurations.md | 2 +- src/config/config_type.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Configurations.md b/Configurations.md index e1885aba836..0064f561720 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1881,7 +1881,7 @@ specific version of rustfmt is used in your CI, use this option. - **Possible values**: any published version (e.g. `"0.3.8"`) - **Stable**: No (tracking issue: #3386) -## `skip_children` +## `skip_children` (DEPRECATED #3587) Don't reformat out of line modules diff --git a/src/config/config_type.rs b/src/config/config_type.rs index 2eff7561392..28e6847cc4e 100644 --- a/src/config/config_type.rs +++ b/src/config/config_type.rs @@ -58,6 +58,9 @@ macro_rules! create_config { use serde::{Deserialize, Serialize}; + // for error messages + use ansi_term::Colour::Red; + #[derive(Clone)] #[allow(unreachable_pub)] pub struct Config { @@ -137,8 +140,16 @@ macro_rules! create_config { } fn fill_from_parsed_config(mut self, parsed: PartialConfig, dir: &Path) -> Config { + let deprecate_skip_children = || { + let msg = "Option skip_children is deprecated since it is now the default to not format submodules of given files (#3587)"; + eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg); + }; + $( if let Some(val) = parsed.$i { + if stringify!($i) == "skip_children" { + deprecate_skip_children() + } if self.$i.3 { self.$i.1 = true; self.$i.2 = val; @@ -216,6 +227,7 @@ macro_rules! create_config { match key { $( stringify!($i) => { + dbg!(stringify!($i)); self.$i.1 = true; self.$i.2 = val.parse::<$ty>() .expect(&format!("Failed to parse override for {} (\"{}\") as a {}", From 6b599e69aeb88b64bd30a50a08f294452fa63aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 28 Oct 2019 09:36:49 +0100 Subject: [PATCH 3/5] remove dbg statement --- src/config/config_type.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config/config_type.rs b/src/config/config_type.rs index 28e6847cc4e..358f2fb1c58 100644 --- a/src/config/config_type.rs +++ b/src/config/config_type.rs @@ -227,7 +227,6 @@ macro_rules! create_config { match key { $( stringify!($i) => { - dbg!(stringify!($i)); self.$i.1 = true; self.$i.2 = val.parse::<$ty>() .expect(&format!("Failed to parse override for {} (\"{}\") as a {}", From d57f94a6ce1102792c6e3153388fd00722b3bf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 28 Oct 2019 10:09:52 +0100 Subject: [PATCH 4/5] fix test build script `cargo test` failed because of the too long lines but the build passed anyway because `cargo test -- --ignored` did. The script should be a single command. https://docs.travis-ci.com/user/deployment/script/ --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 966b7d7bac4..70132e46ffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,9 +47,7 @@ matrix: script: - | if [ -z ${INTEGRATION} ]; then - cargo build - cargo test - cargo test -- --ignored + cargo build && cargo test && cargo test -- --ignored else ./ci/integration.sh fi From b15c47798bc761051d9e3694d0fc81a5b08dbac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 28 Oct 2019 10:53:24 +0100 Subject: [PATCH 5/5] wrap long strings --- src/bin/main.rs | 3 ++- src/config/config_type.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index ab338830740..ccbfb4052e2 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -516,7 +516,8 @@ struct GetOptsOptions { } fn deprecate_skip_children() { - let msg = "Option --skip-children is deprecated since it is now the default to not format submodules of given files (#3587)"; + let msg = "Option --skip-children is deprecated since it is now the default to not format \ + submodules of given files (#3587)"; eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg); } diff --git a/src/config/config_type.rs b/src/config/config_type.rs index 358f2fb1c58..b8f0691a7b9 100644 --- a/src/config/config_type.rs +++ b/src/config/config_type.rs @@ -141,7 +141,8 @@ macro_rules! create_config { fn fill_from_parsed_config(mut self, parsed: PartialConfig, dir: &Path) -> Config { let deprecate_skip_children = || { - let msg = "Option skip_children is deprecated since it is now the default to not format submodules of given files (#3587)"; + let msg = "Option skip_children is deprecated since it is now the default to \ + not format submodules of given files (#3587)"; eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg); };