Skip to content

Commit afaca31

Browse files
chore: resolve merge conflicts
2 parents c115af7 + d35ebf7 commit afaca31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2176
-923
lines changed

.travis.yml

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

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "1.4.9"
4+
version = "1.4.10"
55
authors = ["Nicholas Cameron <[email protected]>", "The Rustfmt developers"]
66
description = "Tool to find and fix Rust formatting issues"
77
repository = "https://github.com/rust-lang/rustfmt"
@@ -56,6 +56,8 @@ ignore = "0.4.6"
5656
annotate-snippets = { version = "0.6", features = ["ansi_term"] }
5757
structopt = "0.3"
5858
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
59+
lazy_static = "1.0.0"
60+
ansi_term = "0.12"
5961

6062
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
6163
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
@@ -74,5 +76,3 @@ version = "610.0.0"
7476
package = "rustc-ap-syntax_pos"
7577
version = "610.0.0"
7678

77-
[dev-dependencies]
78-
lazy_static = "1.0.0"

Configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ specific version of rustfmt is used in your CI, use this option.
19681968
- **Possible values**: any published version (e.g. `"0.3.8"`)
19691969
- **Stable**: No (tracking issue: #3386)
19701970

1971-
## `skip_children`
1971+
## `skip_children` (DEPRECATED #3587)
19721972

19731973
Don't reformat out of line modules
19741974

ci/integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -ex
1515
# it again.
1616
#
1717
#which cargo-fmt || cargo install --force
18-
cargo install --path . --force
18+
cargo install --path . --force --locked
1919

2020
echo "Integration tests for: ${INTEGRATION}"
2121
cargo fmt -- --version

src/bin/main.rs

Lines changed: 37 additions & 9 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::{
@@ -73,6 +75,14 @@ pub enum OperationError {
7375
/// An io error during reading or writing.
7476
#[fail(display = "io error: {}", _0)]
7577
IoError(IoError),
78+
/// Attempt to use --check with stdin, which isn't currently
79+
/// supported.
80+
#[fail(display = "The `--check` option is not supported with standard input.")]
81+
CheckWithStdin,
82+
/// Attempt to use --emit=json with stdin, which isn't currently
83+
/// supported.
84+
#[fail(display = "Using `--emit` other than stdout is not supported with standard input.")]
85+
EmitWithStdin,
7686
}
7787

7888
impl From<IoError> for OperationError {
@@ -242,6 +252,14 @@ fn format_string(input: String, options: GetOptsOptions) -> Result<i32, FailureE
242252
// try to read config from local directory
243253
let (mut config, _) = load_config(Some(Path::new(".")), Some(options.clone()))?;
244254

255+
if options.check {
256+
return Err(OperationError::CheckWithStdin.into());
257+
}
258+
if let Some(emit_mode) = options.emit_mode {
259+
if emit_mode != EmitMode::Stdout {
260+
return Err(OperationError::EmitWithStdin.into());
261+
}
262+
}
245263
// emit mode is always Stdout for Stdin.
246264
config.set().emit_mode(EmitMode::Stdout);
247265
config.set().verbose(Verbosity::Quiet);
@@ -486,7 +504,7 @@ struct GetOptsOptions {
486504
verbose: bool,
487505
config_path: Option<PathBuf>,
488506
inline_config: HashMap<String, String>,
489-
emit_mode: EmitMode,
507+
emit_mode: Option<EmitMode>,
490508
backup: bool,
491509
check: bool,
492510
edition: Option<Edition>,
@@ -497,6 +515,12 @@ struct GetOptsOptions {
497515
print_misformatted_file_names: bool,
498516
}
499517

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+
500524
impl GetOptsOptions {
501525
pub fn from_matches(matches: &Matches) -> Result<GetOptsOptions, FailureError> {
502526
let mut options = GetOptsOptions::default();
@@ -513,6 +537,7 @@ impl GetOptsOptions {
513537

514538
if options.unstable_features {
515539
if matches.opt_present("skip-children") {
540+
deprecate_skip_children();
516541
options.skip_children = Some(true);
517542
}
518543
if matches.opt_present("error-on-unformatted") {
@@ -524,6 +549,7 @@ impl GetOptsOptions {
524549
} else {
525550
let mut unstable_options = vec![];
526551
if matches.opt_present("skip-children") {
552+
deprecate_skip_children();
527553
unstable_options.push("`--skip-children`");
528554
}
529555
if matches.opt_present("error-on-unformatted") {
@@ -574,7 +600,7 @@ impl GetOptsOptions {
574600
return Err(format_err!("Invalid to use `--emit` and `--check`"));
575601
}
576602

577-
options.emit_mode = emit_mode_from_emit_str(emit_str)?;
603+
options.emit_mode = Some(emit_mode_from_emit_str(emit_str)?);
578604
}
579605

580606
if let Some(ref edition_str) = matches.opt_str("edition") {
@@ -590,11 +616,13 @@ impl GetOptsOptions {
590616
}
591617

592618
if !rust_nightly {
593-
if !STABLE_EMIT_MODES.contains(&options.emit_mode) {
594-
return Err(format_err!(
595-
"Invalid value for `--emit` - using an unstable \
596-
value without `--unstable-features`",
597-
));
619+
if let Some(ref emit_mode) = options.emit_mode {
620+
if !STABLE_EMIT_MODES.contains(emit_mode) {
621+
return Err(format_err!(
622+
"Invalid value for `--emit` - using an unstable \
623+
value without `--unstable-features`",
624+
));
625+
}
598626
}
599627
}
600628

@@ -643,8 +671,8 @@ impl CliOptions for GetOptsOptions {
643671
}
644672
if self.check {
645673
config.set().emit_mode(EmitMode::Diff);
646-
} else {
647-
config.set().emit_mode(self.emit_mode);
674+
} else if let Some(emit_mode) = self.emit_mode {
675+
config.set().emit_mode(emit_mode);
648676
}
649677
if self.backup {
650678
config.set().make_backup(true);

0 commit comments

Comments
 (0)