From 1b1b92ed33d64bc3d722be6f13f9fc6a23faa858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 8 Sep 2026 18:32:32 +0200 Subject: [PATCH] Use `DenseBit` for `drop_live_at` in liveness tracing --- .../src/type_check/liveness/trace.rs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 89a8899a991c9..dc8e8e077be95 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -110,7 +110,7 @@ struct LivenessResults<'a, 'typeck, 'tcx> { /// Points where the current variable is "drop live" -- meaning /// that there is no future "full use" that may use its value, but /// there is a future drop. - drop_live_at: IntervalSet, + drop_live_at: DenseBitSet, /// Locations where drops may occur. drop_locations: Vec, @@ -126,7 +126,7 @@ impl<'a, 'typeck, 'tcx> LivenessResults<'a, 'typeck, 'tcx> { cx, defs: DenseBitSet::new_empty(num_points), use_live_at: IntervalSet::new(num_points), - drop_live_at: IntervalSet::new(num_points), + drop_live_at: DenseBitSet::new_empty(num_points), drop_locations: vec![], stack: vec![], } @@ -146,12 +146,16 @@ impl<'a, 'typeck, 'tcx> LivenessResults<'a, 'typeck, 'tcx> { } if !self.drop_live_at.is_empty() { - self.cx.add_drop_live_facts_for( - local, - local_ty, - &self.drop_locations, - &self.drop_live_at, - ); + // `drop_live_at` is using a DenseBitSet, but `add_drop_live_facts_for` expects + // an IntervalSet. We thus convert between those two here. + let mut set: IntervalSet = + IntervalSet::new(self.drop_live_at.domain_size()); + for item in self.drop_live_at.iter() { + // We iterate the `drop_live_at` set from smallest to largest values, so + // we can use append to add things to the interval set at the end. + set.append(item); + } + self.cx.add_drop_live_facts_for(local, local_ty, &self.drop_locations, &set); } } }