From 93d0191489d926d008d281ae8a3b79eeb9343bef Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 25 Oct 2024 11:27:28 +0200 Subject: [PATCH] Fix latest clippy warnings. --- crates/aiken-lang/src/tipo/environment.rs | 23 ++++++++++- crates/aiken-lang/src/tipo/exhaustive.rs | 1 + crates/aiken-lang/src/tipo/expr.rs | 47 +++++++++++++++++++++++ crates/aiken-lang/src/tipo/fields.rs | 8 ++-- crates/aiken-lang/src/tipo/hydrator.rs | 4 +- crates/aiken-lang/src/tipo/infer.rs | 4 ++ crates/aiken-lang/src/tipo/pattern.rs | 4 ++ crates/aiken-lang/src/tipo/pipe.rs | 6 +++ crates/aiken-lsp/src/cast.rs | 2 + crates/aiken-lsp/src/lib.rs | 1 + crates/aiken-lsp/src/server.rs | 14 +++++++ crates/aiken-lsp/src/utils.rs | 7 ++-- crates/uplc/src/tx/script_context.rs | 12 +++--- crates/uplc/src/tx/to_plutus_data.rs | 2 +- 14 files changed, 117 insertions(+), 18 deletions(-) diff --git a/crates/aiken-lang/src/tipo/environment.rs b/crates/aiken-lang/src/tipo/environment.rs index 9e9f4c92..076808e1 100644 --- a/crates/aiken-lang/src/tipo/environment.rs +++ b/crates/aiken-lang/src/tipo/environment.rs @@ -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, @@ -216,6 +218,7 @@ impl<'a> Environment<'a> { }) } + #[allow(clippy::result_large_err)] fn custom_type_accessors( &mut self, constructors: &[RecordConstructor], @@ -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, @@ -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, @@ -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, 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, own_id: u64, location: Span) -> Result<(), } } +#[allow(clippy::result_large_err)] fn unify_enclosed_type(e1: Rc, e2: Rc, 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, e2: Rc, 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, 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, name: &str, diff --git a/crates/aiken-lang/src/tipo/exhaustive.rs b/crates/aiken-lang/src/tipo/exhaustive.rs index 71979425..02ff32eb 100644 --- a/crates/aiken-lang/src/tipo/exhaustive.rs +++ b/crates/aiken-lang/src/tipo/exhaustive.rs @@ -530,6 +530,7 @@ fn list_constructors() -> Vec { ] } +#[allow(clippy::result_large_err)] pub(super) fn simplify( environment: &mut Environment, value: &ast::TypedPattern, diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index dfd3558c..f04689f3 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -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( &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, @@ -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 { 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, @@ -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, @@ -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, @@ -1655,6 +1679,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> { }) } + #[allow(clippy::result_large_err)] fn infer_if_branch(&mut self, branch: UntypedIfBranch) -> Result { 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, @@ -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, @@ -1842,6 +1869,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> { } } + #[allow(clippy::result_large_err)] fn infer_list( &mut self, elements: Vec, @@ -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) -> Result { 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) -> Result { // 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, location: Span) -> Result { 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 { 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, @@ -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 { 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, @@ -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 { self.environment.new_unbound_var() } + #[allow(clippy::result_large_err)] pub fn type_from_annotation(&mut self, annotation: &Annotation) -> Result, Error> { self.hydrator .type_from_annotation(annotation, self.environment) } + #[allow(clippy::result_large_err)] fn unify( &mut self, t1: Rc, @@ -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 { if !matches!(expr, TypedExpr::Assignment { .. }) { if expr.tipo().is_void() { @@ -2724,6 +2770,7 @@ fn assert_assignment(expr: TypedExpr) -> Result { Ok(expr) } +#[allow(clippy::result_large_err)] pub fn ensure_serialisable(is_top_level: bool, t: Rc, location: Span) -> Result<(), Error> { match t.deref() { Type::App { diff --git a/crates/aiken-lang/src/tipo/fields.rs b/crates/aiken-lang/src/tipo/fields.rs index b68bd884..3ddc032b 100644 --- a/crates/aiken-lang/src/tipo/fields.rs +++ b/crates/aiken-lang/src/tipo/fields.rs @@ -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(&self, args: &mut [CallArg], location: Span) -> Result<(), Error> { let mut last_labeled_arguments_given: Option<&CallArg> = None; let mut seen_labels = std::collections::HashSet::new(); diff --git a/crates/aiken-lang/src/tipo/hydrator.rs b/crates/aiken-lang/src/tipo/hydrator.rs index 8d5d2bc4..fb1643bd 100644 --- a/crates/aiken-lang/src/tipo/hydrator.rs +++ b/crates/aiken-lang/src/tipo/hydrator.rs @@ -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, @@ -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, diff --git a/crates/aiken-lang/src/tipo/infer.rs b/crates/aiken-lang/src/tipo/infer.rs index 5d9c031a..12073aca 100644 --- a/crates/aiken-lang/src/tipo/infer.rs +++ b/crates/aiken-lang/src/tipo/infer.rs @@ -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>, @@ -763,6 +766,7 @@ fn infer_fuzzer( } } +#[allow(clippy::result_large_err)] fn annotate_fuzzer(tipo: &Type, location: &Span) -> Result { match tipo { Type::App { diff --git a/crates/aiken-lang/src/tipo/pattern.rs b/crates/aiken-lang/src/tipo/pattern.rs index c27e050e..86e77903 100644 --- a/crates/aiken-lang/src/tipo/pattern.rs +++ b/crates/aiken-lang/src/tipo/pattern.rs @@ -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). diff --git a/crates/aiken-lang/src/tipo/pipe.rs b/crates/aiken-lang/src/tipo/pipe.rs index 15692010..7fca1436 100644 --- a/crates/aiken-lang/src/tipo/pipe.rs +++ b/crates/aiken-lang/src/tipo/pipe.rs @@ -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, @@ -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, @@ -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, @@ -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 { let func = Box::new(self.expr_typer.infer(func)?); let return_type = self.expr_typer.new_unbound_var(); diff --git a/crates/aiken-lsp/src/cast.rs b/crates/aiken-lsp/src/cast.rs index 05c4d3ee..c25e29e3 100644 --- a/crates/aiken-lsp/src/cast.rs +++ b/crates/aiken-lsp/src/cast.rs @@ -1,5 +1,6 @@ use crate::error::Error; +#[allow(clippy::result_large_err)] pub fn cast_request(request: lsp_server::Request) -> Result where R: lsp_types::request::Request, @@ -10,6 +11,7 @@ where Ok(params) } +#[allow(clippy::result_large_err)] pub fn cast_notification(notification: lsp_server::Notification) -> Result where N: lsp_types::notification::Notification, diff --git a/crates/aiken-lsp/src/lib.rs b/crates/aiken-lsp/src/lib.rs index 15beac07..d7b8d9d4 100644 --- a/crates/aiken-lsp/src/lib.rs +++ b/crates/aiken-lsp/src/lib.rs @@ -11,6 +11,7 @@ mod quickfix; pub mod server; mod utils; +#[allow(clippy::result_large_err)] pub fn start() -> Result<(), Error> { tracing::info!("Aiken language server starting"); diff --git a/crates/aiken-lsp/src/server.rs b/crates/aiken-lsp/src/server.rs index eafaf185..f519304d 100644 --- a/crates/aiken-lsp/src/server.rs +++ b/crates/aiken-lsp/src/server.rs @@ -75,6 +75,7 @@ pub struct Server { impl Server { /// 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> { for file in self.published_diagnostics.drain() { let params = lsp_types::PublishDiagnosticsParams { @@ -97,6 +98,7 @@ impl Server { } /// Compile the project if we are in one. Otherwise do nothing. + #[allow(clippy::result_large_err)] fn compile(&mut self, connection: &Connection) -> Result<(), ServerError> { self.notify_client_of_compilation_start(connection)?; @@ -119,6 +121,7 @@ impl Server { Ok(()) } + #[allow(clippy::result_large_err)] fn create_compilation_progress_token( &mut self, connection: &lsp_server::Connection, @@ -191,6 +194,7 @@ impl Server { Ok(vec![text_edit_replace(new_text)]) } + #[allow(clippy::result_large_err)] fn handle_notification( &mut self, connection: &lsp_server::Connection, @@ -251,6 +255,7 @@ impl Server { } } + #[allow(clippy::result_large_err)] fn handle_request( &mut self, request: lsp_server::Request, @@ -434,6 +439,7 @@ impl Server { Some(modules) } + #[allow(clippy::result_large_err)] fn goto_definition( &self, params: lsp_types::GotoDefinitionParams, @@ -500,6 +506,7 @@ impl Server { }) } + #[allow(clippy::result_large_err)] fn hover( &self, params: lsp_types::HoverParams, @@ -560,6 +567,7 @@ impl Server { })) } + #[allow(clippy::result_large_err)] pub fn listen(&mut self, connection: Connection) -> Result<(), ServerError> { self.create_compilation_progress_token(&connection)?; self.start_watching_aiken_toml(&connection)?; @@ -614,6 +622,7 @@ impl Server { server } + #[allow(clippy::result_large_err)] fn notify_client_of_compilation_end(&self, connection: &Connection) -> Result<(), ServerError> { self.send_work_done_notification( connection, @@ -621,6 +630,7 @@ impl Server { ) } + #[allow(clippy::result_large_err)] fn notify_client_of_compilation_start( &self, connection: &Connection, @@ -643,6 +653,7 @@ impl Server { /// 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 /// the `showMessage` notification instead. + #[allow(clippy::result_large_err)] fn process_diagnostic(&mut self, error: E) -> Result<(), ServerError> where E: Diagnostic + GetSource + ExtraData, @@ -730,6 +741,7 @@ impl Server { /// Publish all stored diagnostics to the client. /// Any previously publish diagnostics are cleared before the new set are /// published to the client. + #[allow(clippy::result_large_err)] fn publish_stored_diagnostics(&mut self, connection: &Connection) -> Result<(), ServerError> { self.clear_all_diagnostics(connection)?; @@ -778,6 +790,7 @@ impl Server { .push(diagnostic); } + #[allow(clippy::result_large_err)] fn send_work_done_notification( &self, connection: &Connection, @@ -802,6 +815,7 @@ impl Server { Ok(()) } + #[allow(clippy::result_large_err)] fn start_watching_aiken_toml(&mut self, connection: &Connection) -> Result<(), ServerError> { let supports_watch_files = self .initialize_params diff --git a/crates/aiken-lsp/src/utils.rs b/crates/aiken-lsp/src/utils.rs index 9b091a38..d78dc45c 100644 --- a/crates/aiken-lsp/src/utils.rs +++ b/crates/aiken-lsp/src/utils.rs @@ -1,12 +1,10 @@ -use std::path::{Path, PathBuf}; - +use crate::error::Error; use aiken_lang::{ast::Span, line_numbers::LineNumbers}; use itertools::Itertools; use lsp_types::TextEdit; +use std::path::{Path, PathBuf}; use urlencoding::decode; -use crate::error::Error; - pub const COMPILING_PROGRESS_TOKEN: &str = "compiling-aiken"; 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 { let mut file: String = "file://".into(); diff --git a/crates/uplc/src/tx/script_context.rs b/crates/uplc/src/tx/script_context.rs index a5f4c1cd..804e76bc 100644 --- a/crates/uplc/src/tx/script_context.rs +++ b/crates/uplc/src/tx/script_context.rs @@ -407,7 +407,7 @@ impl TxInfo { } }) .map(move |purpose| ScriptContext::V1V2 { - tx_info: self, + tx_info: self.into(), purpose: purpose.clone().into(), }), @@ -421,9 +421,9 @@ impl TxInfo { } }) .map(move |purpose| ScriptContext::V3 { - tx_info: self, + tx_info: self.into(), 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)] pub enum ScriptContext { V1V2 { - tx_info: TxInfo, + tx_info: Box, purpose: Box, }, V3 { - tx_info: TxInfo, + tx_info: Box, redeemer: PlutusData, - purpose: ScriptInfo>, + purpose: Box>>, }, } diff --git a/crates/uplc/src/tx/to_plutus_data.rs b/crates/uplc/src/tx/to_plutus_data.rs index d3d7aaae..476a12fa 100644 --- a/crates/uplc/src/tx/to_plutus_data.rs +++ b/crates/uplc/src/tx/to_plutus_data.rs @@ -1397,7 +1397,7 @@ impl ToPlutusData for ScriptContext { vec![ tx_info.to_plutus_data(), redeemer.to_plutus_data(), - WithNeverRegistrationDeposit(purpose).to_plutus_data(), + WithNeverRegistrationDeposit(purpose.as_ref()).to_plutus_data(), ], ), }