Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjabs committed Jul 11, 2023
1 parent 479e2d8 commit 25d26aa
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 57 deletions.
2 changes: 0 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ fn build_cadical(repo: &str, branch: &str, commit: &str) -> bool {
// We specify the build manually here instead of calling make for better portability
let src_files = glob(&format!("{}/src/*.cpp", cadical_dir_str))
.unwrap()
.into_iter()
.filter_map(|res| {
if let Ok(p) = res {
if let Some(name) = p.file_name() {
Expand Down Expand Up @@ -166,7 +165,6 @@ fn build_kissat(repo: &str, branch: &str, commit: &str) -> bool {
// We specify the build manually here instead of calling make for better portability
let src_files = glob(&format!("{}/src/*.c", kissat_dir_str))
.unwrap()
.into_iter()
.filter_map(|res| {
if let Ok(p) = res {
if let Some(name) = p.file_name() {
Expand Down
2 changes: 1 addition & 1 deletion src/instances/fio/opb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ fn write_card<W: Write>(
write!(writer, "-1 x{} ", l.vidx() + opts.first_var_idx)
}
})?;
writeln!(writer, "{} {};", op, bound as isize - offset)
writeln!(writer, "{} {};", op, bound - offset)
} else {
let (lits, bound, op) = match card {
CardConstraint::UB(constr) => {
Expand Down
4 changes: 2 additions & 2 deletions src/instances/sat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl<VM: ManageVars> SatInstance<VM> {
cards.push(pb.as_card_constr().unwrap());
return None;
}
return Some(pb);
Some(pb)
})
.collect();
let cards = cards
Expand All @@ -597,7 +597,7 @@ impl<VM: ManageVars> SatInstance<VM> {
cnf.add_clause(card.as_clause().unwrap());
return None;
}
return Some(card);
Some(card)
})
.collect();
if unsat {
Expand Down
18 changes: 8 additions & 10 deletions src/solvers/cadical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,14 @@ impl<'term> Terminate<'term> for CaDiCaL<'term, '_> {
{
self.terminate_cb = Some(Box::new(Box::new(cb)));
let cb_ptr = self.terminate_cb.as_mut().unwrap().as_mut() as *const _ as *const c_void;
unsafe { ffi::ccadical_set_terminate(self.handle, cb_ptr, ffi::ccadical_terminate_cb) }
unsafe {
ffi::ccadical_set_terminate(self.handle, cb_ptr, Some(ffi::ccadical_terminate_cb))
}
}

fn detach_terminator(&mut self) {
self.terminate_cb = None;
let null_cb: extern "C" fn(*const c_void) -> c_int =
unsafe { std::mem::transmute(std::ptr::null::<u32>()) };
unsafe { ffi::ccadical_set_terminate(self.handle, std::ptr::null(), null_cb) }
unsafe { ffi::ccadical_set_terminate(self.handle, std::ptr::null(), None) }
}
}

Expand Down Expand Up @@ -576,16 +576,14 @@ impl<'learn> Learn<'learn> for CaDiCaL<'_, 'learn> {
self.handle,
cb_ptr,
max_len.try_into().unwrap(),
ffi::ccadical_learn_cb,
Some(ffi::ccadical_learn_cb),
)
}
}

fn detach_learner(&mut self) {
self.terminate_cb = None;
let null_cb: extern "C" fn(*const c_void, *const c_int) =
unsafe { std::mem::transmute(std::ptr::null::<u32>()) };
unsafe { ffi::ccadical_set_learn(self.handle, std::ptr::null(), 0, null_cb) }
unsafe { ffi::ccadical_set_learn(self.handle, std::ptr::null(), 0, None) }
}
}

Expand Down Expand Up @@ -948,13 +946,13 @@ mod ffi {
pub fn ccadical_set_terminate(
solver: *mut CaDiCaLHandle,
state: *const c_void,
terminate: extern "C" fn(state: *const c_void) -> c_int,
terminate: Option<extern "C" fn(state: *const c_void) -> c_int>,
);
pub fn ccadical_set_learn(
solver: *mut CaDiCaLHandle,
state: *const c_void,
max_length: c_int,
learn: extern "C" fn(state: *const c_void, clause: *const c_int),
learn: Option<extern "C" fn(state: *const c_void, clause: *const c_int)>,
);
pub fn ccadical_constrain(solver: *mut CaDiCaLHandle, lit: c_int);
pub fn ccadical_constraint_failed(solver: *mut CaDiCaLHandle) -> c_int;
Expand Down
18 changes: 9 additions & 9 deletions src/solvers/glucose4/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,23 @@ impl PhaseLit for GlucoseCore4 {

impl LimitConflicts for GlucoseCore4 {
fn limit_conflicts(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
limit as i64
} else {
-1
})))
}));
Ok(())
}
}

impl LimitPropagations for GlucoseCore4 {
fn limit_propagations(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
})),
)
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
}));
Ok(())
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/solvers/glucose4/simp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,23 +270,23 @@ impl PhaseLit for GlucoseSimp4 {

impl LimitConflicts for GlucoseSimp4 {
fn limit_conflicts(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
limit as i64
} else {
-1
})))
}));
Ok(())
}
}

impl LimitPropagations for GlucoseSimp4 {
fn limit_propagations(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
})),
)
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
}));
Ok(())
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/solvers/kissat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,12 @@ impl<'term> Terminate<'term> for Kissat<'term> {
{
self.terminate_cb = Some(Box::new(Box::new(cb)));
let cb_ptr = self.terminate_cb.as_mut().unwrap().as_mut() as *const _ as *const c_void;
unsafe { ffi::kissat_set_terminate(self.handle, cb_ptr, ffi::kissat_terminate_cb) }
unsafe { ffi::kissat_set_terminate(self.handle, cb_ptr, Some(ffi::kissat_terminate_cb)) }
}

fn detach_terminator(&mut self) {
self.terminate_cb = None;
let null_cb: extern "C" fn(*const c_void) -> c_int =
unsafe { std::mem::transmute(std::ptr::null::<u32>()) };
unsafe { ffi::kissat_set_terminate(self.handle, std::ptr::null(), null_cb) }
unsafe { ffi::kissat_set_terminate(self.handle, std::ptr::null(), None) }
}
}

Expand Down Expand Up @@ -484,7 +482,7 @@ mod ffi {
pub fn kissat_set_terminate(
solver: *mut KissatHandle,
state: *const c_void,
terminate: extern "C" fn(state: *const c_void) -> c_int,
terminate: Option<extern "C" fn(state: *const c_void) -> c_int>,
);
pub fn kissat_terminate(solver: *mut KissatHandle);
pub fn kissat_reserve(solver: *mut KissatHandle, max_var: c_int);
Expand Down
18 changes: 9 additions & 9 deletions src/solvers/minisat/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,23 @@ impl PhaseLit for MinisatCore {

impl LimitConflicts for MinisatCore {
fn limit_conflicts(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
limit as i64
} else {
-1
})))
}));
Ok(())
}
}

impl LimitPropagations for MinisatCore {
fn limit_propagations(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
})),
)
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
}));
Ok(())
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/solvers/minisat/simp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,23 @@ impl PhaseLit for MinisatSimp {

impl LimitConflicts for MinisatSimp {
fn limit_conflicts(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
self.set_limit(Limit::Conflicts(if let Some(limit) = limit {
limit as i64
} else {
-1
})))
}));
Ok(())
}
}

impl LimitPropagations for MinisatSimp {
fn limit_propagations(&mut self, limit: Option<u32>) -> Result<(), SolverError> {
Ok(
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
})),
)
self.set_limit(Limit::Propagations(if let Some(limit) = limit {
limit as i64
} else {
-1
}));
Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Clause {
idx += 1;
}
}
return Some(self);
Some(self)
}
}

Expand Down

0 comments on commit 25d26aa

Please sign in to comment.