Skip to content

Commit 07ad2f7

Browse files
committed
clippy fixes
1 parent fc1c55b commit 07ad2f7

File tree

8 files changed

+25
-37
lines changed

8 files changed

+25
-37
lines changed

patronus-egraphs/src/rewrites.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ pub struct ArithMatch {
236236
fn check_width_consistency(pattern: &Pattern<Arith>) {
237237
let exprs = pattern.ast.as_ref();
238238
for e_node_or_var in exprs.iter() {
239-
if let ENodeOrVar::ENode(expr) = e_node_or_var {
240-
if is_bin_op(expr) {
239+
if let ENodeOrVar::ENode(expr) = e_node_or_var
240+
&& is_bin_op(expr) {
241241
// w, w_a, s_a, a, w_b, s_b, b
242242
let a_width_id = usize::from(expr.children()[1]);
243243
let a_id = usize::from(expr.children()[3]);
@@ -258,7 +258,6 @@ fn check_width_consistency(pattern: &Pattern<Arith>) {
258258
);
259259
}
260260
}
261-
}
262261
}
263262
}
264263

patronus/src/btor2/parse.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ impl<'a> Parser<'a> {
111111

112112
// get a better name if none could be determined from the file content
113113
// this better name is often derived from the filename or other meta info
114-
if self.sys.name.is_empty() {
115-
if let Some(name) = backup_name {
114+
if self.sys.name.is_empty()
115+
&& let Some(name) = backup_name {
116116
self.sys.name = name.to_string();
117117
}
118-
}
119118

120119
// possibly improve state names through yosys aliases which look like:
121120
// better_name = zext(__state__, 0)

patronus/src/expr/parse.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,11 @@ impl<'a> Parser<'a> {
228228
}
229229

230230
fn try_parse_width_int(&mut self) -> Option<WidthInt> {
231-
if let Some(m) = DEC_NUM_REGEX.find(self.inp) {
232-
if let Ok(num) = m.as_str().parse() {
231+
if let Some(m) = DEC_NUM_REGEX.find(self.inp)
232+
&& let Ok(num) = m.as_str().parse() {
233233
self.consume_m(&m);
234234
return Some(num);
235235
}
236-
}
237236
None
238237
}
239238

patronus/src/smt/serialize.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ pub fn serialize_expr(out: &mut impl Write, ctx: &Context, expr: ExprRef) -> Res
198198
// we had to serialize some children first => we need a closing parenthesis
199199
if pc > 0 {
200200
// special continuation for zero extend of booleans (for which we use an ite)
201-
if let Expr::BVZeroExt { e, by, .. } = expr {
202-
if e.get_type(ctx).is_bool() {
201+
if let Expr::BVZeroExt { e, by, .. } = expr
202+
&& e.get_type(ctx).is_bool() {
203203
let zeros = "0".repeat(*by as usize);
204204
write!(out, " #b{}1 #b{}0", zeros, zeros)?;
205205
}
206-
}
207206
// everyone gets a closing parenthesis
208207
write!(out, ")")?;
209208
}

patronus/src/system/analysis.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ fn internal_count_expr_uses(
2828
while let Some(expr) = todo.pop() {
2929
if let Some(state) = states.get(&expr) {
3030
// for states, we also want to mark the initial and the next expression as used
31-
if let Some(init) = state.init {
32-
if !ignore_init {
31+
if let Some(init) = state.init
32+
&& !ignore_init {
3333
let count = use_count[init];
3434
if count == 0 {
3535
use_count[init] = 1;
3636
todo.push(init);
3737
}
3838
}
39-
}
4039
if let Some(next) = state.next {
4140
let count = use_count[next];
4241
if count == 0 {
@@ -105,20 +104,16 @@ fn cone_of_influence_impl(
105104

106105
// for states, we might want to follow the next and init expressions
107106
if let Some(state) = states.get(&expr_ref) {
108-
if follow_init {
109-
if let Some(c) = state.init {
110-
if !visited.contains(&c) {
107+
if follow_init
108+
&& let Some(c) = state.init
109+
&& !visited.contains(&c) {
111110
todo.push(c);
112111
}
113-
}
114-
}
115-
if follow_next {
116-
if let Some(c) = state.next {
117-
if !visited.contains(&c) {
112+
if follow_next
113+
&& let Some(c) = state.next
114+
&& !visited.contains(&c) {
118115
todo.push(c);
119116
}
120-
}
121-
}
122117
}
123118

124119
// check to see if this is a state or input

patronus/src/system/transition_system.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ impl TransitionSystem {
6565
}
6666

6767
pub fn update_signal_name(&mut self, old: ExprRef, new: ExprRef) {
68-
if old != new {
69-
if let Some(old_name) = self.names[old] {
70-
if self.names[new].is_none() {
68+
if old != new
69+
&& let Some(old_name) = self.names[old]
70+
&& self.names[new].is_none() {
7171
self.names[new] = Some(old_name);
7272
self.names[old] = None;
7373
}
74-
}
75-
}
7674
}
7775

7876
pub fn add_input(&mut self, ctx: &Context, symbol: ExprRef) {
@@ -143,11 +141,10 @@ impl TransitionSystem {
143141
// update names
144142
let old_name_exprs = self.names.non_default_value_keys().collect::<Vec<_>>();
145143
for old_expr in old_name_exprs.into_iter() {
146-
if let Some(new_expr) = update(old_expr) {
147-
if new_expr != old_expr {
144+
if let Some(new_expr) = update(old_expr)
145+
&& new_expr != old_expr {
148146
self.names[new_expr] = self.names[old_expr];
149147
}
150-
}
151148
}
152149
}
153150

python/src/smt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use crate::ExprRef;
66
use crate::ctx::{ContextGuardRead, ContextGuardWrite};
77
use baa::{BitVecOps, Value};
88
use num_bigint::BigInt;
9-
use patronus::expr::{Context, TypeCheck};
9+
use patronus::expr::TypeCheck;
1010
use patronus::mc::get_smt_value;
1111
use patronus::smt::*;
1212
use pyo3::exceptions::PyRuntimeError;
1313
use pyo3::prelude::*;
14-
use rustc_hash::{FxHashMap, FxHashSet};
14+
use rustc_hash::FxHashMap;
1515

1616
#[pyclass]
1717
pub struct SolverCtx {

tools/simplify/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use clap::Parser;
66
use patronus::expr::*;
7-
use patronus::smt::{SmtCommand, parse_command, read_command, serialize_cmd};
7+
use patronus::smt::{SmtCommand, read_command, serialize_cmd};
88
use rustc_hash::FxHashMap;
9-
use std::io::{BufRead, BufReader, BufWriter};
9+
use std::io::{BufReader, BufWriter};
1010
use std::path::PathBuf;
1111

1212
#[derive(Parser, Debug)]

0 commit comments

Comments
 (0)