Skip to content

Commit 3bdc894

Browse files
authored
Rollup merge of #89133 - FabianWolff:issue-79546, r=michaelwoerister
Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0` Fixes #79546.
2 parents 0cbddff + 8c5bdb9 commit 3bdc894

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: compiler/rustc_session/src/session.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,12 @@ impl Session {
902902
let mut fuel = self.optimization_fuel.lock();
903903
ret = fuel.remaining != 0;
904904
if fuel.remaining == 0 && !fuel.out_of_fuel {
905-
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
905+
if self.diagnostic().can_emit_warnings() {
906+
// We only call `msg` in case we can actually emit warnings.
907+
// Otherwise, this could cause a `delay_good_path_bug` to
908+
// trigger (issue #79546).
909+
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
910+
}
906911
fuel.out_of_fuel = true;
907912
} else if fuel.remaining > 0 {
908913
fuel.remaining -= 1;

Diff for: src/test/ui/lint/issue-79546-fuel-ice.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Regression test for the ICE described in #79546.
2+
3+
// compile-flags: --cap-lints=allow -Zfuel=issue79546=0
4+
// check-pass
5+
#![crate_name="issue79546"]
6+
7+
struct S;
8+
fn main() {}

0 commit comments

Comments
 (0)