Skip to content

Commit

Permalink
replace type parameters in polonius bin
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Sep 25, 2019
1 parent 7689696 commit 16351fd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
30 changes: 15 additions & 15 deletions polonius-engine/src/output/datafrog_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ pub(super) fn compute<T: FactTypes>(
let mut result = Output::new(dump_enabled);

let var_maybe_initialized_on_exit = initialization::init_var_maybe_initialized_on_exit(
all_facts.child.clone(),
all_facts.path_belongs_to_var.clone(),
all_facts.initialized_at.clone(),
all_facts.moved_out_at.clone(),
all_facts.path_accessed_at.clone(),
&all_facts.cfg_edge.clone(),
all_facts.child,
all_facts.path_belongs_to_var,
all_facts.initialized_at,
all_facts.moved_out_at,
all_facts.path_accessed_at,
&all_facts.cfg_edge,
&mut result,
);

let region_live_at = liveness::init_region_live_at(
all_facts.var_used.clone(),
all_facts.var_drop_used.clone(),
all_facts.var_defined.clone(),
all_facts.var_uses_region.clone(),
all_facts.var_drops_region.clone(),
var_maybe_initialized_on_exit.clone(),
&all_facts.cfg_edge.clone(),
all_facts.universal_region.clone(),
all_facts.var_used,
all_facts.var_drop_used,
all_facts.var_defined,
all_facts.var_uses_region,
all_facts.var_drops_region,
var_maybe_initialized_on_exit,
&all_facts.cfg_edge,
all_facts.universal_region,
&mut result,
);

Expand All @@ -55,7 +55,7 @@ pub(super) fn compute<T: FactTypes>(
// static inputs
let cfg_edge_rel = Relation::from_iter(all_facts.cfg_edge.iter().map(|&(p, q)| (p, q)));

let killed_rel: Relation<(T::Loan, T::Point)> = all_facts.killed.clone().into();
let killed_rel: Relation<(T::Loan, T::Point)> = all_facts.killed.into();

// `invalidates` facts, stored ready for joins
let invalidates = iteration.variable::<((T::Loan, T::Point), ())>("invalidates");
Expand Down
12 changes: 6 additions & 6 deletions polonius-engine/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ fn compare_errors<Loan: Atom, Point: Atom>(

impl<T: FactTypes> Output<T> {
pub fn compute(
all_facts: AllFacts<T>,
all_facts: &AllFacts<T>,
algorithm: Algorithm,
dump_enabled: bool,
) -> Self {
match algorithm {
Algorithm::Naive => naive::compute(dump_enabled, all_facts),
Algorithm::DatafrogOpt => datafrog_opt::compute(dump_enabled, all_facts),
Algorithm::Naive => naive::compute(dump_enabled, all_facts.clone()),
Algorithm::DatafrogOpt => datafrog_opt::compute(dump_enabled, all_facts.clone()),
Algorithm::LocationInsensitive => {
location_insensitive::compute(dump_enabled, all_facts)
location_insensitive::compute(dump_enabled, all_facts.clone())
}
Algorithm::Compare => {
let naive_output = naive::compute(dump_enabled, all_facts.clone());
let opt_output = datafrog_opt::compute(dump_enabled, all_facts);
let opt_output = datafrog_opt::compute(dump_enabled, all_facts.clone());
if compare_errors(&naive_output.errors, &opt_output.errors) {
panic!(concat!(
"The errors reported by the naive algorithm differ from ",
Expand All @@ -143,7 +143,7 @@ impl<T: FactTypes> Output<T> {
}
opt_output
}
Algorithm::Hybrid => hybrid::compute(dump_enabled, all_facts),
Algorithm::Hybrid => hybrid::compute(dump_enabled, all_facts.clone()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::hash::Hash;
use std::io::{self, Write};
use std::path::PathBuf;

pub(crate) type Output = PoloniusEngineOutput<T>;
pub(crate) type Output = PoloniusEngineOutput<LocalFacts>;

pub(crate) fn dump_output(
output: &Output,
Expand Down
15 changes: 13 additions & 2 deletions src/facts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use polonius_engine;
use polonius_engine::{self, FactTypes};

pub(crate) type AllFacts = polonius_engine::AllFacts<T>;
#[derive(Copy, Clone, Debug)]
pub(crate) struct LocalFacts;

pub(crate) type AllFacts = polonius_engine::AllFacts<LocalFacts>;

macro_rules! index_type {
($t:ident) => {
Expand Down Expand Up @@ -36,3 +39,11 @@ index_type!(Loan);
index_type!(Point);
index_type!(Variable);
index_type!(MovePath);

impl FactTypes for LocalFacts {
type Origin = Origin;
type Loan = Loan;
type Point = Point;
type Variable = Variable;
type MovePath = MovePath;
}

0 comments on commit 16351fd

Please sign in to comment.