Skip to content

Commit ff280f8

Browse files
clippy fixes
1 parent 61d5395 commit ff280f8

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

src/conversions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ convert_enums!(
111111
v -> egglog::Term::Var((&v.name).into()),
112112
egglog::Term::Var(v) => TermVar { name: v.to_string() };
113113
TermApp[trait=Hash](name: String, args: Vec<usize>)
114-
a -> egglog::Term::App(a.name.clone().into(), a.args.to_vec()),
114+
a -> egglog::Term::App(a.name.clone(), a.args.to_vec()),
115115
egglog::Term::App(s, a) => TermApp {
116116
name: s.to_string(),
117117
args: a.to_vec()
@@ -461,11 +461,11 @@ convert_struct!(
461461
)
462462
r -> egglog::RunReport {
463463
updated: r.updated,
464-
search_and_apply_time_per_rule: r.search_and_apply_time_per_rule.iter().map(|(k, v)| (k.clone().into(), v.clone().0)).collect(),
465-
num_matches_per_rule: r.num_matches_per_rule.iter().map(|(k, v)| (k.clone().into(), *v)).collect(),
466-
search_and_apply_time_per_ruleset: r.search_and_apply_time_per_ruleset.iter().map(|(k, v)| (k.clone().into(), v.clone().0)).collect(),
467-
merge_time_per_ruleset: r.merge_time_per_ruleset.iter().map(|(k, v)| (k.clone().into(), v.clone().0)).collect(),
468-
rebuild_time_per_ruleset: r.rebuild_time_per_ruleset.iter().map(|(k, v)| (k.clone().into(), v.clone().0)).collect(),
464+
search_and_apply_time_per_rule: r.search_and_apply_time_per_rule.iter().map(|(k, v)| (k.clone(), v.clone().0)).collect(),
465+
num_matches_per_rule: r.num_matches_per_rule.iter().map(|(k, v)| (k.clone(), *v)).collect(),
466+
search_and_apply_time_per_ruleset: r.search_and_apply_time_per_ruleset.iter().map(|(k, v)| (k.clone(), v.clone().0)).collect(),
467+
merge_time_per_ruleset: r.merge_time_per_ruleset.iter().map(|(k, v)| (k.clone(), v.clone().0)).collect(),
468+
rebuild_time_per_ruleset: r.rebuild_time_per_ruleset.iter().map(|(k, v)| (k.clone(), v.clone().0)).collect(),
469469
},
470470
r -> RunReport {
471471
updated: r.updated,

src/egraph.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ impl EGraph {
7979
WrappedError::Egglog(e, "\nWhen running commands:\n".to_string() + &cmds_str)
8080
})
8181
});
82-
if res.is_ok() {
83-
if let Some(cmds) = &mut self.cmds {
84-
cmds.push_str(&cmds_str);
85-
}
82+
if res.is_ok()
83+
&& let Some(cmds) = &mut self.cmds
84+
{
85+
cmds.push_str(&cmds_str);
8686
}
8787
res.map(|xs| xs.iter().map(|o| o.into()).collect())
8888
}
@@ -131,7 +131,7 @@ impl EGraph {
131131
name,
132132
key.into_iter().map(|v| v.0).collect::<Vec<_>>().as_slice(),
133133
)
134-
.map(|v| Value(v))
134+
.map(Value)
135135
}
136136

137137
fn eval_expr(&mut self, expr: Expr) -> EggResult<(String, Value)> {
@@ -216,7 +216,7 @@ impl EGraph {
216216
.egraph
217217
.value_to_container::<egglog::sort::VecContainer>(v.0)
218218
.unwrap();
219-
return vc.data.iter().map(|x| Value(*x)).collect();
219+
vc.data.iter().map(|x| Value(*x)).collect()
220220
}
221221

222222
fn value_to_function(&self, v: Value) -> (String, Vec<Value>) {

src/extract.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ impl egglog::extract::CostModel<Cost> for CostModel {
117117
) -> Cost {
118118
Cost(Arc::new(Python::attach(|py| match &self.enode_cost {
119119
Some(enode_cost) => {
120-
let mut values = row
121-
.vals
122-
.iter()
123-
.map(|v| Value(v.clone()))
124-
.collect::<Vec<_>>();
120+
let mut values = row.vals.iter().map(|v| Value(*v)).collect::<Vec<_>>();
125121
// Remove last element which is the output
126122
// this is not needed because the only thing we can do with the output is look up an analysis
127123
// which we can also do with the original function
@@ -238,7 +234,7 @@ impl Extractor {
238234
let (cost, term) = self
239235
.0
240236
.extract_best_with_sort(&egraph.egraph, &mut termdag.0, value.0, sort.clone())
241-
.ok_or(PyValueError::new_err(format!("Unextractable root")))?;
237+
.ok_or(PyValueError::new_err("Unextractable root".to_string()))?;
242238
Ok((cost.0.clone_ref(py), term.into()))
243239
}
244240

src/py_object_sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl PyObjectSort {
158158
// Integrate with Python garbage collector
159159
// https://pyo3.rs/main/class/protocols#garbage-collector-integration
160160

161-
fn __traverse__<'py>(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
161+
fn __traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
162162
visit.call(self.hashable_to_index.as_ref())?;
163163
self.objects
164164
.lock()

src/termdag.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl TermDag {
2323
///
2424
/// Panics if the term does not already exist in this [TermDag].
2525
pub fn lookup(&self, node: Term) -> TermId {
26-
self.0.lookup(&node.into()).into()
26+
self.0.lookup(&node.into())
2727
}
2828

2929
/// Convert the given id to the corresponding term.
@@ -38,7 +38,7 @@ impl TermDag {
3838
/// Panics if any of the children are not already in the DAG.
3939
pub fn app(&mut self, sym: String, children: Vec<Term>) -> Term {
4040
self.0
41-
.app(sym.into(), children.into_iter().map(|c| c.into()).collect())
41+
.app(sym, children.into_iter().map(|c| c.into()).collect())
4242
.into()
4343
}
4444

@@ -51,7 +51,7 @@ impl TermDag {
5151
/// Make and return a [`Term::Var`] with the given symbol, and insert into
5252
/// the DAG if it is not already present.
5353
pub fn var(&mut self, sym: String) -> Term {
54-
self.0.var(sym.into()).into()
54+
self.0.var(sym).into()
5555
}
5656

5757
/// Recursively converts the given expression to a term.

0 commit comments

Comments
 (0)