Fix latest clippy warnings.
This commit is contained in:
@@ -91,6 +91,7 @@ pub struct Environment<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Environment<'a> {
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn find_module(&self, fragments: &[String], location: Span) -> Result<&'a TypeInfo, Error> {
|
||||
let mut name = fragments.join("/");
|
||||
|
||||
@@ -158,6 +159,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn match_fun_type(
|
||||
&mut self,
|
||||
tipo: Rc<Type>,
|
||||
@@ -216,6 +218,7 @@ impl<'a> Environment<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn custom_type_accessors<A>(
|
||||
&mut self,
|
||||
constructors: &[RecordConstructor<A>],
|
||||
@@ -368,6 +371,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn get_type_constructor_mut(
|
||||
&mut self,
|
||||
name: &str,
|
||||
@@ -388,6 +392,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
|
||||
/// Lookup a type in the current scope.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn get_type_constructor(
|
||||
&mut self,
|
||||
module_alias: &Option<String>,
|
||||
@@ -434,7 +439,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
|
||||
/// Lookup a value constructor in the current scope.
|
||||
///
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn get_value_constructor(
|
||||
&mut self,
|
||||
module: Option<&String>,
|
||||
@@ -585,6 +590,7 @@ impl<'a> Environment<'a> {
|
||||
/// Map a type in the current scope. Errors if the module
|
||||
/// already has a type with that name, unless the type is
|
||||
/// from the prelude.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn insert_type_constructor(
|
||||
&mut self,
|
||||
type_name: String,
|
||||
@@ -737,6 +743,7 @@ impl<'a> Environment<'a> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn make_type_vars(
|
||||
&mut self,
|
||||
args: &[String],
|
||||
@@ -827,6 +834,7 @@ impl<'a> Environment<'a> {
|
||||
self.previous_id
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn register_import(&mut self, def: &UntypedDefinition) -> Result<(), Error> {
|
||||
match def {
|
||||
Definition::Use(Use {
|
||||
@@ -985,6 +993,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
|
||||
/// Iterate over a module, registering any new types created by the module into the typer
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn register_types(
|
||||
&mut self,
|
||||
definitions: Vec<&'a UntypedDefinition>,
|
||||
@@ -1065,6 +1074,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn register_type(
|
||||
&mut self,
|
||||
def: &'a UntypedDefinition,
|
||||
@@ -1182,6 +1192,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn register_function(
|
||||
&mut self,
|
||||
name: &str,
|
||||
@@ -1241,6 +1252,7 @@ impl<'a> Environment<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn register_values(
|
||||
&mut self,
|
||||
def: &'a UntypedDefinition,
|
||||
@@ -1512,6 +1524,7 @@ impl<'a> Environment<'a> {
|
||||
///
|
||||
/// It two types are found to not be the same an error is returned.
|
||||
#[allow(clippy::only_used_in_recursion)]
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn unify(
|
||||
&mut self,
|
||||
lhs: Rc<Type>,
|
||||
@@ -1719,6 +1732,7 @@ impl<'a> Environment<'a> {
|
||||
/// Checks that the given patterns are exhaustive for given type.
|
||||
/// https://github.com/elm/compiler/blob/047d5026fe6547c842db65f7196fed3f0b4743ee/compiler/src/Nitpick/PatternMatches.hs#L397-L475
|
||||
/// http://moscova.inria.fr/~maranget/papers/warn/index.html
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn check_exhaustiveness(
|
||||
&mut self,
|
||||
unchecked_patterns: &[&TypedPattern],
|
||||
@@ -1768,7 +1782,7 @@ impl<'a> Environment<'a> {
|
||||
}
|
||||
|
||||
/// Lookup constructors for type in the current scope.
|
||||
///
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn get_constructors_for_type(
|
||||
&mut self,
|
||||
full_module_name: &String,
|
||||
@@ -1868,6 +1882,7 @@ pub enum EntityKind {
|
||||
/// prevents the algorithm from inferring recursive types, which
|
||||
/// could cause naively-implemented type checking to diverge.
|
||||
/// While traversing the type tree.
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn unify_unbound_type(tipo: Rc<Type>, own_id: u64, location: Span) -> Result<(), Error> {
|
||||
if let Type::Var { tipo, alias } = tipo.deref() {
|
||||
let new_value = match tipo.borrow().deref() {
|
||||
@@ -1942,6 +1957,7 @@ fn unify_unbound_type(tipo: Rc<Type>, own_id: u64, location: Span) -> Result<(),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn unify_enclosed_type(e1: Rc<Type>, e2: Rc<Type>, result: Result<(), Error>) -> Result<(), Error> {
|
||||
// If types cannot unify, show the type error with the enclosing types, e1 and e2.
|
||||
match result {
|
||||
@@ -1962,6 +1978,7 @@ fn unify_enclosed_type(e1: Rc<Type>, e2: Rc<Type>, result: Result<(), Error>) ->
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn assert_unique_type_name<'a>(
|
||||
names: &mut HashMap<&'a str, &'a Span>,
|
||||
name: &'a str,
|
||||
@@ -1977,6 +1994,7 @@ fn assert_unique_type_name<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn assert_unique_value_name<'a>(
|
||||
names: &mut HashMap<String, &'a Span>,
|
||||
name: &str,
|
||||
@@ -1992,6 +2010,7 @@ fn assert_unique_value_name<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn assert_unique_const_name<'a>(
|
||||
names: &mut HashMap<String, &'a Span>,
|
||||
name: &str,
|
||||
|
||||
@@ -530,6 +530,7 @@ fn list_constructors() -> Vec<tipo::ValueConstructor> {
|
||||
]
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub(super) fn simplify(
|
||||
environment: &mut Environment,
|
||||
value: &ast::TypedPattern,
|
||||
|
||||
@@ -32,6 +32,7 @@ use std::{
|
||||
};
|
||||
use vec1::Vec1;
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub(crate) fn infer_function(
|
||||
fun: &UntypedFunction,
|
||||
module_name: &str,
|
||||
@@ -246,6 +247,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn check_when_exhaustiveness(
|
||||
&mut self,
|
||||
typed_clauses: &[TypedClause],
|
||||
@@ -265,6 +267,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn do_infer_call(
|
||||
&mut self,
|
||||
fun: UntypedExpr,
|
||||
@@ -278,6 +281,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok((fun, args, typ))
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn do_infer_call_with_known_fun<F>(
|
||||
&mut self,
|
||||
fun: TypedExpr,
|
||||
@@ -334,6 +338,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok((fun, arguments, return_type))
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn do_infer_fn(
|
||||
&mut self,
|
||||
args: Vec<UntypedArg>,
|
||||
@@ -386,6 +391,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
self.infer_fn_with_known_types(arguments, body, return_type)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn get_field_map(
|
||||
&mut self,
|
||||
constructor: &TypedExpr,
|
||||
@@ -426,6 +432,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
|
||||
/// Crawl the AST, annotating each node with the inferred type or
|
||||
/// returning an error.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer(&mut self, expr: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||
match expr {
|
||||
UntypedExpr::ErrorTerm { location } => Ok(self.infer_error_term(location)),
|
||||
@@ -573,6 +580,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_bytearray(
|
||||
&mut self,
|
||||
bytes: Vec<u8>,
|
||||
@@ -597,6 +605,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_curve_point(
|
||||
&mut self,
|
||||
curve: Curve,
|
||||
@@ -618,6 +627,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_trace_if_false(
|
||||
&mut self,
|
||||
value: UntypedExpr,
|
||||
@@ -701,6 +711,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_binop(
|
||||
&mut self,
|
||||
name: BinOp,
|
||||
@@ -771,6 +782,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_record_update(
|
||||
&mut self,
|
||||
constructor: UntypedExpr,
|
||||
@@ -897,6 +909,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_un_op(
|
||||
&mut self,
|
||||
location: Span,
|
||||
@@ -1035,6 +1048,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
None
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_field_access(
|
||||
&mut self,
|
||||
container: UntypedExpr,
|
||||
@@ -1077,6 +1091,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_module_access(
|
||||
&mut self,
|
||||
module_alias: &str,
|
||||
@@ -1145,6 +1160,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_record_access(
|
||||
&mut self,
|
||||
record: UntypedExpr,
|
||||
@@ -1157,6 +1173,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
self.infer_known_record_access(record, label, location)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_known_record_access(
|
||||
&mut self,
|
||||
record: TypedExpr,
|
||||
@@ -1244,6 +1261,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_param(
|
||||
&mut self,
|
||||
untyped_arg: UntypedArg,
|
||||
@@ -1288,6 +1306,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok((typed_arg, extra_assignment))
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_assignment(
|
||||
&mut self,
|
||||
untyped_pattern: UntypedPattern,
|
||||
@@ -1482,6 +1501,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_call(
|
||||
&mut self,
|
||||
fun: UntypedExpr,
|
||||
@@ -1500,6 +1520,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_call_argument(
|
||||
&mut self,
|
||||
value: UntypedExpr,
|
||||
@@ -1548,6 +1569,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_clause(
|
||||
&mut self,
|
||||
clause: UntypedClause,
|
||||
@@ -1583,6 +1605,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_clause_pattern(
|
||||
&mut self,
|
||||
patterns: Vec1<UntypedPattern>,
|
||||
@@ -1604,6 +1627,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok(typed_patterns)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_if(
|
||||
&mut self,
|
||||
branches: Vec1<UntypedIfBranch>,
|
||||
@@ -1655,6 +1679,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_if_branch(&mut self, branch: UntypedIfBranch) -> Result<TypedIfBranch, Error> {
|
||||
let (condition, body, is) = match branch.is {
|
||||
Some(is) => self.in_new_scope(|typer| {
|
||||
@@ -1728,6 +1753,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_fn(
|
||||
&mut self,
|
||||
args: Vec<UntypedArg>,
|
||||
@@ -1754,6 +1780,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_fn_with_known_types(
|
||||
&mut self,
|
||||
args: Vec<TypedArg>,
|
||||
@@ -1842,6 +1869,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_list(
|
||||
&mut self,
|
||||
elements: Vec<UntypedExpr>,
|
||||
@@ -1887,6 +1915,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_logical_op_chain(
|
||||
&mut self,
|
||||
kind: LogicalOpChainKind,
|
||||
@@ -1934,6 +1963,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok(chain)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_pipeline(&mut self, expressions: Vec1<UntypedExpr>) -> Result<TypedExpr, Error> {
|
||||
PipeTyper::infer(self, expressions)
|
||||
}
|
||||
@@ -2132,6 +2162,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_seq(&mut self, location: Span, untyped: Vec<UntypedExpr>) -> Result<TypedExpr, Error> {
|
||||
// Search for backpassing.
|
||||
let mut breakpoint = None;
|
||||
@@ -2252,6 +2283,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_pair(
|
||||
&mut self,
|
||||
fst: UntypedExpr,
|
||||
@@ -2272,6 +2304,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_tuple(&mut self, elems: Vec<UntypedExpr>, location: Span) -> Result<TypedExpr, Error> {
|
||||
let mut typed_elems = vec![];
|
||||
|
||||
@@ -2293,6 +2326,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_tuple_index(
|
||||
&mut self,
|
||||
tuple_or_pair: UntypedExpr,
|
||||
@@ -2350,6 +2384,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
TypedExpr::ErrorTerm { location, tipo }
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_trace_arg(&mut self, arg: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||
let typed_arg = self.infer(arg)?;
|
||||
match self.unify(
|
||||
@@ -2366,6 +2401,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_trace(
|
||||
&mut self,
|
||||
kind: TraceKind,
|
||||
@@ -2431,6 +2467,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_value_constructor(
|
||||
&mut self,
|
||||
module: &Option<String>,
|
||||
@@ -2534,6 +2571,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_var(&mut self, name: String, location: Span) -> Result<TypedExpr, Error> {
|
||||
let constructor = self.infer_value_constructor(&None, &name, &location)?;
|
||||
|
||||
@@ -2544,6 +2582,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_when(
|
||||
&mut self,
|
||||
subject: UntypedExpr,
|
||||
@@ -2604,6 +2643,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn instantiate(
|
||||
&mut self,
|
||||
t: Rc<Type>,
|
||||
@@ -2615,15 +2655,18 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn new_unbound_var(&mut self) -> Rc<Type> {
|
||||
self.environment.new_unbound_var()
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn type_from_annotation(&mut self, annotation: &Annotation) -> Result<Rc<Type>, Error> {
|
||||
self.hydrator
|
||||
.type_from_annotation(annotation, self.environment)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn unify(
|
||||
&mut self,
|
||||
t1: Rc<Type>,
|
||||
@@ -2635,6 +2678,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn recover_from_no_assignment(
|
||||
result: Result<(), Error>,
|
||||
span: Span,
|
||||
@@ -2653,6 +2697,7 @@ fn recover_from_no_assignment(
|
||||
result.map(|()| None)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> {
|
||||
match expr {
|
||||
UntypedExpr::Assignment {
|
||||
@@ -2692,6 +2737,7 @@ fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn assert_assignment(expr: TypedExpr) -> Result<TypedExpr, Error> {
|
||||
if !matches!(expr, TypedExpr::Assignment { .. }) {
|
||||
if expr.tipo().is_void() {
|
||||
@@ -2724,6 +2770,7 @@ fn assert_assignment(expr: TypedExpr) -> Result<TypedExpr, Error> {
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn ensure_serialisable(is_top_level: bool, t: Rc<Type>, location: Span) -> Result<(), Error> {
|
||||
match t.deref() {
|
||||
Type::App {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
use super::error::{Error, UnknownLabels};
|
||||
use crate::ast::{CallArg, Span};
|
||||
use itertools::Itertools;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct FieldMap {
|
||||
@@ -21,6 +19,7 @@ impl FieldMap {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn insert(&mut self, label: String, index: usize, location: &Span) -> Result<(), Error> {
|
||||
match self.fields.insert(label.clone(), (index, *location)) {
|
||||
Some((_, location_other)) => {
|
||||
@@ -52,6 +51,7 @@ impl FieldMap {
|
||||
|
||||
/// Reorder an argument list so that labelled fields supplied out-of-order are
|
||||
/// in the correct order.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn reorder<A>(&self, args: &mut [CallArg<A>], location: Span) -> Result<(), Error> {
|
||||
let mut last_labeled_arguments_given: Option<&CallArg<A>> = None;
|
||||
let mut seen_labels = std::collections::HashSet::new();
|
||||
|
||||
@@ -80,6 +80,7 @@ impl Hydrator {
|
||||
self.rigid_type_names.clone()
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn type_from_option_annotation(
|
||||
&mut self,
|
||||
ast: &Option<Annotation>,
|
||||
@@ -91,6 +92,7 @@ impl Hydrator {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn type_from_annotation(
|
||||
&mut self,
|
||||
annotation: &Annotation,
|
||||
@@ -110,7 +112,7 @@ impl Hydrator {
|
||||
}
|
||||
|
||||
/// Construct a Type from an AST Type annotation.
|
||||
///
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn do_type_from_annotation<'a>(
|
||||
&mut self,
|
||||
annotation: &'a Annotation,
|
||||
|
||||
@@ -20,6 +20,7 @@ use std::{borrow::Borrow, collections::HashMap, ops::Deref, rc::Rc};
|
||||
|
||||
impl UntypedModule {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer(
|
||||
mut self,
|
||||
id_gen: &IdGenerator,
|
||||
@@ -158,6 +159,7 @@ impl UntypedModule {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_definition(
|
||||
def: UntypedDefinition,
|
||||
module_name: &String,
|
||||
@@ -687,6 +689,7 @@ fn infer_definition(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_fuzzer(
|
||||
environment: &mut Environment<'_>,
|
||||
expected_inner_type: Option<Rc<Type>>,
|
||||
@@ -763,6 +766,7 @@ fn infer_fuzzer(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn annotate_fuzzer(tipo: &Type, location: &Span) -> Result<Annotation, Error> {
|
||||
match tipo {
|
||||
Type::App {
|
||||
|
||||
@@ -36,6 +36,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn insert_variable(
|
||||
&mut self,
|
||||
name: &str,
|
||||
@@ -91,6 +92,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_alternative_pattern(
|
||||
&mut self,
|
||||
pattern: UntypedPattern,
|
||||
@@ -122,6 +124,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer_pattern(
|
||||
&mut self,
|
||||
pattern: UntypedPattern,
|
||||
@@ -130,6 +133,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||
self.unify(pattern, Rc::new(subject.clone()), None, false)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
/// When we have an assignment or a case expression we unify the pattern with the
|
||||
/// inferred type of the subject in order to determine what variables to insert
|
||||
/// into the environment (or to detect a type error).
|
||||
|
||||
@@ -21,6 +21,7 @@ pub(crate) struct PipeTyper<'a, 'b, 'c> {
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn infer(
|
||||
expr_typer: &'a mut ExprTyper<'b, 'c>,
|
||||
expressions: Vec1<UntypedExpr>,
|
||||
@@ -56,6 +57,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
typer.infer_expressions(expressions)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_expressions(
|
||||
mut self,
|
||||
expressions: impl IntoIterator<Item = UntypedExpr>,
|
||||
@@ -74,6 +76,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_each_expression(
|
||||
&mut self,
|
||||
expressions: impl IntoIterator<Item = UntypedExpr>,
|
||||
@@ -192,6 +195,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
}
|
||||
|
||||
/// Attempt to infer a |> b(..c) as b(..c)(a)
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_apply_to_call_pipe(
|
||||
&mut self,
|
||||
function: TypedExpr,
|
||||
@@ -225,6 +229,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
}
|
||||
|
||||
/// Attempt to infer a |> b(c) as b(a, c)
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_insert_pipe(
|
||||
&mut self,
|
||||
function: TypedExpr,
|
||||
@@ -247,6 +252,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||
}
|
||||
|
||||
/// Attempt to infer a |> b as b(a)
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn infer_apply_pipe(&mut self, func: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||
let func = Box::new(self.expr_typer.infer(func)?);
|
||||
let return_type = self.expr_typer.new_unbound_var();
|
||||
|
||||
Reference in New Issue
Block a user