Skip to content

Commit

Permalink
Rollup merge of rust-lang#72067 - jonas-schievink:fuel-warn, r=varkor
Browse files Browse the repository at this point in the history
Emit a warning when optimization fuel runs out

`eprintln!` gets swallowed by Cargo too easily.
  • Loading branch information
Dylan-DPC authored May 11, 2020
2 parents d58d31e + 62116c3 commit c29dc3e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustc_session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ impl Session {
let mut fuel = self.optimization_fuel.lock();
ret = fuel.remaining != 0;
if fuel.remaining == 0 && !fuel.out_of_fuel {
eprintln!("optimization-fuel-exhausted: {}", msg());
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
fuel.out_of_fuel = true;
} else if fuel.remaining > 0 {
fuel.remaining -= 1;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/optimization-fuel-0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use std::mem::size_of;

// (#55495: The --error-format is to sidestep an issue in our test harness)
// compile-flags: --error-format human -Z fuel=foo=0
// compile-flags: -Z fuel=foo=0

struct S1(u8, u16, u8);
struct S2(u8, u16, u8);
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/optimization-fuel-0.stderr
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
optimization-fuel-exhausted: Reorder fields of "S1"
warning: optimization-fuel-exhausted: Reorder fields of "S1"

warning: 1 warning emitted

3 changes: 1 addition & 2 deletions src/test/ui/optimization-fuel-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use std::mem::size_of;

// (#55495: The --error-format is to sidestep an issue in our test harness)
// compile-flags: --error-format human -Z fuel=foo=1
// compile-flags: -Z fuel=foo=1

struct S1(u8, u16, u8);
struct S2(u8, u16, u8);
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/optimization-fuel-1.stderr
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
optimization-fuel-exhausted: Reorder fields of "S2"
warning: optimization-fuel-exhausted: Reorder fields of "S2"

warning: 1 warning emitted

0 comments on commit c29dc3e

Please sign in to comment.