Skip to content

Commit

Permalink
Rollup merge of rust-lang#90452 - tmiasko:promote-candidate, r=cjgillot
Browse files Browse the repository at this point in the history
Remove unnecessary `Option` from `promote_candidate` return type
  • Loading branch information
matthiaskrgr authored Nov 1, 2021
2 parents 86f5b8a + 3a95338 commit 6ce0ef5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions compiler/rustc_const_eval/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
new_temp
}

fn promote_candidate(
mut self,
candidate: Candidate,
next_promoted_id: usize,
) -> Option<Body<'tcx>> {
fn promote_candidate(mut self, candidate: Candidate, next_promoted_id: usize) -> Body<'tcx> {
let def = self.source.source.with_opt_param();
let mut rvalue = {
let promoted = &mut self.promoted;
Expand Down Expand Up @@ -938,7 +934,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {

let span = self.promoted.span;
self.assign(RETURN_PLACE, rvalue, span);
Some(self.promoted)
self.promoted
}
}

Expand Down Expand Up @@ -1011,11 +1007,9 @@ pub fn promote_candidates<'tcx>(
keep_original: false,
};

//FIXME(oli-obk): having a `maybe_push()` method on `IndexVec` might be nice
if let Some(mut promoted) = promoter.promote_candidate(candidate, promotions.len()) {
promoted.source.promoted = Some(promotions.next_index());
promotions.push(promoted);
}
let mut promoted = promoter.promote_candidate(candidate, promotions.len());
promoted.source.promoted = Some(promotions.next_index());
promotions.push(promoted);
}

// Insert each of `extra_statements` before its indicated location, which
Expand Down

0 comments on commit 6ce0ef5

Please sign in to comment.