Skip to content

Commit 62116c3

Browse files
Emit a warning when optimization fuel runs out
`eprintln!` gets swallowed by Cargo too easily.
1 parent bad3bf6 commit 62116c3

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

src/librustc_session/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ impl Session {
813813
let mut fuel = self.optimization_fuel.lock();
814814
ret = fuel.remaining != 0;
815815
if fuel.remaining == 0 && !fuel.out_of_fuel {
816-
eprintln!("optimization-fuel-exhausted: {}", msg());
816+
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
817817
fuel.out_of_fuel = true;
818818
} else if fuel.remaining > 0 {
819819
fuel.remaining -= 1;

src/test/ui/optimization-fuel-0.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use std::mem::size_of;
66

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

109
struct S1(u8, u16, u8);
1110
struct S2(u8, u16, u8);
+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
optimization-fuel-exhausted: Reorder fields of "S1"
1+
warning: optimization-fuel-exhausted: Reorder fields of "S1"
2+
3+
warning: 1 warning emitted
4+

src/test/ui/optimization-fuel-1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use std::mem::size_of;
66

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

109
struct S1(u8, u16, u8);
1110
struct S2(u8, u16, u8);
+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
optimization-fuel-exhausted: Reorder fields of "S2"
1+
warning: optimization-fuel-exhausted: Reorder fields of "S2"
2+
3+
warning: 1 warning emitted
4+

0 commit comments

Comments
 (0)