Skip to content

Commit

Permalink
Emit a warning when optimization fuel runs out
Browse files Browse the repository at this point in the history
`eprintln!` gets swallowed by Cargo too easily.
  • Loading branch information
jonas-schievink committed May 10, 2020
1 parent bad3bf6 commit 62116c3
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
Expand Up @@ -813,7 +813,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
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
@@ -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
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
@@ -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 62116c3

Please sign in to comment.