diff options
| author | Lzu Tao <taolzu@gmail.com> | 2024-06-01 11:18:34 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2024-06-16 09:39:42 +0000 |
| commit | c03659443a70b018e49f2ae72645d64eac58c7f7 (patch) | |
| tree | 5e152e3c469aa5ca7c3ba9e028ca1bfdce6fe91f | |
| parent | 28708912fb011f1c7666281ba5a22862f4503d4d (diff) | |
| download | rust-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.rs | 5 |
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![]; |
