From 012b4baa2ec87d60f084c4a19785cf7f42e7dfa7 Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 18 Aug 2021 18:33:33 +0200 Subject: [PATCH] clippy --- compiler/gen_llvm/src/llvm/build.rs | 41 +---------------------------- compiler/mono/src/alias_analysis.rs | 12 ++------- compiler/mono/src/borrow.rs | 4 +-- compiler/mono/src/expand_rc.rs | 18 +++++-------- compiler/mono/src/ir.rs | 30 ++------------------- compiler/mono/src/layout.rs | 17 ++++++------ 6 files changed, 20 insertions(+), 102 deletions(-) diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index d73287c71a..a3eef64241 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -3847,47 +3847,8 @@ pub fn build_proc<'a, 'ctx, 'env>( ) } - RawFunctionLayout::ZeroArgumentThunk(result) => { + RawFunctionLayout::ZeroArgumentThunk(_) => { // do nothing - /* - let bytes = roc_mono::alias_analysis::func_name_bytes_help( - symbol, - std::iter::empty(), - top_level.result, - ); - let func_name = FuncName(&bytes); - let func_solutions = mod_solutions.func_solutions(func_name).unwrap(); - - let mut it = func_solutions.specs(); - let func_spec = it.next().unwrap(); - debug_assert!( - it.next().is_none(), - "we expect only one specialization of this symbol" - ); - - let evaluator = function_value_by_func_spec( - env, - *func_spec, - symbol, - &[], - &top_level.result, - ); - - let ident_string = proc.name.as_str(&env.interns); - let fn_name: String = format!("{}_1", ident_string); - - let arena = env.arena; - - build_closure_caller_help( - env, - &fn_name, - evaluator, - name, - Vec::new_in(arena), - result, - &result, - ) - */ } } } diff --git a/compiler/mono/src/alias_analysis.rs b/compiler/mono/src/alias_analysis.rs index 9f84305705..d95ed886e9 100644 --- a/compiler/mono/src/alias_analysis.rs +++ b/compiler/mono/src/alias_analysis.rs @@ -64,18 +64,10 @@ where let mut hasher = DefaultHasher::new(); for layout in argument_layouts { - match layout { - _ => { - layout.hash(&mut hasher); - } - } + layout.hash(&mut hasher); } - match return_layout { - _ => { - return_layout.hash(&mut hasher); - } - } + return_layout.hash(&mut hasher); hasher.finish() }; diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index 51624dbce8..3a3d30a685 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -10,9 +10,7 @@ pub const OWNED: bool = false; pub const BORROWED: bool = true; fn should_borrow_layout(layout: &Layout) -> bool { - match layout { - _ => layout.is_refcounted(), - } + layout.is_refcounted() } pub fn infer_borrow<'a>( diff --git a/compiler/mono/src/expand_rc.rs b/compiler/mono/src/expand_rc.rs index 0bc8f2e45d..e52ee16041 100644 --- a/compiler/mono/src/expand_rc.rs +++ b/compiler/mono/src/expand_rc.rs @@ -160,12 +160,9 @@ impl<'a, 'i> Env<'a, 'i> { fn try_insert_struct_info(&mut self, symbol: Symbol, layout: &Layout<'a>) { use Layout::*; - match layout { - Struct(fields) => { - self.constructor_map.insert(symbol, 0); - self.layout_map.insert(symbol, Layout::Struct(fields)); - } - _ => {} + if let Struct(fields) = layout { + self.constructor_map.insert(symbol, 0); + self.layout_map.insert(symbol, Layout::Struct(fields)); } } @@ -359,13 +356,10 @@ pub fn expand_and_cancel_proc<'a>( let mut introduced = Vec::new_in(env.arena); for (layout, symbol) in arguments { - match layout { - Layout::Struct(fields) => { - env.insert_struct_info(*symbol, fields); + if let Layout::Struct(fields) = layout { + env.insert_struct_info(*symbol, fields); - introduced.push(*symbol); - } - _ => {} + introduced.push(*symbol); } } diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index ca7f1c3d4a..e92a669d28 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -2032,34 +2032,8 @@ fn specialize_external<'a>( aliases.insert(*symbol, (name, top_level, layout)); } - RawFunctionLayout::ZeroArgumentThunk(return_layout) => { - panic!("should be unused"); - /* - let assigned = env.unique_symbol(); - - let hole = env.arena.alloc(Stmt::Ret(assigned)); - - let body = force_thunk(env, name, return_layout, assigned, hole); - - let proc = Proc { - name, - args: &[], - body, - closure_data_layout: None, - ret_layout: return_layout, - is_self_recursive: SelfRecursive::NotSelfRecursive, - must_own_arguments: false, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, - }; - - let top_level = ProcLayout::new(env.arena, &[], return_layout); - - procs - .specialized - .insert((name, top_level), InProgressProc::Done(proc)); - - aliases.insert(*symbol, (name, top_level, layout)); - */ + RawFunctionLayout::ZeroArgumentThunk(_) => { + unreachable!("so far"); } } } diff --git a/compiler/mono/src/layout.rs b/compiler/mono/src/layout.rs index b5bd6f1a70..6ea929e1fa 100644 --- a/compiler/mono/src/layout.rs +++ b/compiler/mono/src/layout.rs @@ -440,17 +440,14 @@ impl<'a> LambdaSet<'a> { // here we rely on the fact that a union in a closure would be stored in a one-element record. // a closure representation that is itself union must be a of the shape `Closure1 ... | Closure2 ...` match union { - UnionLayout::NonRecursive(tags) => { - let index = self + UnionLayout::NonRecursive(_) => { + // get the fields from the set, where they are sorted in alphabetic order + // (and not yet sorted by their alignment) + let (index, (_, fields)) = self .set .iter() - .position(|(s, _)| *s == function_symbol) - .unwrap(); - - let (_, fields) = self - .set - .iter() - .find(|(s, _)| *s == function_symbol) + .enumerate() + .find(|(_, (s, _))| *s == function_symbol) .unwrap(); ClosureRepresentation::Union { @@ -473,6 +470,8 @@ impl<'a> LambdaSet<'a> { } } Layout::Struct(_) => { + // get the fields from the set, where they are sorted in alphabetic order + // (and not yet sorted by their alignment) let (_, fields) = self .set .iter()