]> git.lizzy.rs Git - rust.git/commitdiff
Don't print opt fuel messages to stdout because it breaks Rustbuild
authorWesley Wiser <wwiser@gmail.com>
Wed, 24 Oct 2018 01:13:03 +0000 (21:13 -0400)
committerWesley Wiser <wwiser@gmail.com>
Tue, 30 Oct 2018 02:51:20 +0000 (22:51 -0400)
Rustbuild passes `--message-format json` to the compiler invocations
which causes JSON to be emitted on stdout. Printing optimization fuel
messages to stdout breaks the json and causes Rustbuild to fail.

Work around this by emitting optimization fuel related messages on
stderr instead.

src/librustc/session/mod.rs
src/librustc_driver/lib.rs

index a17825a877d88cb45ecaba6e31d2cc6a15e0860a..fe94b62ef19e266c6e0989daba86a1992fd46d45 100644 (file)
@@ -868,7 +868,7 @@ pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -
                 let fuel = self.optimization_fuel_limit.get();
                 ret = fuel != 0;
                 if fuel == 0 && !self.out_of_fuel.get() {
-                    println!("optimization-fuel-exhausted: {}", msg());
+                    eprintln!("optimization-fuel-exhausted: {}", msg());
                     self.out_of_fuel.set(true);
                 } else if fuel > 0 {
                     self.optimization_fuel_limit.set(fuel - 1);
index 276b7290c2ef012de4ac7e0c83b48a1a77702232..8a7d4a01743106b5dd8797fe44f4416d440fa88b 100644 (file)
@@ -944,7 +944,7 @@ fn build_controller(self: Box<Self>,
             control.compilation_done.callback = box move |state| {
                 old_callback(state);
                 let sess = state.session;
-                println!("Fuel used by {}: {}",
+                eprintln!("Fuel used by {}: {}",
                     sess.print_fuel_crate.as_ref().unwrap(),
                     sess.print_fuel.get());
             }