clippy lints 2

This commit is contained in:
collin 2020-11-10 16:34:44 -08:00
parent 33fae17b35
commit f28eb8c20a
6 changed files with 21 additions and 36 deletions

View File

@ -214,7 +214,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
})?;
// Run type inference check on program.
TypeInference::run(&self.program, symbol_table).map_err(|mut e| {
TypeInference::new(&self.program, symbol_table).map_err(|mut e| {
e.set_path(&self.main_file_path);
e
@ -256,7 +256,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
let symbol_table = SymbolTable::new(&self.program, &self.imported_programs, &self.program_input)?;
// Run type inference check on program.
TypeInference::run(&self.program, symbol_table)?;
TypeInference::new(&self.program, symbol_table)?;
tracing::debug!("Program parsing complete\n{:#?}", self.program);

View File

@ -88,13 +88,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
Declare::Let => false,
Declare::Const => true,
};
let expression = self.enforce_expression(
cs,
file_scope.clone(),
function_scope.clone(),
variables.type_.clone(),
expression,
)?;
let expression =
self.enforce_expression(cs, file_scope, function_scope, variables.type_.clone(), expression)?;
if num_variables == 1 {
// Define a single variable with a single value

View File

@ -273,37 +273,25 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
// Data type wrappers
ConstrainedValue::Array(array) => {
array
.iter_mut()
.enumerate()
.map(|(i, value)| {
let unique_name = format!("allocate array member {} {}:{}", i, span.line, span.start);
array.iter_mut().enumerate().try_for_each(|(i, value)| {
let unique_name = format!("allocate array member {} {}:{}", i, span.line, span.start);
value.allocate_value(cs.ns(|| unique_name), span)
})
.collect::<Result<(), ValueError>>()?;
value.allocate_value(cs.ns(|| unique_name), span)
})?;
}
ConstrainedValue::Tuple(tuple) => {
tuple
.iter_mut()
.enumerate()
.map(|(i, value)| {
let unique_name = format!("allocate tuple member {} {}:{}", i, span.line, span.start);
tuple.iter_mut().enumerate().try_for_each(|(i, value)| {
let unique_name = format!("allocate tuple member {} {}:{}", i, span.line, span.start);
value.allocate_value(cs.ns(|| unique_name), span)
})
.collect::<Result<(), ValueError>>()?;
value.allocate_value(cs.ns(|| unique_name), span)
})?;
}
ConstrainedValue::CircuitExpression(_id, members) => {
members
.iter_mut()
.enumerate()
.map(|(i, member)| {
let unique_name = format!("allocate circuit member {} {}:{}", i, span.line, span.start);
members.iter_mut().enumerate().try_for_each(|(i, member)| {
let unique_name = format!("allocate circuit member {} {}:{}", i, span.line, span.start);
member.1.allocate_value(cs.ns(|| unique_name), span)
})
.collect::<Result<(), ValueError>>()?;
member.1.allocate_value(cs.ns(|| unique_name), span)
})?;
}
ConstrainedValue::Mutable(value) => {
value.allocate_value(cs, span)?;

View File

@ -29,6 +29,7 @@ pub trait CLI {
const OPTIONS: &'static [OptionType];
const SUBCOMMANDS: &'static [SubCommandType];
#[allow(clippy::new_ret_no_self)]
#[cfg_attr(tarpaulin, skip)]
fn new<'a, 'b>() -> App<'a, 'b> {
let arguments = &Self::ARGUMENTS

View File

@ -34,7 +34,8 @@ impl TypeInference {
///
/// Evaluates all `TypeAssertion` predicates.
///
pub fn run(program: &Program, symbol_table: SymbolTable) -> Result<(), TypeInferenceError> {
#[allow(clippy::new_ret_no_self)]
pub fn new(program: &Program, symbol_table: SymbolTable) -> Result<(), TypeInferenceError> {
let mut type_inference = Self {
table: symbol_table,
frames: Vec::new(),

View File

@ -66,11 +66,11 @@ impl TestTypeInference {
}
pub fn check(self) {
TypeInference::run(&self.program, self.symbol_table).unwrap();
TypeInference::new(&self.program, self.symbol_table).unwrap();
}
pub fn expect_error(self) {
assert!(TypeInference::run(&self.program, self.symbol_table).is_err());
assert!(TypeInference::new(&self.program, self.symbol_table).is_err());
}
}