Skip to content

Commit

Permalink
Update #[allow(_)] macros to lint with new version of clippy
Browse files Browse the repository at this point in the history
Give all `allow` macros a reason statement, and change the macros to
`expect` where possible
  • Loading branch information
Dekker1 committed Sep 5, 2024
1 parent dbf84e1 commit 29ba087
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 15 deletions.
5 changes: 4 additions & 1 deletion crates/fzn-huub/benches/fzn_huub_benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![allow(unused_crate_dependencies)]
#![expect(
unused_crate_dependencies,
reason = "only dependencies for benchmarking are used in this file"
)]
use std::{
io::Write,
path::{Path, PathBuf},
Expand Down
2 changes: 1 addition & 1 deletion crates/fzn-huub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl TryFrom<Arguments> for Cli<io::Stdout, fn() -> io::Stderr> {
.map_err(|e| e.to_string())?,

stdout: io::stdout(),
#[allow(trivial_casts)] // Doesn't compile without the cast
#[expect(trivial_casts, reason = "doesn't compile without the case")]
stderr: io::stderr as fn() -> io::Stderr,
ansi_color: true,
};
Expand Down
5 changes: 4 additions & 1 deletion crates/fzn-huub/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![allow(unused_crate_dependencies)]
#![allow(
unused_crate_dependencies,
reason = "other dependencies are used in the lib.rs file"
)]
use std::{convert::Infallible, fs, path::PathBuf, process::ExitCode};

use fzn_huub::Cli;
Expand Down
5 changes: 4 additions & 1 deletion crates/fzn-huub/tests/flatzinc_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![allow(unused_crate_dependencies)]
#![expect(
unused_crate_dependencies,
reason = "only dependencies for testing are used in this file"
)]
mod helpers;

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion crates/huub/src/actions/explanation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{actions::inspection::InspectionActions, BoolView, IntView, LitMeanin

pub(crate) trait ExplanationActions: InspectionActions {
fn try_int_lit(&self, var: IntView, meaning: LitMeaning) -> Option<BoolView>;
#[allow(unused)] // TODO
/// Get a literal that represents the given meaning (that is currently `true`)
/// or a relaxation if the literal does not yet exist.
fn get_int_lit_relaxed(&mut self, var: IntView, meaning: LitMeaning) -> (BoolView, LitMeaning);
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/actions/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) trait PropagationActions: ExplanationActions + DecisionActions {
val: IntVal,
reason: impl ReasonBuilder<Self>,
) -> Result<(), Conflict>;
#[allow(dead_code)] // TODO
#[expect(dead_code, reason = "TODO: no current use case in propagators")]
fn set_int_val(
&mut self,
var: IntView,
Expand Down
5 changes: 4 additions & 1 deletion crates/huub/src/model/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ impl From<&BoolView> for BoolExpr {
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[allow(variant_size_differences)]
#[allow(
variant_size_differences,
reason = "`bool` is smaller than all other variants"
)]
pub enum BoolView {
Lit(RawLit),
Const(bool),
Expand Down
5 changes: 4 additions & 1 deletion crates/huub/src/model/reformulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ impl VariableMap {
let _ = self.map.insert(index.into(), elem.into());
}

#[allow(dead_code)] // TODO
#[expect(
dead_code,
reason = "TODO: investigate whether this can be used for SAT rewriting"
)]
pub(crate) fn insert_bool(&mut self, index: RawVar, elem: BoolView) {
let _ = self.map.insert(index.into(), elem.into());
}
Expand Down
5 changes: 4 additions & 1 deletion crates/huub/src/solver/engine/int_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,10 @@ impl IntVar {
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(variant_size_differences)]
#[allow(
variant_size_differences,
reason = "TODO: Investigate if using Box improves performance"
)]
pub(crate) enum OrderStorage {
/// Variables for all inequality conditions are eagerly created and stored in order
Eager {
Expand Down
20 changes: 16 additions & 4 deletions crates/huub/src/solver/engine/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,38 @@ impl<E> PriorityQueue<E> {
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub(crate) enum PriorityLevel {
#[allow(
dead_code,
reason = "TODO: no current propagators are this priority level"
)]
/// The lowest priority level, all other priority levels are more important
#[allow(dead_code)] // TODO
Lowest,
/// A low level of priority, all apart from one priority level are more
/// important
Low,
#[allow(
dead_code,
reason = "TODO: no current propagators are this priority level"
)]
/// A medium level of priority, there are just as many normal priority levels
/// more as less important than this one.
#[allow(dead_code)] // TODO
Medium,
#[allow(
dead_code,
reason = "TODO: no current propagators are this priority level"
)]
/// A high level of priority, all apart from one normal priority level are
/// less important.
#[allow(dead_code)] // TODO
High,
/// The highest normal priority level, this priority level is the most
/// important normal level of priority.
Highest,
#[allow(
dead_code,
reason = "TODO: no current propagators are this priority level"
)]
/// An extraordinarily high level of priority, generally used to ensure
/// something will happen next.
#[allow(dead_code)] // TODO
Immediate,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/solver/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};

#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[allow(variant_size_differences)]
#[allow(variant_size_differences, reason = "`Int` cannot be as smal as `Bool`")]
pub enum Value {
Bool(bool),
Int(IntVal),
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/solver/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl BoolView {
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(variant_size_differences)]
#[allow(variant_size_differences, reason = "`Lit` cannot be as smal as `bool`")]
pub(crate) enum BoolViewInner {
Lit(RawLit),
Const(bool),
Expand Down

0 comments on commit 29ba087

Please sign in to comment.