Don't print opt fuel messages to stdout because it breaks Rustbuild

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.
This commit is contained in:
Wesley Wiser 2018-10-23 21:13:03 -04:00
parent d586d5d2f5
commit a7bea73292
2 changed files with 2 additions and 2 deletions

View file

@ -868,7 +868,7 @@ impl Session {
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);

View file

@ -944,7 +944,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
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());
}