about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-09-22 19:03:24 +0200
committerGitHub <noreply@github.com>2021-09-22 19:03:24 +0200
commit3bdc894486293af5c741d2f48cfee7d36c57838a (patch)
tree6da4820b836bbed0b000ac7000c4c60ad9ffd195 /compiler
parent0cbddffe25d44c583caa9c2bf853ff7402e326d9 (diff)
parent8c5bdb973a3a154d7ed5d5a8cc7ab39ab7a61376 (diff)
downloadrust-3bdc894486293af5c741d2f48cfee7d36c57838a.tar.gz
rust-3bdc894486293af5c741d2f48cfee7d36c57838a.zip
Rollup merge of #89133 - FabianWolff:issue-79546, r=michaelwoerister
Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`

Fixes #79546.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_session/src/session.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index d6f4a3ae4f1..27215556045 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -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;