Skip to content

Commit 56099cd

Browse files
committed
Refactor some things into LivenessComputation
1 parent 33a9201 commit 56099cd

2 files changed

Lines changed: 197 additions & 134 deletions

File tree

‎compiler/rustc_borrowck/src/type_check/liveness/mod.rs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
use itertools::{Either, Itertools};
22
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_index::interval::IntervalSet;
34
use rustc_middle::mir::visit::{TyContext, Visitor};
45
use rustc_middle::mir::{Body, Local, Location, SourceInfo};
56
use rustc_middle::ty::relate::Relate;
67
use rustc_middle::ty::{GenericArgsRef, Region, RegionVid, Ty, TyCtxt, TypeVisitable};
78
use rustc_mir_dataflow::move_paths::MoveData;
8-
use rustc_mir_dataflow::points::DenseLocationMap;
9+
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
910
use rustc_span::span_bug;
11+
use rustc_trait_selection::traits::outlives_for_liveness::FreeRegionsVisitor;
1012
use tracing::debug;
1113

1214
use super::TypeChecker;
15+
use crate::BorrowckInferCtxt;
1316
use crate::constraints::OutlivesConstraintSet;
1417
use crate::polonius::{PoloniusContext, record_live_region_variance};
1518
use crate::region_infer::values::LivenessValues;
@@ -229,3 +232,18 @@ impl<'a, 'tcx> LiveVariablesVisitor<'a, 'tcx> {
229232
}
230233
}
231234
}
235+
236+
pub(crate) fn make_all_regions_live<'tcx>(
237+
infcx: &BorrowckInferCtxt<'tcx>,
238+
universal_regions: &UniversalRegions<'tcx>,
239+
liveness: &mut LivenessValues,
240+
value: impl TypeVisitable<TyCtxt<'tcx>>,
241+
live_at: &IntervalSet<PointIndex>,
242+
) {
243+
debug!("make_all_regions_live(value={value:?})");
244+
value.visit_with(&mut FreeRegionsVisitor {
245+
tcx: infcx.tcx,
246+
param_env: infcx.param_env,
247+
op: |r| liveness.add_points(universal_regions.to_region_vid(r), live_at),
248+
});
249+
}

0 commit comments

Comments
 (0)