Skip to content

Commit 59efe6e

Browse files
committed
Clippy fixes
1 parent f5d54ec commit 59efe6e

File tree

18 files changed

+132
-141
lines changed

18 files changed

+132
-141
lines changed

brane-ast/src/dsl.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ pub fn dtype_dsl_to_ast(value: brane_dsl::DataType) -> DataType {
4141
Semver => DataType::Semver,
4242

4343
Array(a) => DataType::Array { elem_type: Box::new(dtype_dsl_to_ast(*a)) },
44-
Function(sig) => {
45-
DataType::Function { args: sig.args.into_iter().map(|d| dtype_dsl_to_ast(d)).collect(), ret: Box::new(dtype_dsl_to_ast(sig.ret)) }
46-
},
44+
Function(sig) => DataType::Function { args: sig.args.into_iter().map(dtype_dsl_to_ast).collect(), ret: Box::new(dtype_dsl_to_ast(sig.ret)) },
4745
Class(name) => {
4846
// Match if 'Data' or 'IntermediateResult'
4947
if name == BuiltinClasses::Data.name() {

brane-ast/src/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl From<FunctionState> for FunctionDef {
357357
fn from(value: FunctionState) -> Self {
358358
FunctionDef {
359359
name: value.name,
360-
args: value.signature.args.into_iter().map(|d| dtype_dsl_to_ast(d)).collect(),
360+
args: value.signature.args.into_iter().map(dtype_dsl_to_ast).collect(),
361361
ret: dtype_dsl_to_ast(value.signature.ret),
362362
}
363363
}
@@ -416,7 +416,7 @@ impl From<TaskState> for TaskDef {
416416

417417
function: Box::new(FunctionDef {
418418
name: value.name,
419-
args: value.signature.args.into_iter().map(|d| dtype_dsl_to_ast(d)).collect(),
419+
args: value.signature.args.into_iter().map(dtype_dsl_to_ast).collect(),
420420
ret: dtype_dsl_to_ast(value.signature.ret),
421421
}),
422422
args_names: value.arg_names,
@@ -459,7 +459,7 @@ impl ClassState {
459459
// Collect the properties
460460
let props: Vec<VarState> = builtin
461461
.props()
462-
.into_iter()
462+
.iter()
463463
.map(|(name, dtype)| VarState {
464464
name: (*name).into(),
465465
data_type: dtype_ast_to_dsl(dtype.clone()),
@@ -472,7 +472,7 @@ impl ClassState {
472472
// Collect the methods
473473
let methods: Vec<usize> = builtin
474474
.methods()
475-
.into_iter()
475+
.iter()
476476
.enumerate()
477477
.map(|(i, (name, sig))| {
478478
funcs.push(FunctionState {

brane-chk/Cargo.toml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "brane-chk"
33
edition = "2021"
4-
rust-version = "1.74"
4+
rust-version = "1.80"
55
version.workspace = true
66
repository.workspace = true
77
authors = ["Tim Müller", "Bas Kloosterman", "Daniel Voogsgerd"]
@@ -38,9 +38,22 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
3838

3939
# eflint-json = { git = "https://gitlab.com/eflint/json-spec-rs", branch = "incorrect-is-invariant", features = ["display_eflint"] }
4040
enum-debug = { git = "https://github.com/Lut99/enum-debug", tag = "v1.1.0" }
41-
error-trace = { git = "https://github.com/Lut99/error-trace-rs", tag = "v3.3.0", features = ["serde"] }
42-
policy-reasoner = { git = "https://github.com/BraneFramework/policy-reasoner", branch = "lib-refactor", default-features = false, features = ["eflint-haskell-reasoner", "file-logger", "serde", "workflow"] }
43-
policy-store = { git = "https://github.com/BraneFramework/policy-store", default-features = false, features = ["axum-server", "jwk-auth", "jwk-auth-kid", "sqlite-database", "sqlite-database-embedded-migrations"] }
41+
error-trace = { git = "https://github.com/Lut99/error-trace-rs", tag = "v3.3.0", features = [
42+
"serde",
43+
] }
44+
policy-reasoner = { git = "https://github.com/BraneFramework/policy-reasoner", branch = "lib-refactor", default-features = false, features = [
45+
"eflint-haskell-reasoner",
46+
"file-logger",
47+
"serde",
48+
"workflow",
49+
] }
50+
policy-store = { git = "https://github.com/BraneFramework/policy-store", default-features = false, features = [
51+
"axum-server",
52+
"jwk-auth",
53+
"jwk-auth-kid",
54+
"sqlite-database",
55+
"sqlite-database-embedded-migrations",
56+
] }
4457

4558
brane-ast = { path = "../brane-ast" }
4659
brane-cfg = { path = "../brane-cfg" }
@@ -50,7 +63,10 @@ specifications = { path = "../specifications" }
5063

5164
[dev-dependencies]
5265
humanlog = { git = "https://github.com/Lut99/humanlog-rs", tag = "v0.2.0" }
53-
names = { git = "https://github.com/Lut99/names-rs", features = ["rand", "three"] }
66+
names = { git = "https://github.com/Lut99/names-rs", features = [
67+
"rand",
68+
"three",
69+
] }
5470

5571
brane-shr = { path = "../brane-shr" }
5672

brane-chk/src/apis/deliberation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use crate::workflow::compile::pc_to_id;
5757

5858
/***** CONSTANTS *****/
5959
/// The initiator claim that must be given in the input header token.
60-
pub const INITIATOR_CLAIM: &'static str = "username";
60+
pub const INITIATOR_CLAIM: &str = "username";
6161

6262

6363

brane-chk/src/reasonerconn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ impl EFlintHaskellReasonerConnectorWithInterface {
5656
/// its manifest directory). Building the reasoner will trigger the first load, if any,
5757
/// and this may panic if the input is somehow ill-formed.
5858
#[inline]
59-
pub fn new_async<'l, L: AuditLogger>(
59+
pub async fn new_async<'l, L: AuditLogger>(
6060
cmd: impl 'l + IntoIterator<Item = String>,
6161
base_policy_path: impl 'l + Into<PathBuf>,
6262
handler: PrefixedHandler<'static>,
6363
logger: &'l L,
64-
) -> impl 'l + Future<Output = Result<Self, Error>> {
65-
async move { Ok(Self { reasoner: EFlintHaskellReasonerConnector::new_async(cmd, base_policy_path, handler, logger).await? }) }
64+
) -> Result<Self, Error> {
65+
Ok(Self { reasoner: EFlintHaskellReasonerConnector::new_async(cmd, base_policy_path, handler, logger).await? })
6666
}
6767
}
6868
impl ReasonerConnector for EFlintHaskellReasonerConnectorWithInterface {

brane-chk/src/stateresolver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::workflow::compile;
4646
static DATABASE_USER: LazyLock<User> = LazyLock::new(|| User { id: "brane".into(), name: "Brane".into() });
4747

4848
/// The special policy that is used when the database doesn't mention any active.
49-
static DENY_ALL_POLICY: &'static str = "Invariant contradiction When False.";
49+
static DENY_ALL_POLICY: &str = "Invariant contradiction When False.";
5050

5151

5252

@@ -350,7 +350,7 @@ async fn assert_workflow_context(_wf: &Workflow, usecase: &str, usecases: &HashM
350350
async fn get_active_policy(base_policy_hash: &str, db: &SQLiteDatabase<String>, res: &mut String) -> Result<(), Error> {
351351
// Time to fetch a connection
352352
debug!("Connecting to backend database...");
353-
let mut conn: SQLiteConnection<String> = match db.connect(&*DATABASE_USER).await {
353+
let mut conn: SQLiteConnection<String> = match db.connect(&DATABASE_USER).await {
354354
Ok(conn) => conn,
355355
Err(err) => return Err(Error::DatabaseConnect { err }),
356356
};

brane-chk/src/workflow/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ use super::{preprocess, utils};
3030

3131
/***** CONSTANTS *****/
3232
/// The name of the special commit call.
33-
pub const COMMIT_CALL_NAME: &'static str = "__brane_internals::commit";
33+
pub const COMMIT_CALL_NAME: &str = "__brane_internals::commit";
3434

3535
/// The name of the special identity function call.
36-
pub const TOPLEVEL_RETURN_CALL_NAME: &'static str = "__brane_internals::toplevel_return";
36+
pub const TOPLEVEL_RETURN_CALL_NAME: &str = "__brane_internals::toplevel_return";
3737

3838

3939

@@ -256,7 +256,7 @@ fn reconstruct_graph(
256256

257257
// Return the elem
258258
Ok(Elem::Call(ElemCall {
259-
id: pc_to_id(&wir, pc),
259+
id: pc_to_id(wir, pc),
260260
task: format!("{}[{}]::{}", def.package, def.version, def.function.name),
261261
input: input
262262
.iter()

brane-chk/src/workflow/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn workflow_to_output(path: &str, lang: OutputLanguage, workflow: Workflow) {
265265
// OK, now write to out or stdout
266266
if path == "-" {
267267
debug!("Writing result to stdout...");
268-
if let Err(err) = std::io::stdout().write_all(&output.as_bytes()) {
268+
if let Err(err) = std::io::stdout().write_all(output.as_bytes()) {
269269
error!("{}", trace!(("Failed to write to stdout"), err));
270270
std::process::exit(1);
271271
}

brane-chk/src/workflow/eflint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ fn compile_metadata(metadata: &Metadata, phrases: &mut Vec<String>) {
100100
/***** FORMATTERS *****/
101101
/// Serializes a workflow to eFLINT using it's [`Display`]-implementation.
102102
pub struct WorkflowToEflint<'w>(pub &'w Workflow);
103-
impl<'w> Display for WorkflowToEflint<'w> {
103+
impl Display for WorkflowToEflint<'_> {
104104
#[inline]
105-
fn fmt(&self, f: &mut Formatter<'_>) -> FResult { eflint_fmt(&self.0, f) }
105+
fn fmt(&self, f: &mut Formatter<'_>) -> FResult { eflint_fmt(self.0, f) }
106106
}
107107

108108

@@ -231,7 +231,7 @@ impl<'w> Visitor<'w> for DataAnalyzer<'w> {
231231
self.first.push((id.clone(), analyzer.first.into_iter().flat_map(|(_, data)| data).collect()));
232232
}
233233
self.last.clear();
234-
self.last.extend(analyzer.last.into_iter());
234+
self.last.extend(analyzer.last);
235235

236236
// Continue with iteration
237237
Ok(Some(&elem.next))
@@ -413,7 +413,7 @@ impl<'w> Visitor<'w> for EFlintCompiler<'w> {
413413
self.phrases.push(create!(constr_app!("loop", node.clone())));
414414

415415
// Collect the inputs & outputs of the body
416-
let mut analyzer = DataAnalyzer::new(&self.names);
416+
let mut analyzer = DataAnalyzer::new(self.names);
417417
analyzer.visit(&elem.body)?;
418418

419419
// Post-process the input into a list of body nodes and a list of data input

brane-chk/src/workflow/preprocess.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ mod tests {
5656
}
5757

5858
// Defines a few test files with expected inlinable functions
59+
// NOTE: Sorry Clippy, it may be a complex type but at least you can see what's expected
60+
// from every line. Not gonna go through the hassle of splitting this up for just a quick
61+
// inline one.
62+
#[allow(clippy::type_complexity)]
5963
let tests: [(&str, &str, HashMap<usize, Option<HashSet<usize>>>); 5] = [
6064
("case1", r#"println("Hello, world!");"#, HashMap::from([(1, None)])),
6165
(

0 commit comments

Comments
 (0)