]> git.lizzy.rs Git - rust.git/commitdiff
Emit a warning when optimization fuel runs out
authorJonas Schievink <jonasschievink@gmail.com>
Sat, 9 May 2020 22:33:08 +0000 (00:33 +0200)
committerJonas Schievink <jonasschievink@gmail.com>
Sun, 10 May 2020 13:40:17 +0000 (15:40 +0200)
`eprintln!` gets swallowed by Cargo too easily.

src/librustc_session/session.rs
src/test/ui/optimization-fuel-0.rs
src/test/ui/optimization-fuel-0.stderr
src/test/ui/optimization-fuel-1.rs
src/test/ui/optimization-fuel-1.stderr

index 48e36fdb3d4999de3bd7e4719ca2271c26ac80bc..15bd87d5ffdb1244189664efd2e484460103f7c7 100644 (file)
@@ -813,7 +813,7 @@ pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -
                 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;
index f86972b73482677a022b6d806766255b035a46d7..a97c5750f94c34a2fd8eab648e1386b65e493e05 100644 (file)
@@ -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);
index 3ad405b2b50ff4db108c3e39f337a28379579f12..f0e2ebfc37a37d949557d9af08c2b25dc4f42c43 100644 (file)
@@ -1 +1,4 @@
-optimization-fuel-exhausted: Reorder fields of "S1"
+warning: optimization-fuel-exhausted: Reorder fields of "S1"
+
+warning: 1 warning emitted
+
index 98283066361c2615e71296be5693f59db14841d9..a09f91c68abe7b6309b6650f52b84bc7fe3d1d53 100644 (file)
@@ -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);
index 197e45219c3f8726fd710f5e8b0bcdce2379cffd..53eafb05830cbd0586c2dc8dcf4654941cba7d2e 100644 (file)
@@ -1 +1,4 @@
-optimization-fuel-exhausted: Reorder fields of "S2"
+warning: optimization-fuel-exhausted: Reorder fields of "S2"
+
+warning: 1 warning emitted
+