fmt and clippy

This commit is contained in:
gluaxspeed 2021-07-16 03:28:06 -07:00
parent 470a4075f8
commit 025f02e5f8
2 changed files with 18 additions and 24 deletions

View File

@ -67,4 +67,4 @@ pub mod option;
pub use option::*; pub use option::*;
#[cfg(test)] #[cfg(test)]
mod test; mod test;

View File

@ -30,8 +30,8 @@ use crate::{
compiler::Compiler, compiler::Compiler,
errors::CompilerError, errors::CompilerError,
targets::edwards_bls12::EdwardsGroupType, targets::edwards_bls12::EdwardsGroupType,
Output,
AstSnapshotOptions, AstSnapshotOptions,
Output,
}; };
pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>; pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>;
@ -128,19 +128,17 @@ impl Namespace for CompileNamespace {
// (name, content) // (name, content)
let mut inputs = vec![]; let mut inputs = vec![];
if let Some(input) = test.config.get("inputs") { if let Some(Value::Sequence(field)) = test.config.get("inputs") {
if let Value::Sequence(field) = input { for map in field {
for map in field { for (name, value) in map.as_mapping().unwrap().iter() {
for (name, value) in map.as_mapping().unwrap().iter() { // Try to parse string from 'inputs' map, else fail
// Try to parse string from 'inputs' map, else fail let value = if let serde_yaml::Value::String(value) = value {
let value = if let serde_yaml::Value::String(value) = value { value
value } else {
} else { return Err("Expected string in 'inputs' map".to_string());
return Err("Expected string in 'inputs' map".to_string()); };
};
inputs.push((name.as_str().unwrap().to_string(), value.clone())); inputs.push((name.as_str().unwrap().to_string(), value.clone()));
}
} }
} }
} }
@ -216,25 +214,21 @@ impl Namespace for CompileNamespace {
let initial_ast: String = hash( let initial_ast: String = hash(
Ast::from_json_file("/tmp/output/initial_ast.json".into()) Ast::from_json_file("/tmp/output/initial_ast.json".into())
.unwrap_or(Ast::new(Program::new("Error reading initial theorem.".to_string()))) .unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string())))
.to_json_string() .to_json_string()
.unwrap_or("Error converting ast to string.".to_string()), .unwrap_or_else(|_| "Error converting ast to string.".to_string()),
); );
let canonicalized_ast: String = hash( let canonicalized_ast: String = hash(
Ast::from_json_file("/tmp/output/canonicalization_ast.json".into()) Ast::from_json_file("/tmp/output/canonicalization_ast.json".into())
.unwrap_or(Ast::new(Program::new( .unwrap_or_else(|_| Ast::new(Program::new("Error reading canonicalized theorem.".to_string())))
"Error reading canonicalized theorem.".to_string(),
)))
.to_json_string() .to_json_string()
.unwrap_or("Error converting ast to string.".to_string()), .unwrap_or_else(|_| "Error converting ast to string.".to_string()),
); );
let type_inferenced_ast = hash( let type_inferenced_ast = hash(
Ast::from_json_file("/tmp/output/type_inferenced_ast.json".into()) Ast::from_json_file("/tmp/output/type_inferenced_ast.json".into())
.unwrap_or(Ast::new(Program::new( .unwrap_or_else(|_| Ast::new(Program::new("Error reading type inferenced theorem.".to_string())))
"Error reading type inferenced theorem.".to_string(),
)))
.to_json_string() .to_json_string()
.unwrap_or("Error converting ast to string.".to_string()), .unwrap_or_else(|_| "Error converting ast to string.".to_string()),
); );
let final_output = CompileOutput { let final_output = CompileOutput {