Skip to content

Commit 6befd69

Browse files
committed
Work around the clones
1 parent d60b7a6 commit 6befd69

File tree

3 files changed

+52
-23
lines changed

3 files changed

+52
-23
lines changed

compiler/rustc_borrowck/src/handle_placeholders.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ pub(crate) fn compute_sccs_applying_placeholder_outlives_constraints<'tcx>(
268268
infcx: &BorrowckInferCtxt<'tcx>,
269269
) -> LoweredConstraints<'tcx> {
270270
let universal_regions = &universal_region_relations.universal_regions;
271-
let (definitions, has_placeholders) = region_definitions(infcx, universal_regions);
271+
272+
let (definitions, has_placeholders) =
273+
region_definitions(infcx, universal_regions, &mut liveness_constraints);
272274

273275
let MirTypeckRegionConstraints {
274276
placeholder_indices,

compiler/rustc_borrowck/src/nll.rs

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use tracing::{debug, instrument};
2121
use crate::borrow_set::BorrowSet;
2222
use crate::consumers::RustcFacts;
2323
use crate::diagnostics::RegionErrors;
24-
use crate::handle_placeholders::compute_sccs_applying_placeholder_outlives_constraints;
24+
use crate::handle_placeholders::{
25+
LoweredConstraints, compute_sccs_applying_placeholder_outlives_constraints,
26+
};
2527
use crate::polonius::legacy::{
2628
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
2729
};
@@ -92,17 +94,30 @@ pub(crate) fn compute_closure_requirements_modulo_opaques<'tcx>(
9294
) -> Option<ClosureRegionRequirements<'tcx>> {
9395
// FIXME(#146079): we shouldn't have to clone all this stuff here.
9496
// Computing the region graph should take at least some of it by reference/`Rc`.
95-
let lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(
97+
let LoweredConstraints {
98+
constraint_sccs,
99+
definitions,
100+
scc_annotations,
101+
outlives_constraints,
102+
type_tests,
103+
liveness_constraints,
104+
universe_causes,
105+
placeholder_indices,
106+
} = compute_sccs_applying_placeholder_outlives_constraints(
96107
constraints.clone(),
97108
&universal_region_relations,
98109
infcx,
99110
);
100111

101-
let placeholder_indices = lowered_constraints.placeholder_indices.clone(); // FIXME!!!
102-
103112
let regioncx = RegionInferenceContext::new(
104113
&infcx,
105-
lowered_constraints,
114+
constraint_sccs,
115+
definitions,
116+
scc_annotations,
117+
outlives_constraints,
118+
type_tests,
119+
liveness_constraints,
120+
universe_causes,
106121
universal_region_relations.clone(),
107122
);
108123

@@ -148,10 +163,28 @@ pub(crate) fn compute_regions<'tcx>(
148163
&lowered_constraints,
149164
);
150165

151-
let placeholder_indices = lowered_constraints.placeholder_indices.clone();
152-
153-
let mut regioncx =
154-
RegionInferenceContext::new(infcx, lowered_constraints, universal_region_relations);
166+
let LoweredConstraints {
167+
constraint_sccs,
168+
definitions,
169+
scc_annotations,
170+
outlives_constraints,
171+
type_tests,
172+
liveness_constraints,
173+
universe_causes,
174+
placeholder_indices,
175+
} = lowered_constraints;
176+
177+
let mut regioncx = RegionInferenceContext::new(
178+
&infcx,
179+
constraint_sccs,
180+
definitions,
181+
scc_annotations,
182+
outlives_constraints,
183+
type_tests,
184+
liveness_constraints,
185+
universe_causes,
186+
universal_region_relations,
187+
);
155188

156189
// If requested for `-Zpolonius=next`, convert NLL constraints to localized outlives constraints
157190
// and use them to compute loan liveness.

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,23 +312,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
312312
/// of constraints produced by the MIR type check.
313313
pub(crate) fn new(
314314
infcx: &BorrowckInferCtxt<'tcx>,
315-
lowered_constraints: LoweredConstraints<'tcx>,
315+
constraint_sccs: Sccs<RegionVid, ConstraintSccIndex>,
316+
definitions: Frozen<IndexVec<RegionVid, RegionDefinition<'tcx>>>,
317+
scc_annotations: IndexVec<ConstraintSccIndex, RegionTracker>,
318+
outlives_constraints: Frozen<OutlivesConstraintSet<'tcx>>,
319+
type_tests: Vec<TypeTest<'tcx>>,
320+
mut liveness_constraints: LivenessValues,
321+
universe_causes: FxIndexMap<UniverseIndex, UniverseInfo<'tcx>>,
316322
universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
317323
) -> Self {
318-
let LoweredConstraints {
319-
constraint_sccs,
320-
definitions,
321-
outlives_constraints,
322-
scc_annotations,
323-
type_tests,
324-
mut liveness_constraints,
325-
universe_causes,
326-
placeholder_indices,
327-
} = lowered_constraints;
328-
329324
debug!("universal_regions: {:#?}", universal_region_relations.universal_regions);
330325
debug!("outlives constraints: {:#?}", outlives_constraints);
331-
debug!("placeholder_indices: {:#?}", placeholder_indices);
332326
debug!("type tests: {:#?}", type_tests);
333327

334328
let constraint_graph = Frozen::freeze(outlives_constraints.graph(definitions.len()));

0 commit comments

Comments
 (0)