Skip to content

Commit 00e8121

Browse files
committed
Work around the clones
1 parent d60b7a6 commit 00e8121

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

compiler/rustc_borrowck/src/consumers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct BodyWithBorrowckFacts<'tcx> {
9494
/// [`calculate_borrows_out_of_scope_at_location`].
9595
pub region_inference_context: RegionInferenceContext<'tcx>,
9696
/// The inferred region values. These are included because they
97-
/// are necesssary as input to
97+
/// are necessary as input to
9898
/// [`calculate_borrows_out_of_scope_at_location`].
9999
pub inferred_regions: InferredRegions<'tcx>,
100100
/// The table that maps Polonius points to locations in the table.

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: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::constraints::graph::NormalConstraintGraph;
2626
use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
2727
use crate::dataflow::BorrowIndex;
2828
use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
29-
use crate::handle_placeholders::{LoweredConstraints, RegionTracker};
29+
use crate::handle_placeholders::RegionTracker;
3030
use crate::polonius::LiveLoans;
3131
use crate::polonius::legacy::PoloniusOutput;
3232
use crate::region_infer::values::{
@@ -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)