Skip to content

Commit 17856e8

Browse files
committed
Merge pull request #859 from solidsnack/master
Write non-output to stderr when there is output
2 parents 3fddb98 + 867b507 commit 17856e8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/bin/rustfmt.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ use std::str::FromStr;
2828

2929
use getopts::{Matches, Options};
3030

31+
macro_rules! msg {
32+
($($arg:tt)*) => (
33+
match writeln!(&mut ::std::io::stderr(), $($arg)* ) {
34+
Ok(_) => {},
35+
Err(x) => panic!("Unable to write to stderr: {}", x),
36+
}
37+
)
38+
}
39+
3140
/// Rustfmt operations.
3241
enum Operation {
3342
/// Format files and their child modules.
@@ -203,7 +212,7 @@ fn execute() -> i32 {
203212
path = path_tmp;
204213
};
205214
if let Some(path) = path.as_ref() {
206-
println!("Using rustfmt config file {}", path.display());
215+
msg!("Using rustfmt config file {}", path.display());
207216
}
208217
for file in files {
209218
// Check the file directory if the config-path could not be read or not provided
@@ -213,9 +222,9 @@ fn execute() -> i32 {
213222
for {}",
214223
file.display()));
215224
if let Some(path) = path_tmp.as_ref() {
216-
println!("Using rustfmt config file {} for {}",
217-
path.display(),
218-
file.display());
225+
msg!("Using rustfmt config file {} for {}",
226+
path.display(),
227+
file.display());
219228
}
220229
config = config_tmp;
221230
}

0 commit comments

Comments
 (0)