Skip to content

Commit d67fa2a

Browse files
committed
naive: the loan_invalidated_at relation does not need to be a variable
1 parent a998edd commit d67fa2a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

polonius-engine/src/output/naive.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ pub(super) fn compute<T: FactTypes>(
4343
let loan_live_at = iteration.variable::<((T::Loan, T::Point), ())>("loan_live_at");
4444

4545
// `loan_invalidated_at` facts, stored ready for joins
46-
let loan_invalidated_at =
47-
iteration.variable::<((T::Loan, T::Point), ())>("loan_invalidated_at");
48-
loan_invalidated_at.extend(
46+
let loan_invalidated_at = Relation::from_iter(
4947
ctx.loan_invalidated_at
5048
.iter()
5149
.map(|&(loan, point)| ((loan, point), ())),
@@ -112,7 +110,7 @@ pub(super) fn compute<T: FactTypes>(
112110
// .. and then start iterating rules!
113111
while iteration.changed() {
114112
// Cleanup step: remove symmetries
115-
// - remove regions which are `subset`s of themselves
113+
// - remove origins which are `subset`s of themselves
116114
//
117115
// FIXME: investigate whether is there a better way to do that without complicating
118116
// the rules too much, because it would also require temporary variables and
@@ -222,12 +220,16 @@ pub(super) fn compute<T: FactTypes>(
222220

223221
// Rule 8: compute illegal access errors, i.e. an invalidation of a live loan.
224222
//
223+
// Here again, this join acts as a pure filter and could be a more efficient leapjoin.
224+
// However, similarly to the `origin_live_on_entry` example described above, the
225+
// leapjoin with a single `filter_with` leaper would currently not be well-formed.
226+
//
225227
// errors(Loan, Point) :-
226228
// loan_invalidated_at(Loan, Point),
227229
// loan_live_at(Loan, Point).
228230
errors.from_join(
229-
&loan_invalidated_at,
230231
&loan_live_at,
232+
&loan_invalidated_at,
231233
|&(loan, point), _, _| (loan, point),
232234
);
233235

0 commit comments

Comments
 (0)