Fix latest clippy warnings.
This commit is contained in:
parent
e97fe332b1
commit
93d0191489
|
@ -91,6 +91,7 @@ pub struct Environment<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Environment<'a> {
|
impl<'a> Environment<'a> {
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn find_module(&self, fragments: &[String], location: Span) -> Result<&'a TypeInfo, Error> {
|
pub fn find_module(&self, fragments: &[String], location: Span) -> Result<&'a TypeInfo, Error> {
|
||||||
let mut name = fragments.join("/");
|
let mut name = fragments.join("/");
|
||||||
|
|
||||||
|
@ -158,6 +159,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn match_fun_type(
|
pub fn match_fun_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
tipo: Rc<Type>,
|
tipo: Rc<Type>,
|
||||||
|
@ -216,6 +218,7 @@ impl<'a> Environment<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn custom_type_accessors<A>(
|
fn custom_type_accessors<A>(
|
||||||
&mut self,
|
&mut self,
|
||||||
constructors: &[RecordConstructor<A>],
|
constructors: &[RecordConstructor<A>],
|
||||||
|
@ -368,6 +371,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn get_type_constructor_mut(
|
pub fn get_type_constructor_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -388,6 +392,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lookup a type in the current scope.
|
/// Lookup a type in the current scope.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn get_type_constructor(
|
pub fn get_type_constructor(
|
||||||
&mut self,
|
&mut self,
|
||||||
module_alias: &Option<String>,
|
module_alias: &Option<String>,
|
||||||
|
@ -434,7 +439,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lookup a value constructor in the current scope.
|
/// Lookup a value constructor in the current scope.
|
||||||
///
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn get_value_constructor(
|
pub fn get_value_constructor(
|
||||||
&mut self,
|
&mut self,
|
||||||
module: Option<&String>,
|
module: Option<&String>,
|
||||||
|
@ -585,6 +590,7 @@ impl<'a> Environment<'a> {
|
||||||
/// Map a type in the current scope. Errors if the module
|
/// Map a type in the current scope. Errors if the module
|
||||||
/// already has a type with that name, unless the type is
|
/// already has a type with that name, unless the type is
|
||||||
/// from the prelude.
|
/// from the prelude.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn insert_type_constructor(
|
pub fn insert_type_constructor(
|
||||||
&mut self,
|
&mut self,
|
||||||
type_name: String,
|
type_name: String,
|
||||||
|
@ -737,6 +743,7 @@ impl<'a> Environment<'a> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn make_type_vars(
|
fn make_type_vars(
|
||||||
&mut self,
|
&mut self,
|
||||||
args: &[String],
|
args: &[String],
|
||||||
|
@ -827,6 +834,7 @@ impl<'a> Environment<'a> {
|
||||||
self.previous_id
|
self.previous_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn register_import(&mut self, def: &UntypedDefinition) -> Result<(), Error> {
|
pub fn register_import(&mut self, def: &UntypedDefinition) -> Result<(), Error> {
|
||||||
match def {
|
match def {
|
||||||
Definition::Use(Use {
|
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
|
/// Iterate over a module, registering any new types created by the module into the typer
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn register_types(
|
pub fn register_types(
|
||||||
&mut self,
|
&mut self,
|
||||||
definitions: Vec<&'a UntypedDefinition>,
|
definitions: Vec<&'a UntypedDefinition>,
|
||||||
|
@ -1065,6 +1074,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn register_type(
|
pub fn register_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
def: &'a UntypedDefinition,
|
def: &'a UntypedDefinition,
|
||||||
|
@ -1182,6 +1192,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn register_function(
|
fn register_function(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -1241,6 +1252,7 @@ impl<'a> Environment<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn register_values(
|
pub fn register_values(
|
||||||
&mut self,
|
&mut self,
|
||||||
def: &'a UntypedDefinition,
|
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.
|
/// It two types are found to not be the same an error is returned.
|
||||||
#[allow(clippy::only_used_in_recursion)]
|
#[allow(clippy::only_used_in_recursion)]
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn unify(
|
pub fn unify(
|
||||||
&mut self,
|
&mut self,
|
||||||
lhs: Rc<Type>,
|
lhs: Rc<Type>,
|
||||||
|
@ -1719,6 +1732,7 @@ impl<'a> Environment<'a> {
|
||||||
/// Checks that the given patterns are exhaustive for given type.
|
/// Checks that the given patterns are exhaustive for given type.
|
||||||
/// https://github.com/elm/compiler/blob/047d5026fe6547c842db65f7196fed3f0b4743ee/compiler/src/Nitpick/PatternMatches.hs#L397-L475
|
/// https://github.com/elm/compiler/blob/047d5026fe6547c842db65f7196fed3f0b4743ee/compiler/src/Nitpick/PatternMatches.hs#L397-L475
|
||||||
/// http://moscova.inria.fr/~maranget/papers/warn/index.html
|
/// http://moscova.inria.fr/~maranget/papers/warn/index.html
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn check_exhaustiveness(
|
pub fn check_exhaustiveness(
|
||||||
&mut self,
|
&mut self,
|
||||||
unchecked_patterns: &[&TypedPattern],
|
unchecked_patterns: &[&TypedPattern],
|
||||||
|
@ -1768,7 +1782,7 @@ impl<'a> Environment<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lookup constructors for type in the current scope.
|
/// Lookup constructors for type in the current scope.
|
||||||
///
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn get_constructors_for_type(
|
pub fn get_constructors_for_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
full_module_name: &String,
|
full_module_name: &String,
|
||||||
|
@ -1868,6 +1882,7 @@ pub enum EntityKind {
|
||||||
/// prevents the algorithm from inferring recursive types, which
|
/// prevents the algorithm from inferring recursive types, which
|
||||||
/// could cause naively-implemented type checking to diverge.
|
/// could cause naively-implemented type checking to diverge.
|
||||||
/// While traversing the type tree.
|
/// While traversing the type tree.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn unify_unbound_type(tipo: Rc<Type>, own_id: u64, location: Span) -> Result<(), Error> {
|
fn unify_unbound_type(tipo: Rc<Type>, own_id: u64, location: Span) -> Result<(), Error> {
|
||||||
if let Type::Var { tipo, alias } = tipo.deref() {
|
if let Type::Var { tipo, alias } = tipo.deref() {
|
||||||
let new_value = match tipo.borrow().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> {
|
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.
|
// If types cannot unify, show the type error with the enclosing types, e1 and e2.
|
||||||
match result {
|
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>(
|
fn assert_unique_type_name<'a>(
|
||||||
names: &mut HashMap<&'a str, &'a Span>,
|
names: &mut HashMap<&'a str, &'a Span>,
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
|
@ -1977,6 +1994,7 @@ fn assert_unique_type_name<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn assert_unique_value_name<'a>(
|
fn assert_unique_value_name<'a>(
|
||||||
names: &mut HashMap<String, &'a Span>,
|
names: &mut HashMap<String, &'a Span>,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -1992,6 +2010,7 @@ fn assert_unique_value_name<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn assert_unique_const_name<'a>(
|
fn assert_unique_const_name<'a>(
|
||||||
names: &mut HashMap<String, &'a Span>,
|
names: &mut HashMap<String, &'a Span>,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|
|
@ -530,6 +530,7 @@ fn list_constructors() -> Vec<tipo::ValueConstructor> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub(super) fn simplify(
|
pub(super) fn simplify(
|
||||||
environment: &mut Environment,
|
environment: &mut Environment,
|
||||||
value: &ast::TypedPattern,
|
value: &ast::TypedPattern,
|
||||||
|
|
|
@ -32,6 +32,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use vec1::Vec1;
|
use vec1::Vec1;
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub(crate) fn infer_function(
|
pub(crate) fn infer_function(
|
||||||
fun: &UntypedFunction,
|
fun: &UntypedFunction,
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
|
@ -246,6 +247,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn check_when_exhaustiveness(
|
fn check_when_exhaustiveness(
|
||||||
&mut self,
|
&mut self,
|
||||||
typed_clauses: &[TypedClause],
|
typed_clauses: &[TypedClause],
|
||||||
|
@ -265,6 +267,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn do_infer_call(
|
pub fn do_infer_call(
|
||||||
&mut self,
|
&mut self,
|
||||||
fun: UntypedExpr,
|
fun: UntypedExpr,
|
||||||
|
@ -278,6 +281,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok((fun, args, typ))
|
Ok((fun, args, typ))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn do_infer_call_with_known_fun<F>(
|
pub fn do_infer_call_with_known_fun<F>(
|
||||||
&mut self,
|
&mut self,
|
||||||
fun: TypedExpr,
|
fun: TypedExpr,
|
||||||
|
@ -334,6 +338,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok((fun, arguments, return_type))
|
Ok((fun, arguments, return_type))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn do_infer_fn(
|
pub fn do_infer_fn(
|
||||||
&mut self,
|
&mut self,
|
||||||
args: Vec<UntypedArg>,
|
args: Vec<UntypedArg>,
|
||||||
|
@ -386,6 +391,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
self.infer_fn_with_known_types(arguments, body, return_type)
|
self.infer_fn_with_known_types(arguments, body, return_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn get_field_map(
|
fn get_field_map(
|
||||||
&mut self,
|
&mut self,
|
||||||
constructor: &TypedExpr,
|
constructor: &TypedExpr,
|
||||||
|
@ -426,6 +432,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
|
|
||||||
/// Crawl the AST, annotating each node with the inferred type or
|
/// Crawl the AST, annotating each node with the inferred type or
|
||||||
/// returning an error.
|
/// returning an error.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer(&mut self, expr: UntypedExpr) -> Result<TypedExpr, Error> {
|
pub fn infer(&mut self, expr: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||||
match expr {
|
match expr {
|
||||||
UntypedExpr::ErrorTerm { location } => Ok(self.infer_error_term(location)),
|
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(
|
fn infer_bytearray(
|
||||||
&mut self,
|
&mut self,
|
||||||
bytes: Vec<u8>,
|
bytes: Vec<u8>,
|
||||||
|
@ -597,6 +605,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_curve_point(
|
fn infer_curve_point(
|
||||||
&mut self,
|
&mut self,
|
||||||
curve: Curve,
|
curve: Curve,
|
||||||
|
@ -618,6 +627,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_trace_if_false(
|
fn infer_trace_if_false(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: UntypedExpr,
|
value: UntypedExpr,
|
||||||
|
@ -701,6 +711,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_binop(
|
fn infer_binop(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: BinOp,
|
name: BinOp,
|
||||||
|
@ -771,6 +782,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_record_update(
|
fn infer_record_update(
|
||||||
&mut self,
|
&mut self,
|
||||||
constructor: UntypedExpr,
|
constructor: UntypedExpr,
|
||||||
|
@ -897,6 +909,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_un_op(
|
fn infer_un_op(
|
||||||
&mut self,
|
&mut self,
|
||||||
location: Span,
|
location: Span,
|
||||||
|
@ -1035,6 +1048,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_field_access(
|
fn infer_field_access(
|
||||||
&mut self,
|
&mut self,
|
||||||
container: UntypedExpr,
|
container: UntypedExpr,
|
||||||
|
@ -1077,6 +1091,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_module_access(
|
fn infer_module_access(
|
||||||
&mut self,
|
&mut self,
|
||||||
module_alias: &str,
|
module_alias: &str,
|
||||||
|
@ -1145,6 +1160,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_record_access(
|
fn infer_record_access(
|
||||||
&mut self,
|
&mut self,
|
||||||
record: UntypedExpr,
|
record: UntypedExpr,
|
||||||
|
@ -1157,6 +1173,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
self.infer_known_record_access(record, label, location)
|
self.infer_known_record_access(record, label, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_known_record_access(
|
fn infer_known_record_access(
|
||||||
&mut self,
|
&mut self,
|
||||||
record: TypedExpr,
|
record: TypedExpr,
|
||||||
|
@ -1244,6 +1261,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_param(
|
fn infer_param(
|
||||||
&mut self,
|
&mut self,
|
||||||
untyped_arg: UntypedArg,
|
untyped_arg: UntypedArg,
|
||||||
|
@ -1288,6 +1306,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok((typed_arg, extra_assignment))
|
Ok((typed_arg, extra_assignment))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer_assignment(
|
pub fn infer_assignment(
|
||||||
&mut self,
|
&mut self,
|
||||||
untyped_pattern: UntypedPattern,
|
untyped_pattern: UntypedPattern,
|
||||||
|
@ -1482,6 +1501,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_call(
|
fn infer_call(
|
||||||
&mut self,
|
&mut self,
|
||||||
fun: UntypedExpr,
|
fun: UntypedExpr,
|
||||||
|
@ -1500,6 +1520,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_call_argument(
|
fn infer_call_argument(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: UntypedExpr,
|
value: UntypedExpr,
|
||||||
|
@ -1548,6 +1569,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_clause(
|
fn infer_clause(
|
||||||
&mut self,
|
&mut self,
|
||||||
clause: UntypedClause,
|
clause: UntypedClause,
|
||||||
|
@ -1583,6 +1605,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_clause_pattern(
|
fn infer_clause_pattern(
|
||||||
&mut self,
|
&mut self,
|
||||||
patterns: Vec1<UntypedPattern>,
|
patterns: Vec1<UntypedPattern>,
|
||||||
|
@ -1604,6 +1627,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok(typed_patterns)
|
Ok(typed_patterns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_if(
|
fn infer_if(
|
||||||
&mut self,
|
&mut self,
|
||||||
branches: Vec1<UntypedIfBranch>,
|
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> {
|
fn infer_if_branch(&mut self, branch: UntypedIfBranch) -> Result<TypedIfBranch, Error> {
|
||||||
let (condition, body, is) = match branch.is {
|
let (condition, body, is) = match branch.is {
|
||||||
Some(is) => self.in_new_scope(|typer| {
|
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(
|
pub fn infer_fn(
|
||||||
&mut self,
|
&mut self,
|
||||||
args: Vec<UntypedArg>,
|
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(
|
pub fn infer_fn_with_known_types(
|
||||||
&mut self,
|
&mut self,
|
||||||
args: Vec<TypedArg>,
|
args: Vec<TypedArg>,
|
||||||
|
@ -1842,6 +1869,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_list(
|
fn infer_list(
|
||||||
&mut self,
|
&mut self,
|
||||||
elements: Vec<UntypedExpr>,
|
elements: Vec<UntypedExpr>,
|
||||||
|
@ -1887,6 +1915,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_logical_op_chain(
|
fn infer_logical_op_chain(
|
||||||
&mut self,
|
&mut self,
|
||||||
kind: LogicalOpChainKind,
|
kind: LogicalOpChainKind,
|
||||||
|
@ -1934,6 +1963,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok(chain)
|
Ok(chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_pipeline(&mut self, expressions: Vec1<UntypedExpr>) -> Result<TypedExpr, Error> {
|
fn infer_pipeline(&mut self, expressions: Vec1<UntypedExpr>) -> Result<TypedExpr, Error> {
|
||||||
PipeTyper::infer(self, expressions)
|
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> {
|
fn infer_seq(&mut self, location: Span, untyped: Vec<UntypedExpr>) -> Result<TypedExpr, Error> {
|
||||||
// Search for backpassing.
|
// Search for backpassing.
|
||||||
let mut breakpoint = None;
|
let mut breakpoint = None;
|
||||||
|
@ -2252,6 +2283,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_pair(
|
fn infer_pair(
|
||||||
&mut self,
|
&mut self,
|
||||||
fst: UntypedExpr,
|
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> {
|
fn infer_tuple(&mut self, elems: Vec<UntypedExpr>, location: Span) -> Result<TypedExpr, Error> {
|
||||||
let mut typed_elems = vec![];
|
let mut typed_elems = vec![];
|
||||||
|
|
||||||
|
@ -2293,6 +2326,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_tuple_index(
|
fn infer_tuple_index(
|
||||||
&mut self,
|
&mut self,
|
||||||
tuple_or_pair: UntypedExpr,
|
tuple_or_pair: UntypedExpr,
|
||||||
|
@ -2350,6 +2384,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
TypedExpr::ErrorTerm { location, tipo }
|
TypedExpr::ErrorTerm { location, tipo }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_trace_arg(&mut self, arg: UntypedExpr) -> Result<TypedExpr, Error> {
|
fn infer_trace_arg(&mut self, arg: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||||
let typed_arg = self.infer(arg)?;
|
let typed_arg = self.infer(arg)?;
|
||||||
match self.unify(
|
match self.unify(
|
||||||
|
@ -2366,6 +2401,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_trace(
|
fn infer_trace(
|
||||||
&mut self,
|
&mut self,
|
||||||
kind: TraceKind,
|
kind: TraceKind,
|
||||||
|
@ -2431,6 +2467,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer_value_constructor(
|
pub fn infer_value_constructor(
|
||||||
&mut self,
|
&mut self,
|
||||||
module: &Option<String>,
|
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> {
|
fn infer_var(&mut self, name: String, location: Span) -> Result<TypedExpr, Error> {
|
||||||
let constructor = self.infer_value_constructor(&None, &name, &location)?;
|
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(
|
fn infer_when(
|
||||||
&mut self,
|
&mut self,
|
||||||
subject: UntypedExpr,
|
subject: UntypedExpr,
|
||||||
|
@ -2604,6 +2643,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn instantiate(
|
fn instantiate(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: Rc<Type>,
|
t: Rc<Type>,
|
||||||
|
@ -2615,15 +2655,18 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn new_unbound_var(&mut self) -> Rc<Type> {
|
pub fn new_unbound_var(&mut self) -> Rc<Type> {
|
||||||
self.environment.new_unbound_var()
|
self.environment.new_unbound_var()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn type_from_annotation(&mut self, annotation: &Annotation) -> Result<Rc<Type>, Error> {
|
pub fn type_from_annotation(&mut self, annotation: &Annotation) -> Result<Rc<Type>, Error> {
|
||||||
self.hydrator
|
self.hydrator
|
||||||
.type_from_annotation(annotation, self.environment)
|
.type_from_annotation(annotation, self.environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn unify(
|
fn unify(
|
||||||
&mut self,
|
&mut self,
|
||||||
t1: Rc<Type>,
|
t1: Rc<Type>,
|
||||||
|
@ -2635,6 +2678,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn recover_from_no_assignment(
|
fn recover_from_no_assignment(
|
||||||
result: Result<(), Error>,
|
result: Result<(), Error>,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -2653,6 +2697,7 @@ fn recover_from_no_assignment(
|
||||||
result.map(|()| None)
|
result.map(|()| None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> {
|
fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> {
|
||||||
match expr {
|
match expr {
|
||||||
UntypedExpr::Assignment {
|
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> {
|
fn assert_assignment(expr: TypedExpr) -> Result<TypedExpr, Error> {
|
||||||
if !matches!(expr, TypedExpr::Assignment { .. }) {
|
if !matches!(expr, TypedExpr::Assignment { .. }) {
|
||||||
if expr.tipo().is_void() {
|
if expr.tipo().is_void() {
|
||||||
|
@ -2724,6 +2770,7 @@ fn assert_assignment(expr: TypedExpr) -> Result<TypedExpr, Error> {
|
||||||
Ok(expr)
|
Ok(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn ensure_serialisable(is_top_level: bool, t: Rc<Type>, location: Span) -> Result<(), Error> {
|
pub fn ensure_serialisable(is_top_level: bool, t: Rc<Type>, location: Span) -> Result<(), Error> {
|
||||||
match t.deref() {
|
match t.deref() {
|
||||||
Type::App {
|
Type::App {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
use super::error::{Error, UnknownLabels};
|
use super::error::{Error, UnknownLabels};
|
||||||
use crate::ast::{CallArg, Span};
|
use crate::ast::{CallArg, Span};
|
||||||
|
use itertools::Itertools;
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FieldMap {
|
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> {
|
pub fn insert(&mut self, label: String, index: usize, location: &Span) -> Result<(), Error> {
|
||||||
match self.fields.insert(label.clone(), (index, *location)) {
|
match self.fields.insert(label.clone(), (index, *location)) {
|
||||||
Some((_, location_other)) => {
|
Some((_, location_other)) => {
|
||||||
|
@ -52,6 +51,7 @@ impl FieldMap {
|
||||||
|
|
||||||
/// Reorder an argument list so that labelled fields supplied out-of-order are
|
/// Reorder an argument list so that labelled fields supplied out-of-order are
|
||||||
/// in the correct order.
|
/// in the correct order.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn reorder<A>(&self, args: &mut [CallArg<A>], location: Span) -> Result<(), Error> {
|
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 last_labeled_arguments_given: Option<&CallArg<A>> = None;
|
||||||
let mut seen_labels = std::collections::HashSet::new();
|
let mut seen_labels = std::collections::HashSet::new();
|
||||||
|
|
|
@ -80,6 +80,7 @@ impl Hydrator {
|
||||||
self.rigid_type_names.clone()
|
self.rigid_type_names.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn type_from_option_annotation(
|
pub fn type_from_option_annotation(
|
||||||
&mut self,
|
&mut self,
|
||||||
ast: &Option<Annotation>,
|
ast: &Option<Annotation>,
|
||||||
|
@ -91,6 +92,7 @@ impl Hydrator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn type_from_annotation(
|
pub fn type_from_annotation(
|
||||||
&mut self,
|
&mut self,
|
||||||
annotation: &Annotation,
|
annotation: &Annotation,
|
||||||
|
@ -110,7 +112,7 @@ impl Hydrator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a Type from an AST Type annotation.
|
/// Construct a Type from an AST Type annotation.
|
||||||
///
|
#[allow(clippy::result_large_err)]
|
||||||
fn do_type_from_annotation<'a>(
|
fn do_type_from_annotation<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
annotation: &'a Annotation,
|
annotation: &'a Annotation,
|
||||||
|
|
|
@ -20,6 +20,7 @@ use std::{borrow::Borrow, collections::HashMap, ops::Deref, rc::Rc};
|
||||||
|
|
||||||
impl UntypedModule {
|
impl UntypedModule {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer(
|
pub fn infer(
|
||||||
mut self,
|
mut self,
|
||||||
id_gen: &IdGenerator,
|
id_gen: &IdGenerator,
|
||||||
|
@ -158,6 +159,7 @@ impl UntypedModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_definition(
|
fn infer_definition(
|
||||||
def: UntypedDefinition,
|
def: UntypedDefinition,
|
||||||
module_name: &String,
|
module_name: &String,
|
||||||
|
@ -687,6 +689,7 @@ fn infer_definition(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_fuzzer(
|
fn infer_fuzzer(
|
||||||
environment: &mut Environment<'_>,
|
environment: &mut Environment<'_>,
|
||||||
expected_inner_type: Option<Rc<Type>>,
|
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> {
|
fn annotate_fuzzer(tipo: &Type, location: &Span) -> Result<Annotation, Error> {
|
||||||
match tipo {
|
match tipo {
|
||||||
Type::App {
|
Type::App {
|
||||||
|
|
|
@ -36,6 +36,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn insert_variable(
|
fn insert_variable(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -91,6 +92,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer_alternative_pattern(
|
pub fn infer_alternative_pattern(
|
||||||
&mut self,
|
&mut self,
|
||||||
pattern: UntypedPattern,
|
pattern: UntypedPattern,
|
||||||
|
@ -122,6 +124,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer_pattern(
|
pub fn infer_pattern(
|
||||||
&mut self,
|
&mut self,
|
||||||
pattern: UntypedPattern,
|
pattern: UntypedPattern,
|
||||||
|
@ -130,6 +133,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
||||||
self.unify(pattern, Rc::new(subject.clone()), None, false)
|
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
|
/// 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
|
/// inferred type of the subject in order to determine what variables to insert
|
||||||
/// into the environment (or to detect a type error).
|
/// 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> {
|
impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn infer(
|
pub fn infer(
|
||||||
expr_typer: &'a mut ExprTyper<'b, 'c>,
|
expr_typer: &'a mut ExprTyper<'b, 'c>,
|
||||||
expressions: Vec1<UntypedExpr>,
|
expressions: Vec1<UntypedExpr>,
|
||||||
|
@ -56,6 +57,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||||
typer.infer_expressions(expressions)
|
typer.infer_expressions(expressions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_expressions(
|
fn infer_expressions(
|
||||||
mut self,
|
mut self,
|
||||||
expressions: impl IntoIterator<Item = UntypedExpr>,
|
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(
|
fn infer_each_expression(
|
||||||
&mut self,
|
&mut self,
|
||||||
expressions: impl IntoIterator<Item = UntypedExpr>,
|
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)
|
/// Attempt to infer a |> b(..c) as b(..c)(a)
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_apply_to_call_pipe(
|
fn infer_apply_to_call_pipe(
|
||||||
&mut self,
|
&mut self,
|
||||||
function: TypedExpr,
|
function: TypedExpr,
|
||||||
|
@ -225,6 +229,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to infer a |> b(c) as b(a, c)
|
/// Attempt to infer a |> b(c) as b(a, c)
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_insert_pipe(
|
fn infer_insert_pipe(
|
||||||
&mut self,
|
&mut self,
|
||||||
function: TypedExpr,
|
function: TypedExpr,
|
||||||
|
@ -247,6 +252,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to infer a |> b as b(a)
|
/// Attempt to infer a |> b as b(a)
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn infer_apply_pipe(&mut self, func: UntypedExpr) -> Result<TypedExpr, Error> {
|
fn infer_apply_pipe(&mut self, func: UntypedExpr) -> Result<TypedExpr, Error> {
|
||||||
let func = Box::new(self.expr_typer.infer(func)?);
|
let func = Box::new(self.expr_typer.infer(func)?);
|
||||||
let return_type = self.expr_typer.new_unbound_var();
|
let return_type = self.expr_typer.new_unbound_var();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn cast_request<R>(request: lsp_server::Request) -> Result<R::Params, Error>
|
pub fn cast_request<R>(request: lsp_server::Request) -> Result<R::Params, Error>
|
||||||
where
|
where
|
||||||
R: lsp_types::request::Request,
|
R: lsp_types::request::Request,
|
||||||
|
@ -10,6 +11,7 @@ where
|
||||||
Ok(params)
|
Ok(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn cast_notification<N>(notification: lsp_server::Notification) -> Result<N::Params, Error>
|
pub fn cast_notification<N>(notification: lsp_server::Notification) -> Result<N::Params, Error>
|
||||||
where
|
where
|
||||||
N: lsp_types::notification::Notification,
|
N: lsp_types::notification::Notification,
|
||||||
|
|
|
@ -11,6 +11,7 @@ mod quickfix;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn start() -> Result<(), Error> {
|
pub fn start() -> Result<(), Error> {
|
||||||
tracing::info!("Aiken language server starting");
|
tracing::info!("Aiken language server starting");
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ pub struct Server {
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
/// Clear all diagnostics that have been previously published to the client
|
/// Clear all diagnostics that have been previously published to the client
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn clear_all_diagnostics(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
fn clear_all_diagnostics(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
||||||
for file in self.published_diagnostics.drain() {
|
for file in self.published_diagnostics.drain() {
|
||||||
let params = lsp_types::PublishDiagnosticsParams {
|
let params = lsp_types::PublishDiagnosticsParams {
|
||||||
|
@ -97,6 +98,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compile the project if we are in one. Otherwise do nothing.
|
/// Compile the project if we are in one. Otherwise do nothing.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn compile(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
fn compile(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
||||||
self.notify_client_of_compilation_start(connection)?;
|
self.notify_client_of_compilation_start(connection)?;
|
||||||
|
|
||||||
|
@ -119,6 +121,7 @@ impl Server {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn create_compilation_progress_token(
|
fn create_compilation_progress_token(
|
||||||
&mut self,
|
&mut self,
|
||||||
connection: &lsp_server::Connection,
|
connection: &lsp_server::Connection,
|
||||||
|
@ -191,6 +194,7 @@ impl Server {
|
||||||
Ok(vec![text_edit_replace(new_text)])
|
Ok(vec![text_edit_replace(new_text)])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn handle_notification(
|
fn handle_notification(
|
||||||
&mut self,
|
&mut self,
|
||||||
connection: &lsp_server::Connection,
|
connection: &lsp_server::Connection,
|
||||||
|
@ -251,6 +255,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn handle_request(
|
fn handle_request(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: lsp_server::Request,
|
request: lsp_server::Request,
|
||||||
|
@ -434,6 +439,7 @@ impl Server {
|
||||||
Some(modules)
|
Some(modules)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn goto_definition(
|
fn goto_definition(
|
||||||
&self,
|
&self,
|
||||||
params: lsp_types::GotoDefinitionParams,
|
params: lsp_types::GotoDefinitionParams,
|
||||||
|
@ -500,6 +506,7 @@ impl Server {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn hover(
|
fn hover(
|
||||||
&self,
|
&self,
|
||||||
params: lsp_types::HoverParams,
|
params: lsp_types::HoverParams,
|
||||||
|
@ -560,6 +567,7 @@ impl Server {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn listen(&mut self, connection: Connection) -> Result<(), ServerError> {
|
pub fn listen(&mut self, connection: Connection) -> Result<(), ServerError> {
|
||||||
self.create_compilation_progress_token(&connection)?;
|
self.create_compilation_progress_token(&connection)?;
|
||||||
self.start_watching_aiken_toml(&connection)?;
|
self.start_watching_aiken_toml(&connection)?;
|
||||||
|
@ -614,6 +622,7 @@ impl Server {
|
||||||
server
|
server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn notify_client_of_compilation_end(&self, connection: &Connection) -> Result<(), ServerError> {
|
fn notify_client_of_compilation_end(&self, connection: &Connection) -> Result<(), ServerError> {
|
||||||
self.send_work_done_notification(
|
self.send_work_done_notification(
|
||||||
connection,
|
connection,
|
||||||
|
@ -621,6 +630,7 @@ impl Server {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn notify_client_of_compilation_start(
|
fn notify_client_of_compilation_start(
|
||||||
&self,
|
&self,
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
|
@ -643,6 +653,7 @@ impl Server {
|
||||||
/// If the Aiken diagnostic cannot be converted to LSP diagnostic (due to it
|
/// If the Aiken diagnostic cannot be converted to LSP diagnostic (due to it
|
||||||
/// not having a location) it is stored as a message suitable for use with
|
/// not having a location) it is stored as a message suitable for use with
|
||||||
/// the `showMessage` notification instead.
|
/// the `showMessage` notification instead.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn process_diagnostic<E>(&mut self, error: E) -> Result<(), ServerError>
|
fn process_diagnostic<E>(&mut self, error: E) -> Result<(), ServerError>
|
||||||
where
|
where
|
||||||
E: Diagnostic + GetSource + ExtraData,
|
E: Diagnostic + GetSource + ExtraData,
|
||||||
|
@ -730,6 +741,7 @@ impl Server {
|
||||||
/// Publish all stored diagnostics to the client.
|
/// Publish all stored diagnostics to the client.
|
||||||
/// Any previously publish diagnostics are cleared before the new set are
|
/// Any previously publish diagnostics are cleared before the new set are
|
||||||
/// published to the client.
|
/// published to the client.
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn publish_stored_diagnostics(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
fn publish_stored_diagnostics(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
||||||
self.clear_all_diagnostics(connection)?;
|
self.clear_all_diagnostics(connection)?;
|
||||||
|
|
||||||
|
@ -778,6 +790,7 @@ impl Server {
|
||||||
.push(diagnostic);
|
.push(diagnostic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn send_work_done_notification(
|
fn send_work_done_notification(
|
||||||
&self,
|
&self,
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
|
@ -802,6 +815,7 @@ impl Server {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
fn start_watching_aiken_toml(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
fn start_watching_aiken_toml(&mut self, connection: &Connection) -> Result<(), ServerError> {
|
||||||
let supports_watch_files = self
|
let supports_watch_files = self
|
||||||
.initialize_params
|
.initialize_params
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
use std::path::{Path, PathBuf};
|
use crate::error::Error;
|
||||||
|
|
||||||
use aiken_lang::{ast::Span, line_numbers::LineNumbers};
|
use aiken_lang::{ast::Span, line_numbers::LineNumbers};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lsp_types::TextEdit;
|
use lsp_types::TextEdit;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
use urlencoding::decode;
|
use urlencoding::decode;
|
||||||
|
|
||||||
use crate::error::Error;
|
|
||||||
|
|
||||||
pub const COMPILING_PROGRESS_TOKEN: &str = "compiling-aiken";
|
pub const COMPILING_PROGRESS_TOKEN: &str = "compiling-aiken";
|
||||||
pub const CREATE_COMPILING_PROGRESS_TOKEN: &str = "create-compiling-progress-token";
|
pub const CREATE_COMPILING_PROGRESS_TOKEN: &str = "create-compiling-progress-token";
|
||||||
|
|
||||||
|
@ -26,6 +24,7 @@ pub fn text_edit_replace(new_text: String) -> TextEdit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::result_large_err)]
|
||||||
pub fn path_to_uri(path: PathBuf) -> Result<lsp_types::Url, Error> {
|
pub fn path_to_uri(path: PathBuf) -> Result<lsp_types::Url, Error> {
|
||||||
let mut file: String = "file://".into();
|
let mut file: String = "file://".into();
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ impl TxInfo {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(move |purpose| ScriptContext::V1V2 {
|
.map(move |purpose| ScriptContext::V1V2 {
|
||||||
tx_info: self,
|
tx_info: self.into(),
|
||||||
purpose: purpose.clone().into(),
|
purpose: purpose.clone().into(),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -421,9 +421,9 @@ impl TxInfo {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(move |purpose| ScriptContext::V3 {
|
.map(move |purpose| ScriptContext::V3 {
|
||||||
tx_info: self,
|
tx_info: self.into(),
|
||||||
redeemer: redeemer.data.clone(),
|
redeemer: redeemer.data.clone(),
|
||||||
purpose: purpose.clone().into_script_info(datum.cloned()),
|
purpose: purpose.clone().into_script_info(datum.cloned()).into(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -464,13 +464,13 @@ impl TxInfo {
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum ScriptContext {
|
pub enum ScriptContext {
|
||||||
V1V2 {
|
V1V2 {
|
||||||
tx_info: TxInfo,
|
tx_info: Box<TxInfo>,
|
||||||
purpose: Box<ScriptPurpose>,
|
purpose: Box<ScriptPurpose>,
|
||||||
},
|
},
|
||||||
V3 {
|
V3 {
|
||||||
tx_info: TxInfo,
|
tx_info: Box<TxInfo>,
|
||||||
redeemer: PlutusData,
|
redeemer: PlutusData,
|
||||||
purpose: ScriptInfo<Option<PlutusData>>,
|
purpose: Box<ScriptInfo<Option<PlutusData>>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1397,7 +1397,7 @@ impl ToPlutusData for ScriptContext {
|
||||||
vec![
|
vec![
|
||||||
tx_info.to_plutus_data(),
|
tx_info.to_plutus_data(),
|
||||||
redeemer.to_plutus_data(),
|
redeemer.to_plutus_data(),
|
||||||
WithNeverRegistrationDeposit(purpose).to_plutus_data(),
|
WithNeverRegistrationDeposit(purpose.as_ref()).to_plutus_data(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue