Skip to content
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

deprecate skip_children option #3895

Merged
merged 5 commits into from
Oct 29, 2019
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
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -513,6 +515,12 @@ 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<GetOptsOptions, FailureError> {
let mut options = GetOptsOptions::default();
Expand All @@ -529,6 +537,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") {
Expand All @@ -540,6 +549,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") {
Expand Down
12 changes: 12 additions & 0 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -137,8 +140,17 @@ 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;
Expand Down