Skip to content

Commit

Permalink
promote_consts: eargerly return when there are no candidates
Browse files Browse the repository at this point in the history
There is no need to do it when mustn't.
  • Loading branch information
tesuji committed Jun 16, 2024
1 parent 2870891 commit c036594
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_mir_transform/src/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![];
Expand Down

0 comments on commit c036594

Please sign in to comment.