|
39 | 39 | //! 2) once that is done, variance data is transferred, and the NLL region liveness is converted to
|
40 | 40 | //! the polonius shape. That's the main [PoloniusContext].
|
41 | 41 | //! 3) during region inference, that data and the NLL outlives constraints are used to create the
|
42 |
| -//! localized outlives constraints, as described above. |
43 |
| -//! 4) transfer these constraints back to the main borrowck procedure: it handles computing errors |
44 |
| -//! and diagnostics, debugging and MIR dumping concerns. |
| 42 | +//! localized outlives constraints, as described above. That's the [PoloniusDiagnosticsContext]. |
| 43 | +//! 4) transfer this back to the main borrowck procedure: it handles computing errors and |
| 44 | +//! diagnostics, debugging and MIR dumping concerns. |
45 | 45 |
|
46 | 46 | mod constraints;
|
47 | 47 | mod dump;
|
@@ -89,6 +89,12 @@ pub(crate) struct PoloniusContext {
|
89 | 89 | live_region_variances: BTreeMap<RegionVid, ConstraintDirection>,
|
90 | 90 | }
|
91 | 91 |
|
| 92 | +/// This struct holds the data needed by the borrowck error computation and diagnostics. Its data is |
| 93 | +/// computed from the [PoloniusContext] when computing NLL regions. |
| 94 | +pub(crate) struct PoloniusDiagnosticsContext { |
| 95 | + localized_outlives_constraints: LocalizedOutlivesConstraintSet, |
| 96 | +} |
| 97 | + |
92 | 98 | /// The direction a constraint can flow into. Used to create liveness constraints according to
|
93 | 99 | /// variance.
|
94 | 100 | #[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
@@ -135,13 +141,15 @@ impl PoloniusContext {
|
135 | 141 | ///
|
136 | 142 | /// Then, this graph is traversed, and combined with kills, reachability is recorded as loan
|
137 | 143 | /// liveness, to be used by the loan scope and active loans computations.
|
| 144 | + /// |
| 145 | + /// The constraint data will be used to compute errors and diagnostics. |
138 | 146 | pub(crate) fn compute_loan_liveness<'tcx>(
|
139 | 147 | &self,
|
140 | 148 | tcx: TyCtxt<'tcx>,
|
141 | 149 | regioncx: &mut RegionInferenceContext<'tcx>,
|
142 | 150 | body: &Body<'tcx>,
|
143 | 151 | borrow_set: &BorrowSet<'tcx>,
|
144 |
| - ) -> LocalizedOutlivesConstraintSet { |
| 152 | + ) -> PoloniusDiagnosticsContext { |
145 | 153 | let mut localized_outlives_constraints = LocalizedOutlivesConstraintSet::default();
|
146 | 154 | convert_typeck_constraints(
|
147 | 155 | tcx,
|
@@ -173,6 +181,6 @@ impl PoloniusContext {
|
173 | 181 | );
|
174 | 182 | regioncx.record_live_loans(live_loans);
|
175 | 183 |
|
176 |
| - localized_outlives_constraints |
| 184 | + PoloniusDiagnosticsContext { localized_outlives_constraints } |
177 | 185 | }
|
178 | 186 | }
|
0 commit comments