about summary refs log tree commit diff
path: root/src/git-rustfmt
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2018-05-21 15:09:17 +1200
committerNick Cameron <ncameron@mozilla.com>2018-05-21 15:09:17 +1200
commit9a7fac63c8867fc5cf45b3f262f2e385f6992fb3 (patch)
tree5b92f86d78aa4d6a4f2d60174c8d71792af6b392 /src/git-rustfmt
parent95d6b648293b417309d0857b2a93c0cace70c53d (diff)
Remove `format_and_emit_report` from the API
Also changes the header/footer stuff
Diffstat (limited to 'src/git-rustfmt')
-rw-r--r--src/git-rustfmt/main.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/git-rustfmt/main.rs b/src/git-rustfmt/main.rs
index 3eae7cdeabd..545756576c9 100644
--- a/src/git-rustfmt/main.rs
+++ b/src/git-rustfmt/main.rs
@@ -15,13 +15,14 @@ extern crate log;
 extern crate rustfmt_nightly as rustfmt;
 
 use std::env;
+use std::io::stdout;
 use std::path::{Path, PathBuf};
 use std::process::Command;
 use std::str::FromStr;
 
 use getopts::{Matches, Options};
 
-use rustfmt::{format_and_emit_report, load_config, CliOptions, Input};
+use rustfmt::{format_input, load_config, CliOptions, Input};
 
 fn prune_files(files: Vec<&str>) -> Vec<&str> {
     let prefixes: Vec<_> = files
@@ -73,7 +74,14 @@ fn fmt_files(files: &[&str]) -> i32 {
 
     let mut exit_code = 0;
     for file in files {
-        let summary = format_and_emit_report(Input::File(PathBuf::from(file)), &config).unwrap();
+        let (summary, report) = format_input(
+            Input::File(PathBuf::from(file)),
+            &config,
+            Some(&mut stdout()),
+        ).unwrap();
+        if report.has_warnings() {
+            eprintln!("{}", report);
+        }
         if !summary.has_no_errors() {
             exit_code = 1;
         }