Skip to content

Commit

Permalink
refactor: rename restricts_* output relations to `origin_contains_l…
Browse files Browse the repository at this point in the history
…oan_*`

and similarly, a couple of methods in the `Output` API mentioning "borrows" or "regions" were modernized
  • Loading branch information
lqd committed Dec 20, 2020
1 parent cf7ea4c commit cedee18
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion polonius-engine/src/output/datafrog_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ pub(super) fn compute<T: FactTypes>(
let origin_contains_loan_on_entry_op = origin_contains_loan_on_entry_op.complete();
for &((origin, location), loan) in origin_contains_loan_on_entry_op.iter() {
result
.restricts
.origin_contains_loan_at
.entry(location)
.or_default()
.entry(origin)
Expand Down
2 changes: 1 addition & 1 deletion polonius-engine/src/output/location_insensitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(super) fn compute<T: FactTypes>(
let origin_contains_loan_on_entry = origin_contains_loan_on_entry.complete();
for &(origin, loan) in origin_contains_loan_on_entry.iter() {
result
.restricts_anywhere
.origin_contains_loan_anywhere
.entry(origin)
.or_default()
.insert(loan);
Expand Down
16 changes: 8 additions & 8 deletions polonius-engine/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ pub struct Output<T: FactTypes> {

// these are just for debugging
pub loan_live_at: FxHashMap<T::Point, Vec<T::Loan>>,
pub restricts: FxHashMap<T::Point, BTreeMap<T::Origin, BTreeSet<T::Loan>>>,
pub restricts_anywhere: FxHashMap<T::Origin, BTreeSet<T::Loan>>,
pub origin_contains_loan_at: FxHashMap<T::Point, BTreeMap<T::Origin, BTreeSet<T::Loan>>>,
pub origin_contains_loan_anywhere: FxHashMap<T::Origin, BTreeSet<T::Loan>>,
pub origin_live_on_entry: FxHashMap<T::Point, Vec<T::Origin>>,
pub loan_invalidated_at: FxHashMap<T::Point, Vec<T::Loan>>,
pub subset: FxHashMap<T::Point, BTreeMap<T::Origin, BTreeSet<T::Origin>>>,
Expand Down Expand Up @@ -403,8 +403,8 @@ impl<T: FactTypes> Output<T> {
subset_errors: FxHashMap::default(),
dump_enabled,
loan_live_at: FxHashMap::default(),
restricts: FxHashMap::default(),
restricts_anywhere: FxHashMap::default(),
origin_contains_loan_at: FxHashMap::default(),
origin_contains_loan_anywhere: FxHashMap::default(),
origin_live_on_entry: FxHashMap::default(),
loan_invalidated_at: FxHashMap::default(),
move_errors: FxHashMap::default(),
Expand All @@ -426,25 +426,25 @@ impl<T: FactTypes> Output<T> {
}
}

pub fn borrows_in_scope_at(&self, location: T::Point) -> &[T::Loan] {
pub fn loans_in_scope_at(&self, location: T::Point) -> &[T::Loan] {
match self.loan_live_at.get(&location) {
Some(p) => p,
None => &[],
}
}

pub fn restricts_at(
pub fn origin_contains_loan_at(
&self,
location: T::Point,
) -> Cow<'_, BTreeMap<T::Origin, BTreeSet<T::Loan>>> {
assert!(self.dump_enabled);
match self.restricts.get(&location) {
match self.origin_contains_loan_at.get(&location) {
Some(map) => Cow::Borrowed(map),
None => Cow::Owned(BTreeMap::default()),
}
}

pub fn regions_live_at(&self, location: T::Point) -> &[T::Origin] {
pub fn origins_live_at(&self, location: T::Point) -> &[T::Origin] {
assert!(self.dump_enabled);
match self.origin_live_on_entry.get(&location) {
Some(v) => v,
Expand Down
2 changes: 1 addition & 1 deletion polonius-engine/src/output/naive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub(super) fn compute<T: FactTypes>(
let origin_contains_loan_on_entry = origin_contains_loan_on_entry.complete();
for &(origin, loan, location) in origin_contains_loan_on_entry.iter() {
result
.restricts
.origin_contains_loan_at
.entry(location)
.or_default()
.entry(origin)
Expand Down
8 changes: 4 additions & 4 deletions src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub(crate) fn dump_output(

if output.dump_enabled {
dump_output_fields![
restricts,
restricts_anywhere,
origin_contains_loan_at,
origin_contains_loan_anywhere,
origin_live_on_entry,
loan_invalidated_at,
loan_live_at,
Expand Down Expand Up @@ -434,9 +434,9 @@ fn build_outputs_by_point_for_visualization(
intern,
),
facts_by_point(
output.restricts.iter(),
output.origin_contains_loan_at.iter(),
|(point, origin_to_loans)| (*point, origin_to_loans.clone()),
"restricts".to_string(),
"origin_contains_loan_at".to_string(),
0,
intern,
),
Expand Down

0 comments on commit cedee18

Please sign in to comment.