about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-11-01 03:33:11 +0100
committerGitHub <noreply@github.com>2021-11-01 03:33:11 +0100
commit6ce0ef5e89074cb6c452f9cd19f1211048663a13 (patch)
tree50603200f91a57573e69415a58cce3d32364d66f
parent86f5b8a52dedf0cf318757113696622384ca55d9 (diff)
parent3a95338f312c630e89c35ffa9e5ece97520e5253 (diff)
downloadrust-6ce0ef5e89074cb6c452f9cd19f1211048663a13.tar.gz
rust-6ce0ef5e89074cb6c452f9cd19f1211048663a13.zip
Rollup merge of #90452 - tmiasko:promote-candidate, r=cjgillot
Remove unnecessary `Option` from `promote_candidate` return type
-rw-r--r--compiler/rustc_const_eval/src/transform/promote_consts.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs
index 67664d2ede1..7bf378601e0 100644
--- a/compiler/rustc_const_eval/src/transform/promote_consts.rs
+++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs
@@ -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;
@@ -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
     }
 }
 
@@ -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