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.
|
// 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.set_path(&self.main_file_path);
|
||||||
|
|
||||||
e
|
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)?;
|
let symbol_table = SymbolTable::new(&self.program, &self.imported_programs, &self.program_input)?;
|
||||||
|
|
||||||
// Run type inference check on program.
|
// 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);
|
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::Let => false,
|
||||||
Declare::Const => true,
|
Declare::Const => true,
|
||||||
};
|
};
|
||||||
let expression = self.enforce_expression(
|
let expression =
|
||||||
cs,
|
self.enforce_expression(cs, file_scope, function_scope, variables.type_.clone(), expression)?;
|
||||||
file_scope.clone(),
|
|
||||||
function_scope.clone(),
|
|
||||||
variables.type_.clone(),
|
|
||||||
expression,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if num_variables == 1 {
|
if num_variables == 1 {
|
||||||
// Define a single variable with a single value
|
// 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
|
// Data type wrappers
|
||||||
ConstrainedValue::Array(array) => {
|
ConstrainedValue::Array(array) => {
|
||||||
array
|
array.iter_mut().enumerate().try_for_each(|(i, value)| {
|
||||||
.iter_mut()
|
let unique_name = format!("allocate array member {} {}:{}", i, span.line, span.start);
|
||||||
.enumerate()
|
|
||||||
.map(|(i, value)| {
|
|
||||||
let unique_name = format!("allocate array member {} {}:{}", i, span.line, span.start);
|
|
||||||
|
|
||||||
value.allocate_value(cs.ns(|| unique_name), span)
|
value.allocate_value(cs.ns(|| unique_name), span)
|
||||||
})
|
})?;
|
||||||
.collect::<Result<(), ValueError>>()?;
|
|
||||||
}
|
}
|
||||||
ConstrainedValue::Tuple(tuple) => {
|
ConstrainedValue::Tuple(tuple) => {
|
||||||
tuple
|
tuple.iter_mut().enumerate().try_for_each(|(i, value)| {
|
||||||
.iter_mut()
|
let unique_name = format!("allocate tuple member {} {}:{}", i, span.line, span.start);
|
||||||
.enumerate()
|
|
||||||
.map(|(i, value)| {
|
|
||||||
let unique_name = format!("allocate tuple member {} {}:{}", i, span.line, span.start);
|
|
||||||
|
|
||||||
value.allocate_value(cs.ns(|| unique_name), span)
|
value.allocate_value(cs.ns(|| unique_name), span)
|
||||||
})
|
})?;
|
||||||
.collect::<Result<(), ValueError>>()?;
|
|
||||||
}
|
}
|
||||||
ConstrainedValue::CircuitExpression(_id, members) => {
|
ConstrainedValue::CircuitExpression(_id, members) => {
|
||||||
members
|
members.iter_mut().enumerate().try_for_each(|(i, member)| {
|
||||||
.iter_mut()
|
let unique_name = format!("allocate circuit member {} {}:{}", i, span.line, span.start);
|
||||||
.enumerate()
|
|
||||||
.map(|(i, member)| {
|
|
||||||
let unique_name = format!("allocate circuit member {} {}:{}", i, span.line, span.start);
|
|
||||||
|
|
||||||
member.1.allocate_value(cs.ns(|| unique_name), span)
|
member.1.allocate_value(cs.ns(|| unique_name), span)
|
||||||
})
|
})?;
|
||||||
.collect::<Result<(), ValueError>>()?;
|
|
||||||
}
|
}
|
||||||
ConstrainedValue::Mutable(value) => {
|
ConstrainedValue::Mutable(value) => {
|
||||||
value.allocate_value(cs, span)?;
|
value.allocate_value(cs, span)?;
|
||||||
|
@ -29,6 +29,7 @@ pub trait CLI {
|
|||||||
const OPTIONS: &'static [OptionType];
|
const OPTIONS: &'static [OptionType];
|
||||||
const SUBCOMMANDS: &'static [SubCommandType];
|
const SUBCOMMANDS: &'static [SubCommandType];
|
||||||
|
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn new<'a, 'b>() -> App<'a, 'b> {
|
fn new<'a, 'b>() -> App<'a, 'b> {
|
||||||
let arguments = &Self::ARGUMENTS
|
let arguments = &Self::ARGUMENTS
|
||||||
|
@ -34,7 +34,8 @@ impl TypeInference {
|
|||||||
///
|
///
|
||||||
/// Evaluates all `TypeAssertion` predicates.
|
/// 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 {
|
let mut type_inference = Self {
|
||||||
table: symbol_table,
|
table: symbol_table,
|
||||||
frames: Vec::new(),
|
frames: Vec::new(),
|
||||||
|
@ -66,11 +66,11 @@ impl TestTypeInference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn check(self) {
|
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) {
|
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