diff --git a/cli/src/build.rs b/cli/src/build.rs index 1ff3272ba1..e6f753ec11 100644 --- a/cli/src/build.rs +++ b/cli/src/build.rs @@ -211,7 +211,7 @@ pub fn build_file<'a>( Ok(BuiltFile { binary_path, - total_time, outcome, + total_time, }) } diff --git a/cli/src/repl/eval.rs b/cli/src/repl/eval.rs index 4d3f56d31d..36cb52723a 100644 --- a/cli/src/repl/eval.rs +++ b/cli/src/repl/eval.rs @@ -48,8 +48,8 @@ pub unsafe fn jit_to_ast<'a>( arena, subs, ptr_bytes, - home, interns, + home, }; jit_to_ast_help(&env, lib, main_fn_name, layout, content) diff --git a/compiler/build/src/program.rs b/compiler/build/src/program.rs index ab036cd98b..542118321a 100644 --- a/compiler/build/src/program.rs +++ b/compiler/build/src/program.rs @@ -283,8 +283,8 @@ pub fn gen_from_mono_module( let emit_o_file = emit_o_file_start.elapsed().unwrap(); CodeGenTiming { - emit_o_file, code_gen, + emit_o_file, } } diff --git a/compiler/can/src/operator.rs b/compiler/can/src/operator.rs index 48b18250ca..a6e6fca799 100644 --- a/compiler/can/src/operator.rs +++ b/compiler/can/src/operator.rs @@ -58,7 +58,7 @@ fn new_op_call_expr<'a>( } }; - Located { value, region } + Located { region, value } } fn desugar_def_helps<'a>( @@ -283,11 +283,10 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a let mut alternatives = Vec::with_capacity_in(branch.patterns.len(), arena); alternatives.extend(branch.patterns.iter().copied()); - let desugared_guard = if let Some(guard) = &branch.guard { - Some(*desugar_expr(arena, guard)) - } else { - None - }; + let desugared_guard = branch + .guard + .as_ref() + .map(|guard| *desugar_expr(arena, guard)); let alternatives = alternatives.into_bump_slice(); diff --git a/compiler/can/tests/test_can.rs b/compiler/can/tests/test_can.rs index 40eea5a5ff..68d3139c25 100644 --- a/compiler/can/tests/test_can.rs +++ b/compiler/can/tests/test_can.rs @@ -87,7 +87,7 @@ mod test_can { IntErrorKind::Overflow, Base::Decimal, Region::zero(), - string.into(), + string.into_boxed_str(), )), ); } diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index 4feb77fe72..d2c9fa1662 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -1947,11 +1947,11 @@ fn update<'a>( let typechecked = TypeCheckedModule { module_id, - decls, - solved_subs, - ident_ids, - module_timing, layout_cache, + module_timing, + solved_subs, + decls, + ident_ids, }; state @@ -2000,10 +2000,10 @@ fn update<'a>( .extend(procs.module_thunks.iter().copied()); let found_specializations_module = FoundSpecializationsModule { - layout_cache, module_id, - procs, ident_ids, + layout_cache, + procs, subs, module_timing, }; @@ -3715,13 +3715,13 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result, Loadi module_id, module_name, module_path, + src, + module_timing, deps_by_name, + imported_modules, exposed_ident_ids, exposed_imports, - src, parsed_defs, - imported_modules, - module_timing, }; Ok(Msg::Parsed(parsed)) diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index ee6d8232ca..c47d254f2b 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_map)] + use self::InProgressProc::*; use crate::exhaustive::{Ctor, Guard, RenderAs, TagId}; use crate::layout::{ diff --git a/compiler/mono/src/tail_recursion.rs b/compiler/mono/src/tail_recursion.rs index 88533c6eb4..95444ceecb 100644 --- a/compiler/mono/src/tail_recursion.rs +++ b/compiler/mono/src/tail_recursion.rs @@ -231,10 +231,8 @@ fn insert_jumps<'a>( None } } - Refcounting(modify, cont) => match insert_jumps(arena, cont, goal_id, needle) { - Some(cont) => Some(arena.alloc(Refcounting(*modify, cont))), - None => None, - }, + Refcounting(modify, cont) => insert_jumps(arena, cont, goal_id, needle) + .map(|cont| &*arena.alloc(Refcounting(*modify, cont))), Rethrow => None, Ret(_) => None, diff --git a/compiler/parse/src/parser.rs b/compiler/parse/src/parser.rs index aafb81081d..966bed4bf2 100644 --- a/compiler/parse/src/parser.rs +++ b/compiler/parse/src/parser.rs @@ -1098,10 +1098,10 @@ macro_rules! loc { let end_col = state.column; let end_line = state.line; let region = Region { - start_col, start_line, - end_col, end_line, + start_col, + end_col, }; Ok((progress, Located { region, value }, state)) diff --git a/compiler/parse/src/type_annotation.rs b/compiler/parse/src/type_annotation.rs index edaab151aa..6b1f718552 100644 --- a/compiler/parse/src/type_annotation.rs +++ b/compiler/parse/src/type_annotation.rs @@ -92,7 +92,7 @@ fn term<'a>(min_indent: u16) -> impl Parser<'a, Located>, Typ let value = TypeAnnotation::As(arena.alloc(loc_ann), spaces, arena.alloc(loc_as)); - Located { value, region } + Located { region, value } } None => loc_ann, diff --git a/compiler/region/src/all.rs b/compiler/region/src/all.rs index 479df34c5f..4c7d605b58 100644 --- a/compiler/region/src/all.rs +++ b/compiler/region/src/all.rs @@ -24,8 +24,8 @@ impl Region { pub const fn new(start_line: u32, end_line: u32, start_col: u16, end_col: u16) -> Self { Self { start_line, - start_col, end_line, + start_col, end_col, } } @@ -106,10 +106,10 @@ impl Region { end_col: u16, ) -> Self { Region { - start_col, start_line, - end_col, end_line, + start_col, + end_col, } } @@ -177,20 +177,20 @@ impl Located { ) -> Located { let region = Region { start_line, - start_col, end_line, + start_col, end_col, }; - Located { value, region } + Located { region, value } } pub fn at(region: Region, value: T) -> Located { - Located { value, region } + Located { region, value } } pub fn at_zero(value: T) -> Located { let region = Region::zero(); - Located { value, region } + Located { region, value } } } diff --git a/compiler/reporting/src/error/canonicalize.rs b/compiler/reporting/src/error/canonicalize.rs index 54d3aef773..1a259cb8f6 100644 --- a/compiler/reporting/src/error/canonicalize.rs +++ b/compiler/reporting/src/error/canonicalize.rs @@ -149,8 +149,8 @@ pub fn can_problem<'b>( let (doc, title) = crate::error::r#type::cyclic_alias(alloc, symbol, region, others); return Report { - filename, title, + filename, doc, }; } diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index 44b365825a..5e03b5ef6a 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -40,8 +40,8 @@ pub fn type_problem<'b>( .append(alloc.reflow(".")); Report { - filename, title, + filename, doc, } } @@ -85,8 +85,8 @@ pub fn type_problem<'b>( }; Report { - filename, title, + filename, doc, } } @@ -94,8 +94,8 @@ pub fn type_problem<'b>( let (doc, title) = cyclic_alias(alloc, symbol, region, others); Report { - filename, title, + filename, doc, } } diff --git a/editor/src/lang/ast.rs b/editor/src/lang/ast.rs index 3fe5057e7d..0c74afc81b 100644 --- a/editor/src/lang/ast.rs +++ b/editor/src/lang/ast.rs @@ -226,10 +226,10 @@ impl ShallowClone for ValueDef { fn shallow_clone(&self) -> Self { Self { pattern: self.pattern, - expr_type: match &self.expr_type { - Some((id, rigids)) => Some((*id, rigids.shallow_clone())), - None => None, - }, + expr_type: self + .expr_type + .as_ref() + .map(|(id, rigids)| (*id, rigids.shallow_clone())), expr_var: self.expr_var, } } diff --git a/editor/src/lang/pool.rs b/editor/src/lang/pool.rs index 0888e2a228..435f49fdf5 100644 --- a/editor/src/lang/pool.rs +++ b/editor/src/lang/pool.rs @@ -263,11 +263,16 @@ impl PoolStr { } } + #[allow(clippy::len_without_is_empty)] pub fn len(&self, pool: &Pool) -> usize { let contents = self.as_str(pool); contents.len() } + + pub fn is_empty(&self, pool: &Pool) -> bool { + self.len(pool) == 0 + } } impl ShallowClone for PoolStr {