Skip to content

Commit 5055864

Browse files
committed
disable NLL liveness optimization when using polonius
in NLLs some locals are marked live at all points if one of their regions escapes the function but that doesn't work in a flow-sensitive setting like polonius
1 parent 12445e0 commit 5055864

File tree

1 file changed

+13
-5
lines changed
  • compiler/rustc_borrowck/src/type_check/liveness

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@ pub(super) fn generate<'a, 'tcx>(
3838
) {
3939
debug!("liveness::generate");
4040

41-
let free_regions = regions_that_outlive_free_regions(
42-
typeck.infcx.num_region_vars(),
43-
&typeck.universal_regions,
44-
&typeck.constraints.outlives_constraints,
45-
);
41+
// NLLs can avoid computing some liveness data here because its constraints are
42+
// location-insensitive, but that doesn't work in polonius: locals whose type contains a region
43+
// that outlives a free region are not necessarily live everywhere in a flow-sensitive setting,
44+
// unlike NLLs.
45+
let free_regions = if !typeck.tcx().sess.opts.unstable_opts.polonius.is_next_enabled() {
46+
regions_that_outlive_free_regions(
47+
typeck.infcx.num_region_vars(),
48+
&typeck.universal_regions,
49+
&typeck.constraints.outlives_constraints,
50+
)
51+
} else {
52+
typeck.universal_regions.universal_regions_iter().collect()
53+
};
4654
let (relevant_live_locals, boring_locals) =
4755
compute_relevant_live_locals(typeck.tcx(), &free_regions, body);
4856

0 commit comments

Comments
 (0)