Merge pull request #22 from trailofbits/clippy-fixes

Linter fixes and bumped crate version
This commit is contained in:
Fredrik Dahlgren
2024-06-20 17:35:42 +02:00
committed by GitHub
10 changed files with 291 additions and 366 deletions

599
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
[workspace]
resolver = "1"
members = [
"cli",
"parser",

View File

@@ -1,6 +1,6 @@
[package]
name = "circomspect"
version = "0.8.1"
version = "0.9.0"
edition = "2021"
rust-version = "1.65"
license = "LGPL-3.0-only"
@@ -17,7 +17,7 @@ atty = "0.2"
clap = { version = "3.2", features = ["derive"] }
log = "0.4"
parser = { package = "circomspect-parser", version = "2.1.3", path = "../parser" }
pretty_env_logger = "0.4"
pretty_env_logger = "0.5"
program_analysis = { package = "circomspect-program-analysis", version = "0.8.1", path = "../program_analysis" }
program_structure = { package = "circomspect-program-structure", version = "2.1.3", path = "../program_structure" }
serde_json = "1.0"

View File

@@ -1,6 +1,6 @@
[package]
name = "circomspect-parser"
version = "2.1.3"
version = "2.2.0"
edition = "2021"
rust-version = "1.65"
build = "build.rs"
@@ -14,14 +14,14 @@ authors = [
[build-dependencies]
rustc-hex = "2.0"
lalrpop = { version = "0.19", features = ["lexer"] }
num-bigint-dig = "0.6"
lalrpop = { version = "0.20", features = ["lexer"] }
num-bigint-dig = "0.8"
num-traits = "0.2"
[dependencies]
program_structure = { package = "circomspect-program-structure", version = "2.1.3", path = "../program_structure" }
lalrpop = { version = "0.19", features = ["lexer"] }
lalrpop-util = "0.19"
program_structure = { package = "circomspect-program-structure", version = "2.1.4", path = "../program_structure" }
lalrpop = { version = "0.20", features = ["lexer"] }
lalrpop-util = "0.20"
log = "0.4"
regex = "1.7"
rustc-hex = "2.1"
@@ -31,4 +31,4 @@ serde = "1.0"
serde_derive = "1.0"
[dev-dependencies]
program_structure = { package = "circomspect-program-structure", version = "2.1.3", path = "../program_structure" }
program_structure = { package = "circomspect-program-structure", version = "2.1.4", path = "../program_structure" }

View File

@@ -120,7 +120,7 @@ impl FileStack {
} else {
// only match include paths with a single component i.e. lib.circom and not dir/lib.circom or
// ./lib.circom
if include.path.find(std::path::MAIN_SEPARATOR) == None {
if include.path.find(std::path::MAIN_SEPARATOR).is_none() {
debug!("checking if `{}` matches `{}`", include.path, lib.path.display());
if lib.path.file_name().expect("good library file") == pathos {
debug!("adding include `{}` from file", lib.path.display());

View File

@@ -452,7 +452,7 @@ fn remove_anonymous_from_expression(
}
}
} else {
new_signals = signals.clone();
new_signals.clone_from(&signals);
for _ in 0..signals.len() {
new_operators.push(AssignOp::AssignConstraintSignal);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "circomspect-program-analysis"
version = "0.8.1"
version = "0.8.2"
edition = "2021"
rust-version = "1.65"
license = "LGPL-3.0-only"
@@ -14,9 +14,9 @@ log = "0.4"
num-bigint-dig = "0.8"
num-traits = "0.2"
thiserror = "1.0"
parser = { package = "circomspect-parser", version = "2.1.3", path = "../parser" }
program_structure = { package = "circomspect-program-structure", version = "2.1.3", path = "../program_structure" }
parser = { package = "circomspect-parser", version = "2.2.0", path = "../parser" }
program_structure = { package = "circomspect-program-structure", version = "2.1.4", path = "../program_structure" }
[dev-dependencies]
parser = { package = "circomspect-parser", version = "2.1.3", path = "../parser" }
program_structure = { package = "circomspect-program-structure", version = "2.1.3", path = "../program_structure" }
parser = { package = "circomspect-parser", version = "2.2.0", path = "../parser" }
program_structure = { package = "circomspect-program-structure", version = "2.1.4", path = "../program_structure" }

View File

@@ -217,7 +217,7 @@ impl AnalysisRunner {
fn cache_template(&mut self, name: &str) -> Result<&Cfg, AnalysisError> {
if !self.template_cfgs.contains_key(name) {
// The template CFG needs to be generated from the AST.
if self.template_reports.get(name).is_some() {
if self.template_reports.contains_key(name) {
// We have already failed to generate the CFG.
return Err(AnalysisError::FailedToLiftTemplate { name: name.to_string() });
}
@@ -243,7 +243,7 @@ impl AnalysisRunner {
fn cache_function(&mut self, name: &str) -> Result<&Cfg, AnalysisError> {
if !self.function_cfgs.contains_key(name) {
// The function CFG needs to be generated from the AST.
if self.function_reports.get(name).is_some() {
if self.function_reports.contains_key(name) {
// We have already failed to generate the CFG.
return Err(AnalysisError::FailedToLiftFunction { name: name.to_string() });
}
@@ -289,11 +289,11 @@ impl AnalysisRunner {
impl AnalysisContext for AnalysisRunner {
fn is_template(&self, name: &str) -> bool {
self.template_asts.get(name).is_some()
self.template_asts.contains_key(name)
}
fn is_function(&self, name: &str) -> bool {
self.function_asts.get(name).is_some()
self.function_asts.contains_key(name)
}
fn template(&mut self, name: &str) -> Result<&Cfg, AnalysisError> {

View File

@@ -1,6 +1,6 @@
[package]
name = "circomspect-program-structure"
version = "2.1.3"
version = "2.1.4"
edition = "2021"
rust-version = "1.65"
license = "LGPL-3.0-only"
@@ -24,7 +24,7 @@ num-bigint-dig = "0.8"
num-traits = "0.2"
serde = "1.0"
serde_derive = "1.0"
serde-sarif = "0.3"
serde-sarif = "0.4"
serde_json = "1.0"
thiserror = "1.0"
termcolor = "1.1.3"

View File

@@ -1,5 +1,6 @@
use anyhow::anyhow;
use std::cmp::Ordering;
use std::fmt::Display;
use std::str::FromStr;
use codespan_reporting::diagnostic::{Diagnostic, Label};
@@ -44,15 +45,14 @@ impl Ord for MessageCategory {
}
}
impl ToString for MessageCategory {
fn to_string(&self) -> String {
impl Display for MessageCategory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use MessageCategory::*;
match self {
Error => "error",
Warning => "warning",
Info => "info",
Error => write!(f, "error"),
Warning => write!(f, "warning"),
Info => write!(f, "info"),
}
.to_string()
}
}