about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2024-06-01 11:18:34 +0000
committerLzu Tao <taolzu@gmail.com>2024-06-16 09:39:42 +0000
commitc03659443a70b018e49f2ae72645d64eac58c7f7 (patch)
tree5e152e3c469aa5ca7c3ba9e028ca1bfdce6fe91f
parent28708912fb011f1c7666281ba5a22862f4503d4d (diff)
downloadrust-c03659443a70b018e49f2ae72645d64eac58c7f7.tar.gz
rust-c03659443a70b018e49f2ae72645d64eac58c7f7.zip
promote_consts: eargerly return when there are no candidates
There is no need to do it when mustn't.
-rw-r--r--compiler/rustc_mir_transform/src/promote_consts.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs
index a0ee4c432c6..2f7d8d96eac 100644
--- a/compiler/rustc_mir_transform/src/promote_consts.rs
+++ b/compiler/rustc_mir_transform/src/promote_consts.rs
@@ -970,6 +970,11 @@ fn promote_candidates<'tcx>(
     // Visit candidates in reverse, in case they're nested.
     debug!(promote_candidates = ?candidates);
 
+    // eagerly fail fast
+    if candidates.is_empty() {
+        return IndexVec::new();
+    }
+
     let mut promotions = IndexVec::new();
 
     let mut extra_statements = vec![];