Skip to content

Commit 09a028b

Browse files
scampitopecongiro
authored andcommitted
deprecate skip_children option (#3895)
1 parent e0077aa commit 09a028b

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

Diff for: .travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ matrix:
4747
script:
4848
- |
4949
if [ -z ${INTEGRATION} ]; then
50-
cargo build
51-
cargo test
52-
cargo test -- --ignored
50+
cargo build && cargo test && cargo test -- --ignored
5351
else
5452
./ci/integration.sh
5553
fi

Diff for: Cargo.lock

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ annotate-snippets = { version = "0.6", features = ["ansi_term"] }
5757
structopt = "0.3"
5858
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
5959
lazy_static = "1.0.0"
60+
ansi_term = "0.12"
6061

6162
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
6263
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`

Diff for: Configurations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ specific version of rustfmt is used in your CI, use this option.
18811881
- **Possible values**: any published version (e.g. `"0.3.8"`)
18821882
- **Stable**: No (tracking issue: #3386)
18831883

1884-
## `skip_children`
1884+
## `skip_children` (DEPRECATED #3587)
18851885

18861886
Don't reformat out of line modules
18871887

Diff for: src/bin/main.rs

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use std::io::{self, stdout, Read, Write};
1111
use std::path::{Path, PathBuf};
1212
use std::str::FromStr;
1313

14+
use ansi_term::Colour::Red;
15+
1416
use getopts::{Matches, Options};
1517

1618
use crate::rustfmt::{
@@ -513,6 +515,12 @@ struct GetOptsOptions {
513515
print_misformatted_file_names: bool,
514516
}
515517

518+
fn deprecate_skip_children() {
519+
let msg = "Option --skip-children is deprecated since it is now the default to not format \
520+
submodules of given files (#3587)";
521+
eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg);
522+
}
523+
516524
impl GetOptsOptions {
517525
pub fn from_matches(matches: &Matches) -> Result<GetOptsOptions, FailureError> {
518526
let mut options = GetOptsOptions::default();
@@ -529,6 +537,7 @@ impl GetOptsOptions {
529537

530538
if options.unstable_features {
531539
if matches.opt_present("skip-children") {
540+
deprecate_skip_children();
532541
options.skip_children = Some(true);
533542
}
534543
if matches.opt_present("error-on-unformatted") {
@@ -540,6 +549,7 @@ impl GetOptsOptions {
540549
} else {
541550
let mut unstable_options = vec![];
542551
if matches.opt_present("skip-children") {
552+
deprecate_skip_children();
543553
unstable_options.push("`--skip-children`");
544554
}
545555
if matches.opt_present("error-on-unformatted") {

Diff for: src/config/config_type.rs

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ macro_rules! create_config {
5858

5959
use serde::{Deserialize, Serialize};
6060

61+
// for error messages
62+
use ansi_term::Colour::Red;
63+
6164
#[derive(Clone)]
6265
#[allow(unreachable_pub)]
6366
pub struct Config {
@@ -137,8 +140,17 @@ macro_rules! create_config {
137140
}
138141

139142
fn fill_from_parsed_config(mut self, parsed: PartialConfig, dir: &Path) -> Config {
143+
let deprecate_skip_children = || {
144+
let msg = "Option skip_children is deprecated since it is now the default to \
145+
not format submodules of given files (#3587)";
146+
eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg);
147+
};
148+
140149
$(
141150
if let Some(val) = parsed.$i {
151+
if stringify!($i) == "skip_children" {
152+
deprecate_skip_children()
153+
}
142154
if self.$i.3 {
143155
self.$i.1 = true;
144156
self.$i.2 = val;

0 commit comments

Comments
 (0)