Skip to content

Commit

Permalink
Rollup merge of #89133 - FabianWolff:issue-79546, r=michaelwoerister
Browse files Browse the repository at this point in the history
Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`

Fixes #79546.
  • Loading branch information
the8472 authored Sep 22, 2021
2 parents 0cbddff + 8c5bdb9 commit 3bdc894
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,12 @@ impl Session {
let mut fuel = self.optimization_fuel.lock();
ret = fuel.remaining != 0;
if fuel.remaining == 0 && !fuel.out_of_fuel {
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
if self.diagnostic().can_emit_warnings() {
// We only call `msg` in case we can actually emit warnings.
// Otherwise, this could cause a `delay_good_path_bug` to
// trigger (issue #79546).
self.warn(&format!("optimization-fuel-exhausted: {}", msg()));
}
fuel.out_of_fuel = true;
} else if fuel.remaining > 0 {
fuel.remaining -= 1;
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/lint/issue-79546-fuel-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Regression test for the ICE described in #79546.

// compile-flags: --cap-lints=allow -Zfuel=issue79546=0
// check-pass
#![crate_name="issue79546"]

struct S;
fn main() {}

0 comments on commit 3bdc894

Please sign in to comment.