mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
clippy lints 2
This commit is contained in:
parent
33fae17b35
commit
f28eb8c20a
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)?;
|
||||
|
@ -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
|
||||
|
@ -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(),
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user