about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmanda Stjerna <amanda.stjerna@it.uu.se>2024-05-28 16:02:09 +0200
committerAmanda Stjerna <amanda.stjerna@it.uu.se>2024-05-28 16:02:09 +0200
commit8066ebc294f110a758fb2b44a68138db10d38ce0 (patch)
treee4b11daddae1994aaf3872d79ded499b605d081a
parente15564672e4e35a8697b717d49db1bfc6579c612 (diff)
downloadrust-8066ebc294f110a758fb2b44a68138db10d38ce0.tar.gz
rust-8066ebc294f110a758fb2b44a68138db10d38ce0.zip
Move the rest of the logic into `add_extra_drop_facts()`
-rw-r--r--compiler/rustc_borrowck/src/type_check/liveness/trace.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
index 92b70a09a88..50843c602cc 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
@@ -81,8 +81,6 @@ pub(super) fn trace<'mir, 'tcx>(
         borrowck_context.constraints.liveness_constraints.loans = Some(live_loans);
     };
 
-    let polonius_facts_gathered = typeck.borrowck_context.all_facts.is_some();
-
     let cx = LivenessContext {
         typeck,
         body,
@@ -95,9 +93,7 @@ pub(super) fn trace<'mir, 'tcx>(
 
     let mut results = LivenessResults::new(cx);
 
-    if polonius_facts_gathered {
-        results.add_extra_drop_facts(relevant_live_locals.iter().copied().collect());
-    }
+    results.add_extra_drop_facts(&relevant_live_locals);
 
     results.compute_for_all_locals(relevant_live_locals);
 
@@ -220,16 +216,17 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
     ///
     /// Add facts for all locals with free regions, since regions may outlive
     /// the function body only at certain nodes in the CFG.
-    fn add_extra_drop_facts(&mut self, relevant_live_locals: FxIndexSet<Local>) {
+    fn add_extra_drop_facts(&mut self, relevant_live_locals: &[Local]) -> Option<()> {
         let drop_used = self
             .cx
             .typeck
             .borrowck_context
             .all_facts
             .as_ref()
-            .map(|facts| facts.var_dropped_at.clone())
-            .into_iter()
-            .flatten();
+            .map(|facts| facts.var_dropped_at.clone())?;
+
+        let relevant_live_locals: FxIndexSet<_> = relevant_live_locals.iter().copied().collect();
+
         let locations = IntervalSet::new(self.cx.elements.num_points());
 
         for (local, location_index) in drop_used {
@@ -250,6 +247,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
                 }
             }
         }
+        Some(())
     }
 
     /// Clear the value of fields that are "per local variable".