From d216c358ef6fe626af6bfe1657291b093d920da2 Mon Sep 17 00:00:00 2001 From: Jason Dusek Date: Tue, 8 Mar 2016 21:52:58 -0800 Subject: [PATCH 1/3] Write non-output to stderr when there is output --- src/bin/rustfmt.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index 1524384fc128..b7492fdc2fe3 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -28,6 +28,15 @@ use std::str::FromStr; use getopts::{Matches, Options}; +macro_rules! msg( + ($($arg:tt)*) => ( + match writeln!(&mut ::std::io::stderr(), $($arg)* ) { + Ok(_) => {}, + Err(x) => panic!("Unable to write to stderr: {}", x), + } + ) +); + /// Rustfmt operations. enum Operation { /// Format files and their child modules. @@ -203,7 +212,7 @@ fn execute() -> i32 { path = path_tmp; }; if let Some(path) = path.as_ref() { - println!("Using rustfmt config file {}", path.display()); + msg!("Using rustfmt config file {}", path.display()); } for file in files { // Check the file directory if the config-path could not be read or not provided @@ -213,7 +222,7 @@ fn execute() -> i32 { for {}", file.display())); if let Some(path) = path_tmp.as_ref() { - println!("Using rustfmt config file {} for {}", + msg!("Using rustfmt config file {} for {}", path.display(), file.display()); } From 223df90c81d5e94796797067fe4176cd2e00a93c Mon Sep 17 00:00:00 2001 From: Jason Dusek Date: Wed, 9 Mar 2016 11:03:57 -0800 Subject: [PATCH 2/3] Align arguments --- src/bin/rustfmt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index b7492fdc2fe3..ee5877e25caa 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -223,8 +223,8 @@ fn execute() -> i32 { file.display())); if let Some(path) = path_tmp.as_ref() { msg!("Using rustfmt config file {} for {}", - path.display(), - file.display()); + path.display(), + file.display()); } config = config_tmp; } From 867b5074aa2d01ba72a2de89865fb7a7aa25a76a Mon Sep 17 00:00:00 2001 From: Jason Dusek Date: Fri, 11 Mar 2016 00:41:11 -0800 Subject: [PATCH 3/3] Use braces, not parens, for macro def --- src/bin/rustfmt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index ee5877e25caa..062c60e10659 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -28,14 +28,14 @@ use std::str::FromStr; use getopts::{Matches, Options}; -macro_rules! msg( +macro_rules! msg { ($($arg:tt)*) => ( match writeln!(&mut ::std::io::stderr(), $($arg)* ) { Ok(_) => {}, Err(x) => panic!("Unable to write to stderr: {}", x), } ) -); +} /// Rustfmt operations. enum Operation {