Skip to content

Commit e3d0e1d

Browse files
committed
print deprecation message in case the skip-children CLI option is used
1 parent e0077aa commit e3d0e1d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
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`

src/bin/main.rs

Lines changed: 9 additions & 0 deletions
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,11 @@ 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 submodules of given files (#3587)";
520+
eprintln!("{}: {}", Red.bold().paint("Deprecation"), msg);
521+
}
522+
516523
impl GetOptsOptions {
517524
pub fn from_matches(matches: &Matches) -> Result<GetOptsOptions, FailureError> {
518525
let mut options = GetOptsOptions::default();
@@ -529,6 +536,7 @@ impl GetOptsOptions {
529536

530537
if options.unstable_features {
531538
if matches.opt_present("skip-children") {
539+
deprecate_skip_children();
532540
options.skip_children = Some(true);
533541
}
534542
if matches.opt_present("error-on-unformatted") {
@@ -540,6 +548,7 @@ impl GetOptsOptions {
540548
} else {
541549
let mut unstable_options = vec![];
542550
if matches.opt_present("skip-children") {
551+
deprecate_skip_children();
543552
unstable_options.push("`--skip-children`");
544553
}
545554
if matches.opt_present("error-on-unformatted") {

0 commit comments

Comments
 (0)