From 899cbeabd74928aa2982c8fa9968e9a26d684e9f Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 29 Jul 2021 17:32:08 +0200 Subject: [PATCH 1/5] fix extra ampersands --- cli/src/build.rs | 6 +- cli/src/repl/eval.rs | 6 +- cli/src/repl/gen.rs | 2 +- compiler/build/src/program.rs | 4 +- compiler/can/src/constraint.rs | 6 +- compiler/can/src/def.rs | 30 ++++----- compiler/can/src/expr.rs | 8 +-- compiler/can/src/operator.rs | 8 +-- compiler/can/src/pattern.rs | 2 +- compiler/can/src/scope.rs | 2 +- compiler/can/tests/helpers/mod.rs | 2 +- compiler/can/tests/test_can.rs | 6 +- compiler/collections/src/all.rs | 4 +- compiler/constrain/src/expr.rs | 2 +- compiler/constrain/src/pattern.rs | 2 +- compiler/fmt/src/expr.rs | 2 +- compiler/gen_dev/src/lib.rs | 2 +- compiler/gen_dev/tests/dev_num.rs | 2 +- compiler/gen_dev/tests/helpers/eval.rs | 2 +- compiler/gen_llvm/src/llvm/bitcode.rs | 16 ++--- compiler/gen_llvm/src/llvm/build.rs | 72 +++++++++++----------- compiler/gen_llvm/src/llvm/build_dict.rs | 32 +++++----- compiler/gen_llvm/src/llvm/build_hash.rs | 16 ++--- compiler/gen_llvm/src/llvm/build_list.rs | 48 +++++++-------- compiler/gen_llvm/src/llvm/build_str.rs | 30 ++++----- compiler/gen_llvm/src/llvm/compare.rs | 18 +++--- compiler/gen_llvm/src/llvm/convert.rs | 2 +- compiler/gen_llvm/src/llvm/refcounting.rs | 14 ++--- compiler/load/src/file.rs | 52 ++++++++-------- compiler/load/tests/test_load.rs | 4 +- compiler/module/src/symbol.rs | 4 +- compiler/mono/src/alias_analysis.rs | 6 +- compiler/mono/src/decision_tree.rs | 10 +-- compiler/mono/src/expand_rc.rs | 4 +- compiler/mono/src/inc_dec.rs | 4 +- compiler/mono/src/ir.rs | 16 ++--- compiler/mono/src/layout.rs | 6 +- compiler/mono/src/reset_reuse.rs | 2 +- compiler/parse/src/expr.rs | 2 +- compiler/parse/src/number_literal.rs | 4 +- compiler/parse/src/pattern.rs | 4 +- compiler/parse/src/type_annotation.rs | 6 +- compiler/parse/tests/test_parse.rs | 16 ++--- compiler/reporting/src/error/parse.rs | 50 +++++++-------- compiler/reporting/src/error/type.rs | 8 +-- compiler/reporting/src/report.rs | 4 +- compiler/reporting/tests/helpers/mod.rs | 2 +- compiler/reporting/tests/test_reporting.rs | 18 +++--- compiler/solve/src/module.rs | 6 +- compiler/solve/src/solve.rs | 12 ++-- compiler/solve/tests/solve_expr.rs | 2 +- compiler/test_gen/src/gen_num.rs | 10 +-- compiler/test_gen/src/helpers/eval.rs | 6 +- compiler/test_mono/src/lib.rs | 4 +- compiler/types/src/pretty_print.rs | 10 +-- compiler/types/src/solved_types.rs | 16 ++--- compiler/types/src/types.rs | 16 ++--- compiler/unify/src/unify.rs | 4 +- docs/src/lib.rs | 4 +- editor/src/editor/code_lines.rs | 4 +- editor/src/editor/ed_error.rs | 2 +- editor/src/editor/markup/nodes.rs | 6 +- editor/src/editor/mvc/ed_model.rs | 6 +- editor/src/editor/mvc/ed_update.rs | 14 ++--- editor/src/editor/mvc/int_update.rs | 2 +- editor/src/editor/mvc/list_update.rs | 4 +- editor/src/editor/mvc/record_update.rs | 6 +- editor/src/editor/mvc/string_update.rs | 6 +- editor/src/editor/render_ast.rs | 4 +- editor/src/graphics/lowlevel/buffer.rs | 4 +- editor/src/graphics/lowlevel/pipelines.rs | 4 +- editor/src/graphics/primitives/text.rs | 4 +- editor/src/lang/ast.rs | 2 +- editor/src/lang/constrain.rs | 2 +- editor/src/lang/roc_file.rs | 4 +- editor/src/ui/tooltip.rs | 2 +- editor/tests/solve_expr2.rs | 2 +- vendor/morphic_lib/src/api.rs | 4 +- vendor/morphic_lib/src/preprocess.rs | 8 +-- 79 files changed, 372 insertions(+), 376 deletions(-) diff --git a/cli/src/build.rs b/cli/src/build.rs index d75bf0361b..6a498fc5f5 100644 --- a/cli/src/build.rs +++ b/cli/src/build.rs @@ -65,7 +65,7 @@ pub fn build_file<'a>( }; let loaded = roc_load::file::load_and_monomorphize( - &arena, + arena, roc_file_path.clone(), stdlib, src_dir.as_path(), @@ -128,11 +128,11 @@ pub fn build_file<'a>( let cwd = roc_file_path.parent().unwrap(); let binary_path = cwd.join(&*loaded.output_path); // TODO should join ".exe" on Windows let code_gen_timing = program::gen_from_mono_module( - &arena, + arena, loaded, &roc_file_path, Triple::host(), - &app_o_file, + app_o_file, opt_level, emit_debug_info, ); diff --git a/cli/src/repl/eval.rs b/cli/src/repl/eval.rs index 5c6ee43a68..9d28e7b550 100644 --- a/cli/src/repl/eval.rs +++ b/cli/src/repl/eval.rs @@ -479,7 +479,7 @@ fn list_to_ast<'a>( }; let arena = env.arena; - let mut output = Vec::with_capacity_in(len, &arena); + let mut output = Vec::with_capacity_in(len, arena); let elem_size = elem_layout.stack_size(env.ptr_bytes) as usize; for index in 0..len { @@ -533,7 +533,7 @@ where { let arena = env.arena; let subs = env.subs; - let mut output = Vec::with_capacity_in(sequence.len(), &arena); + let mut output = Vec::with_capacity_in(sequence.len(), arena); // We'll advance this as we iterate through the fields let mut field_ptr = ptr as *const u8; @@ -560,7 +560,7 @@ fn struct_to_ast<'a>( ) -> Expr<'a> { let arena = env.arena; let subs = env.subs; - let mut output = Vec::with_capacity_in(field_layouts.len(), &arena); + let mut output = Vec::with_capacity_in(field_layouts.len(), arena); // The fields, sorted alphabetically let mut sorted_fields = { diff --git a/cli/src/repl/gen.rs b/cli/src/repl/gen.rs index 797fdba999..f10ec9f704 100644 --- a/cli/src/repl/gen.rs +++ b/cli/src/repl/gen.rs @@ -219,7 +219,7 @@ pub fn gen_and_eval<'a>( ); } - let lib = module_to_dylib(&env.module, &target, opt_level) + let lib = module_to_dylib(env.module, &target, opt_level) .expect("Error loading compiled dylib for test"); let res_answer = unsafe { eval::jit_to_ast( diff --git a/compiler/build/src/program.rs b/compiler/build/src/program.rs index 48a0456693..d3e68f112f 100644 --- a/compiler/build/src/program.rs +++ b/compiler/build/src/program.rs @@ -132,7 +132,7 @@ pub fn gen_from_mono_module( // Compile and add all the Procs before adding main let ptr_bytes = target.pointer_width().unwrap().bytes() as u32; let env = roc_gen_llvm::llvm::build::Env { - arena: &arena, + arena, builder: &builder, dibuilder: &dibuilder, compile_unit: &compile_unit, @@ -243,7 +243,7 @@ pub fn gen_from_mono_module( target::target_machine(&target, convert_opt_level(opt_level), reloc, model).unwrap(); target_machine - .write_to_file(&env.module, FileType::Object, &app_o_file) + .write_to_file(env.module, FileType::Object, app_o_file) .expect("Writing .o file failed"); } diff --git a/compiler/can/src/constraint.rs b/compiler/can/src/constraint.rs index dfac99f49e..addc786a08 100644 --- a/compiler/can/src/constraint.rs +++ b/compiler/can/src/constraint.rs @@ -64,7 +64,7 @@ impl Constraint { fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDetail) { for var in &detail.type_variables { - if !(declared.rigid_vars.contains(&var) || declared.flex_vars.contains(&var)) { + if !(declared.rigid_vars.contains(var) || declared.flex_vars.contains(var)) { accum.type_variables.insert(*var); } } @@ -82,11 +82,11 @@ fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDe // recursion vars should be always rigid for var in &detail.recursion_variables { - if declared.flex_vars.contains(&var) { + if declared.flex_vars.contains(var) { panic!("recursion variable {:?} is declared as flex", var); } - if !declared.rigid_vars.contains(&var) { + if !declared.rigid_vars.contains(var) { accum.recursion_variables.insert(*var); } } diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index b4a4652924..146ecf838f 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -380,7 +380,7 @@ pub fn sort_can_defs( // // In the above example, `f` cannot reference `a`, and in the closure // a call to `f` cannot cycle back to `a`. - let mut loc_succ = local_successors(&references, &env.closures); + let mut loc_succ = local_successors(references, &env.closures); // if the current symbol is a closure, peek into its body if let Some(References { lookups, .. }) = env.closures.get(symbol) { @@ -430,7 +430,7 @@ pub fn sort_can_defs( // // In the above example, `f` cannot reference `a`, and in the closure // a call to `f` cannot cycle back to `a`. - let mut loc_succ = local_successors(&references, &env.closures); + let mut loc_succ = local_successors(references, &env.closures); // if the current symbol is a closure, peek into its body if let Some(References { lookups, .. }) = env.closures.get(symbol) { @@ -454,7 +454,7 @@ pub fn sort_can_defs( let direct_successors = |symbol: &Symbol| -> ImSet { match refs_by_symbol.get(symbol) { Some((_, references)) => { - let mut loc_succ = local_successors(&references, &env.closures); + let mut loc_succ = local_successors(references, &env.closures); // NOTE: if the symbol is a closure we DONT look into its body @@ -540,7 +540,7 @@ pub fn sort_can_defs( ), Some((region, _)) => { let expr_region = - can_defs_by_symbol.get(&symbol).unwrap().loc_expr.region; + can_defs_by_symbol.get(symbol).unwrap().loc_expr.region; let entry = CycleEntry { symbol: *symbol, @@ -662,11 +662,11 @@ fn group_to_declaration( // for a definition, so every definition is only inserted (thus typechecked and emitted) once let mut seen_pattern_regions: ImSet = ImSet::default(); - for cycle in strongly_connected_components(&group, filtered_successors) { + for cycle in strongly_connected_components(group, filtered_successors) { if cycle.len() == 1 { let symbol = &cycle[0]; - if let Some(can_def) = can_defs_by_symbol.get(&symbol) { + if let Some(can_def) = can_defs_by_symbol.get(symbol) { let mut new_def = can_def.clone(); // Determine recursivity of closures that are not tail-recursive @@ -678,7 +678,7 @@ fn group_to_declaration( *recursive = closure_recursivity(*symbol, closures); } - let is_recursive = successors(&symbol).contains(&symbol); + let is_recursive = successors(symbol).contains(symbol); if !seen_pattern_regions.contains(&new_def.loc_pattern.region) { if is_recursive { @@ -854,7 +854,7 @@ fn canonicalize_pending_def<'a>( }; for (_, (symbol, _)) in scope.idents() { - if !vars_by_symbol.contains_key(&symbol) { + if !vars_by_symbol.contains_key(symbol) { continue; } @@ -999,7 +999,7 @@ fn canonicalize_pending_def<'a>( // // Only defs of the form (foo = ...) can be closure declarations or self tail calls. if let ( - &ast::Pattern::Identifier(ref _name), + &ast::Pattern::Identifier(_name), &Pattern::Identifier(ref defined_symbol), &Closure { function_type, @@ -1021,7 +1021,7 @@ fn canonicalize_pending_def<'a>( // Since everywhere in the code it'll be referred to by its defined name, // remove its generated name from the closure map. (We'll re-insert it later.) - let references = env.closures.remove(&symbol).unwrap_or_else(|| { + let references = env.closures.remove(symbol).unwrap_or_else(|| { panic!( "Tried to remove symbol {:?} from procedures, but it was not found: {:?}", symbol, env.closures @@ -1065,7 +1065,7 @@ fn canonicalize_pending_def<'a>( // Store the referenced locals in the refs_by_symbol map, so we can later figure out // which defined names reference each other. for (_, (symbol, region)) in scope.idents() { - if !vars_by_symbol.contains_key(&symbol) { + if !vars_by_symbol.contains_key(symbol) { continue; } @@ -1111,7 +1111,7 @@ fn canonicalize_pending_def<'a>( let outer_identifier = env.tailcallable_symbol; if let ( - &ast::Pattern::Identifier(ref _name), + &ast::Pattern::Identifier(_name), &Pattern::Identifier(ref defined_symbol), ) = (&loc_pattern.value, &loc_can_pattern.value) { @@ -1144,7 +1144,7 @@ fn canonicalize_pending_def<'a>( // // Only defs of the form (foo = ...) can be closure declarations or self tail calls. if let ( - &ast::Pattern::Identifier(ref _name), + &ast::Pattern::Identifier(_name), &Pattern::Identifier(ref defined_symbol), &Closure { function_type, @@ -1166,7 +1166,7 @@ fn canonicalize_pending_def<'a>( // Since everywhere in the code it'll be referred to by its defined name, // remove its generated name from the closure map. (We'll re-insert it later.) - let references = env.closures.remove(&symbol).unwrap_or_else(|| { + let references = env.closures.remove(symbol).unwrap_or_else(|| { panic!( "Tried to remove symbol {:?} from procedures, but it was not found: {:?}", symbol, env.closures @@ -1555,7 +1555,7 @@ fn correct_mutual_recursive_type_alias<'a>( let mut loc_succ = alias.typ.symbols(); // remove anything that is not defined in the current block loc_succ.retain(|key| symbols_introduced.contains(key)); - loc_succ.remove(&symbol); + loc_succ.remove(symbol); loc_succ } diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index 4116a51128..a129d74f08 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -980,7 +980,7 @@ where visited.insert(defined_symbol); for local in refs.lookups.iter() { - if !visited.contains(&local) { + if !visited.contains(local) { let other_refs: References = references_from_local(*local, visited, refs_by_def, closures); @@ -991,7 +991,7 @@ where } for call in refs.calls.iter() { - if !visited.contains(&call) { + if !visited.contains(call) { let other_refs = references_from_call(*call, visited, refs_by_def, closures); answer = answer.union(other_refs); @@ -1022,7 +1022,7 @@ where visited.insert(call_symbol); for closed_over_local in references.lookups.iter() { - if !visited.contains(&closed_over_local) { + if !visited.contains(closed_over_local) { let other_refs = references_from_local(*closed_over_local, visited, refs_by_def, closures); @@ -1033,7 +1033,7 @@ where } for call in references.calls.iter() { - if !visited.contains(&call) { + if !visited.contains(call) { let other_refs = references_from_call(*call, visited, refs_by_def, closures); answer = answer.union(other_refs); diff --git a/compiler/can/src/operator.rs b/compiler/can/src/operator.rs index 4b6fbf14f2..36b790764d 100644 --- a/compiler/can/src/operator.rs +++ b/compiler/can/src/operator.rs @@ -276,7 +276,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a }) } When(loc_cond_expr, branches) => { - let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, &loc_cond_expr)); + let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, loc_cond_expr)); let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena); for branch in branches.iter() { @@ -346,7 +346,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a } If(if_thens, final_else_branch) => { // If does not get desugared into `when` so we can give more targeted error messages during type checking. - let desugared_final_else = &*arena.alloc(desugar_expr(arena, &final_else_branch)); + let desugared_final_else = &*arena.alloc(desugar_expr(arena, final_else_branch)); let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena); @@ -363,8 +363,8 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a }) } Expect(condition, continuation) => { - let desugared_condition = &*arena.alloc(desugar_expr(arena, &condition)); - let desugared_continuation = &*arena.alloc(desugar_expr(arena, &continuation)); + let desugared_condition = &*arena.alloc(desugar_expr(arena, condition)); + let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation)); arena.alloc(Located { value: Expect(desugared_condition, desugared_continuation), region: loc_expr.region, diff --git a/compiler/can/src/pattern.rs b/compiler/can/src/pattern.rs index 28ea70f9e5..92b1ca611b 100644 --- a/compiler/can/src/pattern.rs +++ b/compiler/can/src/pattern.rs @@ -185,7 +185,7 @@ pub fn canonicalize_pattern<'a>( } } - FloatLiteral(ref string) => match pattern_type { + FloatLiteral(string) => match pattern_type { WhenBranch => match finish_parsing_float(string) { Err(_error) => { let problem = MalformedPatternProblem::MalformedFloat; diff --git a/compiler/can/src/scope.rs b/compiler/can/src/scope.rs index 9037d6e193..4df6919ecd 100644 --- a/compiler/can/src/scope.rs +++ b/compiler/can/src/scope.rs @@ -124,7 +124,7 @@ impl Scope { // If this IdentId was already added previously // when the value was exposed in the module header, // use that existing IdentId. Otherwise, create a fresh one. - let ident_id = match exposed_ident_ids.get_id(&ident.as_inline_str()) { + let ident_id = match exposed_ident_ids.get_id(ident.as_inline_str()) { Some(ident_id) => *ident_id, None => all_ident_ids.add(ident.clone().into()), }; diff --git a/compiler/can/tests/helpers/mod.rs b/compiler/can/tests/helpers/mod.rs index 8540427d98..e43e28bf54 100644 --- a/compiler/can/tests/helpers/mod.rs +++ b/compiler/can/tests/helpers/mod.rs @@ -34,7 +34,7 @@ pub struct CanExprOut { #[allow(dead_code)] pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut { - let loc_expr = roc_parse::test_helpers::parse_loc_with(&arena, expr_str).unwrap_or_else(|e| { + let loc_expr = roc_parse::test_helpers::parse_loc_with(arena, expr_str).unwrap_or_else(|e| { panic!( "can_expr_with() got a parse error when attempting to canonicalize:\n\n{:?} {:?}", expr_str, e diff --git a/compiler/can/tests/test_can.rs b/compiler/can/tests/test_can.rs index 68d3139c25..7e2d615b8a 100644 --- a/compiler/can/tests/test_can.rs +++ b/compiler/can/tests/test_can.rs @@ -145,7 +145,7 @@ mod test_can { let region = Region::zero(); assert_can( - &string.clone(), + string.clone(), RuntimeError(RuntimeError::InvalidFloat( FloatErrorKind::Error, region, @@ -658,7 +658,7 @@ mod test_can { recursive: recursion, .. }) => recursion.clone(), - Some(other @ _) => { + Some(other) => { panic!("assignment at {} is not a closure, but a {:?}", i, other) } None => { @@ -680,7 +680,7 @@ mod test_can { recursive: recursion, .. } => recursion.clone(), - other @ _ => { + other => { panic!("assignment at {} is not a closure, but a {:?}", i, other) } } diff --git a/compiler/collections/src/all.rs b/compiler/collections/src/all.rs index f473ef4e97..efd74751bb 100644 --- a/compiler/collections/src/all.rs +++ b/compiler/collections/src/all.rs @@ -79,7 +79,7 @@ where let mut buf = String::new_in(arena); if let Some(first) = strings.next() { - buf.push_str(&first); + buf.push_str(first); for string in strings { buf.reserve(join_str.len() + string.len()); @@ -133,7 +133,7 @@ where let mut answer = MutMap::default(); for (key, right_value) in map2 { - match std::collections::HashMap::get(map1, &key) { + match std::collections::HashMap::get(map1, key) { None => (), Some(left_value) => { answer.insert(key.clone(), (left_value.clone(), right_value.clone())); diff --git a/compiler/constrain/src/expr.rs b/compiler/constrain/src/expr.rs index 05dff22dd7..09020430e5 100644 --- a/compiler/constrain/src/expr.rs +++ b/compiler/constrain/src/expr.rs @@ -1446,7 +1446,7 @@ fn instantiate_rigids( let mut rigid_substitution: ImMap = ImMap::default(); for (name, var) in introduced_vars.var_by_name.iter() { - if let Some(existing_rigid) = ftv.get(&name) { + if let Some(existing_rigid) = ftv.get(name) { rigid_substitution.insert(*var, Type::Variable(*existing_rigid)); } else { // It's possible to use this rigid in nested defs diff --git a/compiler/constrain/src/pattern.rs b/compiler/constrain/src/pattern.rs index 8a2f5d9250..da28a4b065 100644 --- a/compiler/constrain/src/pattern.rs +++ b/compiler/constrain/src/pattern.rs @@ -206,7 +206,7 @@ pub fn constrain_pattern( let pat_type = Type::Variable(*var); let expected = PExpected::NoExpectation(pat_type.clone()); - if !state.headers.contains_key(&symbol) { + if !state.headers.contains_key(symbol) { state .headers .insert(*symbol, Located::at(region, pat_type.clone())); diff --git a/compiler/fmt/src/expr.rs b/compiler/fmt/src/expr.rs index ebe9036600..77f4d96b3c 100644 --- a/compiler/fmt/src/expr.rs +++ b/compiler/fmt/src/expr.rs @@ -295,7 +295,7 @@ impl<'a> Formattable<'a> for Expr<'a> { items, final_comments, } => { - fmt_list(buf, &items, final_comments, indent); + fmt_list(buf, items, final_comments, indent); } BinOps(lefts, right) => fmt_bin_ops(buf, lefts, right, false, parens, indent), UnaryOp(sub_expr, unary_op) => { diff --git a/compiler/gen_dev/src/lib.rs b/compiler/gen_dev/src/lib.rs index af414118f0..f6ee048e7b 100644 --- a/compiler/gen_dev/src/lib.rs +++ b/compiler/gen_dev/src/lib.rs @@ -74,7 +74,7 @@ where /// build_proc creates a procedure and outputs it to the wrapped object writer. fn build_proc(&mut self, proc: Proc<'a>) -> Result<(&'a [u8], &[Relocation]), String> { self.reset(); - self.load_args(&proc.args)?; + self.load_args(proc.args)?; // let start = std::time::Instant::now(); self.scan_ast(&proc.body); self.create_free_map(); diff --git a/compiler/gen_dev/tests/dev_num.rs b/compiler/gen_dev/tests/dev_num.rs index aa758c6587..010bf078d0 100644 --- a/compiler/gen_dev/tests/dev_num.rs +++ b/compiler/gen_dev/tests/dev_num.rs @@ -31,7 +31,7 @@ mod dev_num { assert_evals_to!("-0.0", 0.0, f64); assert_evals_to!("1.0", 1.0, f64); assert_evals_to!("-1.0", -1.0, f64); - assert_evals_to!("3.1415926535897932", 3.1415926535897932, f64); + assert_evals_to!("3.1415926535897932", 3.141_592_653_589_793, f64); assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64); assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64); } diff --git a/compiler/gen_dev/tests/helpers/eval.rs b/compiler/gen_dev/tests/helpers/eval.rs index f3403bb9d4..48893f63c6 100644 --- a/compiler/gen_dev/tests/helpers/eval.rs +++ b/compiler/gen_dev/tests/helpers/eval.rs @@ -49,7 +49,7 @@ pub fn helper<'a>( let loaded = roc_load::file::load_and_monomorphize_from_str( arena, filename, - &module_src, + module_src, &stdlib, src_dir, exposed_types, diff --git a/compiler/gen_llvm/src/llvm/bitcode.rs b/compiler/gen_llvm/src/llvm/bitcode.rs index b92df1f79b..bfbfaeb3b3 100644 --- a/compiler/gen_llvm/src/llvm/bitcode.rs +++ b/compiler/gen_llvm/src/llvm/bitcode.rs @@ -78,7 +78,7 @@ pub fn build_has_tag_id<'a, 'ctx, 'env>( match env.module.get_function(fn_name) { Some(function_value) => function_value, - None => build_has_tag_id_help(env, union_layout, &fn_name), + None => build_has_tag_id_help(env, union_layout, fn_name), } } @@ -97,9 +97,9 @@ fn build_has_tag_id_help<'a, 'ctx, 'env>( let function_value = crate::llvm::refcounting::build_header_help( env, - &fn_name, + fn_name, output_type.into(), - &argument_types, + argument_types, ); // called from zig, must use C calling convention @@ -204,7 +204,7 @@ pub fn build_transform_caller<'a, 'ctx, 'env>( function, closure_data_layout, argument_layouts, - &fn_name, + fn_name, ), } } @@ -225,7 +225,7 @@ fn build_transform_caller_help<'a, 'ctx, 'env>( let function_value = crate::llvm::refcounting::build_header_help( env, - &fn_name, + fn_name, env.context.void_type().into(), &(bumpalo::vec![ in env.arena; BasicTypeEnum::PointerType(arg_type); argument_layouts.len() + 2 ]), ); @@ -394,7 +394,7 @@ fn build_rc_wrapper<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_RC_REF; let fn_name = layout_ids - .get(symbol, &layout) + .get(symbol, layout) .to_symbol_string(symbol, &env.interns); let fn_name = match rc_operation { @@ -489,7 +489,7 @@ pub fn build_eq_wrapper<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_EQ_REF; let fn_name = layout_ids - .get(symbol, &layout) + .get(symbol, layout) .to_symbol_string(symbol, &env.interns); let function_value = match env.module.get_function(fn_name.as_str()) { @@ -576,7 +576,7 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>( let function_value = crate::llvm::refcounting::build_header_help( env, - &fn_name, + fn_name, env.context.i8_type().into(), &[arg_type.into(), arg_type.into(), arg_type.into()], ); diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index c7564c588c..b8f62fb2ba 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -347,7 +347,7 @@ pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Modu // we compile the builtins into LLVM bitcode let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc"); - let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name); + let memory_buffer = MemoryBuffer::create_from_memory_range(bitcode_bytes, module_name); let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx) .unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err)); @@ -632,7 +632,7 @@ pub fn float_with_precision<'a, 'ctx, 'env>( Builtin::Decimal => call_bitcode_fn( env, &[env.context.f64_type().const_float(value).into()], - &bitcode::DEC_FROM_F64, + bitcode::DEC_FROM_F64, ), Builtin::Float64 => env.context.f64_type().const_float(value).into(), Builtin::Float32 => env.context.f32_type().const_float(value).into(), @@ -976,7 +976,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( // The layout of the struct expects them to be dropped! let (field_expr, field_layout) = load_symbol_and_layout(scope, symbol); if !field_layout.is_dropped_because_empty() { - field_types.push(basic_type_from_layout(env, &field_layout)); + field_types.push(basic_type_from_layout(env, field_layout)); field_vals.push(field_expr); } @@ -1187,7 +1187,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( ) } UnionLayout::NonNullableUnwrapped(field_layouts) => { - let struct_layout = Layout::Struct(&field_layouts); + let struct_layout = Layout::Struct(field_layouts); let struct_type = basic_type_from_layout(env, &struct_layout); @@ -1260,7 +1260,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( // cast the argument bytes into the desired shape for this tag let (argument, _structure_layout) = load_symbol_and_layout(scope, structure); - get_tag_id(env, parent, &union_layout, argument).into() + get_tag_id(env, parent, union_layout, argument).into() } } } @@ -1459,7 +1459,7 @@ pub fn build_tag<'a, 'ctx, 'env>( union_layout, tag_id, arguments, - &tag_field_layouts, + tag_field_layouts, tags, reuse_allocation, parent, @@ -1491,7 +1491,7 @@ pub fn build_tag<'a, 'ctx, 'env>( union_layout, tag_id, arguments, - &tag_field_layouts, + tag_field_layouts, tags, reuse_allocation, parent, @@ -2269,7 +2269,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( scope, parent, layout, - &expr, + expr, ); // Make a new scope which includes the binding we just encountered. @@ -2399,7 +2399,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( cond_layout, cond_symbol, } => { - let ret_type = basic_type_from_layout(env, &ret_layout); + let ret_type = basic_type_from_layout(env, ret_layout); let switch_args = SwitchArgsIr { cond_layout: *cond_layout, @@ -2477,7 +2477,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( ); // remove this join point again - scope.join_points.remove(&id); + scope.join_points.remove(id); cont_block.move_after(phi_block).unwrap(); @@ -3121,7 +3121,7 @@ where let call_result = { let call = builder.build_invoke( function, - &arguments, + arguments, then_block, catch_block, "call_roc_function", @@ -3291,7 +3291,7 @@ fn make_exception_catching_wrapper<'a, 'ctx, 'env>( // Add main to the module. let wrapper_function = add_func( env.module, - &wrapper_function_name, + wrapper_function_name, wrapper_function_type, Linkage::External, C_CALL_CONV, @@ -3414,7 +3414,7 @@ fn build_procedures_help<'a, 'ctx, 'env>( // Add all the Proc headers to the module. // We have to do this in a separate pass first, // because their bodies may reference each other. - let headers = build_proc_headers(env, &mod_solutions, procedures, &mut scope); + let headers = build_proc_headers(env, mod_solutions, procedures, &mut scope); let (_, function_pass) = construct_optimization_passes(env.module, opt_level); @@ -3428,7 +3428,7 @@ fn build_procedures_help<'a, 'ctx, 'env>( current_scope.retain_top_level_thunks_for_module(home); build_proc( - &env, + env, mod_solutions, &mut layout_ids, func_spec_solutions, @@ -3441,7 +3441,7 @@ fn build_procedures_help<'a, 'ctx, 'env>( env.dibuilder.finalize(); if fn_val.verify(true) { - function_pass.run_on(&fn_val); + function_pass.run_on(fn_val); } else { let mode = "NON-OPTIMIZED"; @@ -3511,7 +3511,7 @@ fn build_proc_header<'a, 'ctx, 'env>( let mut arg_basic_types = Vec::with_capacity_in(args.len(), arena); for (layout, _) in args.iter() { - let arg_type = basic_type_from_layout(env, &layout); + let arg_type = basic_type_from_layout(env, layout); arg_basic_types.push(arg_type); } @@ -5426,7 +5426,7 @@ fn build_int_binop<'a, 'ctx, 'env>( } } NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(), - NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], &bitcode::NUM_POW_INT), + NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_POW_INT), NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(), NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(), NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(), @@ -5523,7 +5523,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_add(lhs, rhs, "add_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let then_block = context.append_basic_block(parent, "then_block"); let throw_block = context.append_basic_block(parent, "throw_block"); @@ -5544,7 +5544,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_add(lhs, rhs, "add_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let is_infinite = bd.build_not(is_finite, "negate"); let struct_type = context.struct_type( @@ -5572,7 +5572,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_sub(lhs, rhs, "sub_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let then_block = context.append_basic_block(parent, "then_block"); let throw_block = context.append_basic_block(parent, "throw_block"); @@ -5593,7 +5593,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_sub(lhs, rhs, "sub_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let is_infinite = bd.build_not(is_finite, "negate"); let struct_type = context.struct_type( @@ -5621,7 +5621,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_mul(lhs, rhs, "mul_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let then_block = context.append_basic_block(parent, "then_block"); let throw_block = context.append_basic_block(parent, "throw_block"); @@ -5642,7 +5642,7 @@ fn build_float_binop<'a, 'ctx, 'env>( let result = bd.build_float_mul(lhs, rhs, "mul_float"); let is_finite = - call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value(); + call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value(); let is_infinite = bd.build_not(is_finite, "negate"); let struct_type = context.struct_type( @@ -5688,9 +5688,9 @@ fn build_dec_binop<'a, 'ctx, 'env>( use roc_module::low_level::LowLevel::*; match op { - NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_ADD_WITH_OVERFLOW), - NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_SUB_WITH_OVERFLOW), - NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_MUL_WITH_OVERFLOW), + NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_ADD_WITH_OVERFLOW), + NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_SUB_WITH_OVERFLOW), + NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_MUL_WITH_OVERFLOW), NumAdd => build_dec_binop_throw_on_overflow( env, parent, @@ -5715,7 +5715,7 @@ fn build_dec_binop<'a, 'ctx, 'env>( rhs, "decimal multiplication overflowed", ), - NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_DIV), + NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_DIV), _ => { unreachable!("Unrecognized int binary operation: {:?}", op); } @@ -5938,10 +5938,10 @@ fn build_float_unary_op<'a, 'ctx, 'env>( env.context.i64_type(), "num_floor", ), - NumIsFinite => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_IS_FINITE), - NumAtan => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ATAN), - NumAcos => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ACOS), - NumAsin => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ASIN), + NumIsFinite => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_IS_FINITE), + NumAtan => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ATAN), + NumAcos => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ACOS), + NumAsin => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ASIN), _ => { unreachable!("Unrecognized int unary operation: {:?}", op); } @@ -6107,7 +6107,7 @@ fn cxa_allocate_exception<'a, 'ctx, 'env>( let context = env.context; let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic); - let function = match module.get_function(&name) { + let function = match module.get_function(name) { Some(gvalue) => gvalue, None => { // void *__cxa_allocate_exception(size_t thrown_size); @@ -6141,7 +6141,7 @@ fn cxa_throw_exception<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, info: BasicVal let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic); - let function = match module.get_function(&name) { + let function = match module.get_function(name) { Some(value) => value, None => { // void __cxa_throw (void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ); @@ -6207,7 +6207,7 @@ fn get_gxx_personality_v0<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> Function let module = env.module; let context = env.context; - match module.get_function(&name) { + match module.get_function(name) { Some(gvalue) => gvalue, None => { let personality_func = add_func( @@ -6229,7 +6229,7 @@ fn cxa_end_catch(env: &Env<'_, '_, '_>) { let module = env.module; let context = env.context; - let function = match module.get_function(&name) { + let function = match module.get_function(name) { Some(gvalue) => gvalue, None => { let cxa_end_catch = add_func( @@ -6257,7 +6257,7 @@ fn cxa_begin_catch<'a, 'ctx, 'env>( let module = env.module; let context = env.context; - let function = match module.get_function(&name) { + let function = match module.get_function(name) { Some(gvalue) => gvalue, None => { let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic); diff --git a/compiler/gen_llvm/src/llvm/build_dict.rs b/compiler/gen_llvm/src/llvm/build_dict.rs index 73f799466e..bb6c8189bc 100644 --- a/compiler/gen_llvm/src/llvm/build_dict.rs +++ b/compiler/gen_llvm/src/llvm/build_dict.rs @@ -64,7 +64,7 @@ pub fn dict_len<'a, 'ctx, 'env>( .build_alloca(dict_as_zig_dict.get_type(), "dict_ptr"); env.builder.build_store(dict_ptr, dict_as_zig_dict); - call_bitcode_fn(env, &[dict_ptr.into()], &bitcode::DICT_LEN) + call_bitcode_fn(env, &[dict_ptr.into()], bitcode::DICT_LEN) } Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(), _ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout), @@ -78,7 +78,7 @@ pub fn dict_empty<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> BasicValueEnum<' // we must give a pointer for the bitcode function to write the result into let result_alloc = env.builder.build_alloca(roc_dict_type, "dict_empty"); - call_void_bitcode_fn(env, &[result_alloc.into()], &bitcode::DICT_EMPTY); + call_void_bitcode_fn(env, &[result_alloc.into()], bitcode::DICT_EMPTY); env.builder.build_load(result_alloc, "load_result") } @@ -140,7 +140,7 @@ pub fn dict_insert<'a, 'ctx, 'env>( dec_value_fn.as_global_value().as_pointer_value().into(), result_ptr.into(), ], - &bitcode::DICT_INSERT, + bitcode::DICT_INSERT, ); env.builder.build_load(result_ptr, "load_result") @@ -199,7 +199,7 @@ pub fn dict_remove<'a, 'ctx, 'env>( dec_value_fn.as_global_value().as_pointer_value().into(), result_ptr.into(), ], - &bitcode::DICT_REMOVE, + bitcode::DICT_REMOVE, ); env.builder.build_load(result_ptr, "load_result") @@ -250,7 +250,7 @@ pub fn dict_contains<'a, 'ctx, 'env>( hash_fn.as_global_value().as_pointer_value().into(), eq_fn.as_global_value().as_pointer_value().into(), ], - &bitcode::DICT_CONTAINS, + bitcode::DICT_CONTAINS, ) } @@ -303,7 +303,7 @@ pub fn dict_get<'a, 'ctx, 'env>( eq_fn.as_global_value().as_pointer_value().into(), inc_value_fn.as_global_value().as_pointer_value().into(), ], - &bitcode::DICT_GET, + bitcode::DICT_GET, ) .into_struct_value(); @@ -415,7 +415,7 @@ pub fn dict_elements_rc<'a, 'ctx, 'env>( key_fn.as_global_value().as_pointer_value().into(), value_fn.as_global_value().as_pointer_value().into(), ], - &bitcode::DICT_ELEMENTS_RC, + bitcode::DICT_ELEMENTS_RC, ); } @@ -460,7 +460,7 @@ pub fn dict_keys<'a, 'ctx, 'env>( inc_key_fn.as_global_value().as_pointer_value().into(), list_ptr.into(), ], - &bitcode::DICT_KEYS, + bitcode::DICT_KEYS, ); let list_ptr = env @@ -527,7 +527,7 @@ pub fn dict_union<'a, 'ctx, 'env>( inc_value_fn.as_global_value().as_pointer_value().into(), output_ptr.into(), ], - &bitcode::DICT_UNION, + bitcode::DICT_UNION, ); env.builder.build_load(output_ptr, "load_output_ptr") @@ -549,7 +549,7 @@ pub fn dict_difference<'a, 'ctx, 'env>( dict2, key_layout, value_layout, - &bitcode::DICT_DIFFERENCE, + bitcode::DICT_DIFFERENCE, ) } @@ -569,7 +569,7 @@ pub fn dict_intersection<'a, 'ctx, 'env>( dict2, key_layout, value_layout, - &bitcode::DICT_INTERSECTION, + bitcode::DICT_INTERSECTION, ) } @@ -674,7 +674,7 @@ pub fn dict_walk<'a, 'ctx, 'env>( layout_width(env, accum_layout), env.builder.build_bitcast(output_ptr, u8_ptr, "to_opaque"), ], - &bitcode::DICT_WALK, + bitcode::DICT_WALK, ); env.builder.build_load(output_ptr, "load_output_ptr") @@ -721,7 +721,7 @@ pub fn dict_values<'a, 'ctx, 'env>( inc_value_fn.as_global_value().as_pointer_value().into(), list_ptr.into(), ], - &bitcode::DICT_VALUES, + bitcode::DICT_VALUES, ); let list_ptr = env @@ -784,7 +784,7 @@ pub fn set_from_list<'a, 'ctx, 'env>( dec_key_fn.as_global_value().as_pointer_value().into(), result_alloca.into(), ], - &bitcode::SET_FROM_LIST, + bitcode::SET_FROM_LIST, ); env.builder.build_load(result_alloca, "load_result") @@ -800,7 +800,7 @@ fn build_hash_wrapper<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_HASH_REF; let fn_name = layout_ids - .get(symbol, &layout) + .get(symbol, layout) .to_symbol_string(symbol, &env.interns); let function_value = match env.module.get_function(fn_name.as_str()) { @@ -867,7 +867,7 @@ fn dict_symbol_to_zig_dict<'a, 'ctx, 'env>( let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap(); - complex_bitcast(&env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict") + complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict") .into_struct_value() } diff --git a/compiler/gen_llvm/src/llvm/build_hash.rs b/compiler/gen_llvm/src/llvm/build_hash.rs index fb0db4c879..9337e25ee1 100644 --- a/compiler/gen_llvm/src/llvm/build_hash.rs +++ b/compiler/gen_llvm/src/llvm/build_hash.rs @@ -130,7 +130,7 @@ fn hash_builtin<'a, 'ctx, 'env>( | Builtin::Float16 | Builtin::Decimal | Builtin::Usize => { - let hash_bytes = store_and_use_as_u8_ptr(env, val, &layout); + let hash_bytes = store_and_use_as_u8_ptr(env, val, layout); hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes)) } Builtin::Str => { @@ -138,7 +138,7 @@ fn hash_builtin<'a, 'ctx, 'env>( call_bitcode_fn( env, &[seed.into(), build_str::str_to_i128(env, val).into()], - &bitcode::DICT_HASH_STR, + bitcode::DICT_HASH_STR, ) .into_int_value() } @@ -327,7 +327,7 @@ fn build_hash_tag<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_HASH; let fn_name = layout_ids - .get(symbol, &layout) + .get(symbol, layout) .to_symbol_string(symbol, &env.interns); let function = match env.module.get_function(fn_name.as_str()) { @@ -335,7 +335,7 @@ fn build_hash_tag<'a, 'ctx, 'env>( None => { let seed_type = env.context.i64_type(); - let arg_type = basic_type_from_layout(env, &layout); + let arg_type = basic_type_from_layout(env, layout); let function_value = crate::llvm::refcounting::build_header_help( env, @@ -659,7 +659,7 @@ fn build_hash_list<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_HASH; let fn_name = layout_ids - .get(symbol, &layout) + .get(symbol, layout) .to_symbol_string(symbol, &env.interns); let function = match env.module.get_function(fn_name.as_str()) { @@ -667,7 +667,7 @@ fn build_hash_list<'a, 'ctx, 'env>( None => { let seed_type = env.context.i64_type(); - let arg_type = basic_type_from_layout(env, &layout); + let arg_type = basic_type_from_layout(env, layout); let function_value = crate::llvm::refcounting::build_header_help( env, @@ -870,7 +870,7 @@ fn store_and_use_as_u8_ptr<'a, 'ctx, 'env>( value: BasicValueEnum<'ctx>, layout: &Layout<'a>, ) -> PointerValue<'ctx> { - let basic_type = basic_type_from_layout(env, &layout); + let basic_type = basic_type_from_layout(env, layout); let alloc = env.builder.build_alloca(basic_type, "store"); env.builder.build_store(alloc, value); @@ -895,7 +895,7 @@ fn hash_bitcode_fn<'a, 'ctx, 'env>( call_bitcode_fn( env, &[seed.into(), buffer.into(), num_bytes.into()], - &bitcode::DICT_HASH, + bitcode::DICT_HASH, ) .into_int_value() } diff --git a/compiler/gen_llvm/src/llvm/build_list.rs b/compiler/gen_llvm/src/llvm/build_list.rs index ab85e2cc29..8c9d28663a 100644 --- a/compiler/gen_llvm/src/llvm/build_list.rs +++ b/compiler/gen_llvm/src/llvm/build_list.rs @@ -94,7 +94,7 @@ pub fn list_single<'a, 'ctx, 'env>( pass_element_as_opaque(env, element), layout_width(env, element_layout), ], - &bitcode::LIST_SINGLE, + bitcode::LIST_SINGLE, ) } @@ -206,7 +206,7 @@ pub fn list_join<'a, 'ctx, 'env>( env.alignment_intvalue(element_layout), layout_width(env, element_layout), ], - &bitcode::LIST_JOIN, + bitcode::LIST_JOIN, ) } _ => { @@ -239,7 +239,7 @@ pub fn list_reverse<'a, 'ctx, 'env>( env.alignment_intvalue(&element_layout), layout_width(env, &element_layout), ], - &bitcode::LIST_REVERSE, + bitcode::LIST_REVERSE, ) } @@ -291,11 +291,11 @@ pub fn list_append<'a, 'ctx, 'env>( env, &[ pass_list_as_i128(env, original_wrapper.into()), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), pass_element_as_opaque(env, element), layout_width(env, element_layout), ], - &bitcode::LIST_APPEND, + bitcode::LIST_APPEND, ) } @@ -311,12 +311,12 @@ pub fn list_swap<'a, 'ctx, 'env>( env, &[ pass_list_as_i128(env, original_wrapper.into()), - env.alignment_intvalue(&element_layout), - layout_width(env, &element_layout), + env.alignment_intvalue(element_layout), + layout_width(env, element_layout), index_1.into(), index_2.into(), ], - &bitcode::LIST_SWAP, + bitcode::LIST_SWAP, ) } @@ -328,17 +328,17 @@ pub fn list_drop<'a, 'ctx, 'env>( count: IntValue<'ctx>, element_layout: &Layout<'a>, ) -> BasicValueEnum<'ctx> { - let dec_element_fn = build_dec_wrapper(env, layout_ids, &element_layout); + let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout); call_bitcode_fn_returns_list( env, &[ pass_list_as_i128(env, original_wrapper.into()), - env.alignment_intvalue(&element_layout), - layout_width(env, &element_layout), + env.alignment_intvalue(element_layout), + layout_width(env, element_layout), count.into(), dec_element_fn.as_global_value().as_pointer_value().into(), ], - &bitcode::LIST_DROP, + bitcode::LIST_DROP, ) } @@ -377,7 +377,7 @@ pub fn list_set<'a, 'ctx, 'env>( &[ bytes.into(), length.into(), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), index.into(), pass_element_as_opaque(env, element), layout_width(env, element_layout), @@ -456,7 +456,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>( roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), pass_as_opaque(env, default_ptr), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), layout_width(env, default_layout), pass_as_opaque(env, result_ptr), @@ -487,7 +487,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>( roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), pass_as_opaque(env, default_ptr), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), layout_width(env, function_call_return_layout), layout_width(env, default_layout), @@ -563,7 +563,7 @@ pub fn list_range<'a, 'ctx, 'env>( pass_as_opaque(env, low_ptr), pass_as_opaque(env, high_ptr), ], - &bitcode::LIST_RANGE, + bitcode::LIST_RANGE, ) } @@ -611,12 +611,12 @@ pub fn list_keep_if<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), inc_element_fn.as_global_value().as_pointer_value().into(), dec_element_fn.as_global_value().as_pointer_value().into(), ], - &bitcode::LIST_KEEP_IF, + bitcode::LIST_KEEP_IF, ) } @@ -653,7 +653,7 @@ pub fn list_keep_oks<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&before_layout), + env.alignment_intvalue(before_layout), layout_width(env, before_layout), layout_width(env, result_layout), layout_width(env, after_layout), @@ -697,7 +697,7 @@ pub fn list_keep_errs<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&before_layout), + env.alignment_intvalue(before_layout), layout_width(env, before_layout), layout_width(env, result_layout), layout_width(env, after_layout), @@ -724,7 +724,7 @@ pub fn list_sort_with<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), ], bitcode::LIST_SORT_WITH, @@ -747,7 +747,7 @@ pub fn list_map_with_index<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), layout_width(env, return_layout), ], @@ -771,7 +771,7 @@ pub fn list_map<'a, 'ctx, 'env>( pass_as_opaque(env, roc_function_call.data), roc_function_call.inc_n_data.into(), roc_function_call.data_is_owned.into(), - env.alignment_intvalue(&element_layout), + env.alignment_intvalue(element_layout), layout_width(env, element_layout), layout_width(env, return_layout), ], @@ -873,7 +873,7 @@ pub fn list_concat<'a, 'ctx, 'env>( env.alignment_intvalue(elem_layout), layout_width(env, elem_layout), ], - &bitcode::LIST_CONCAT, + bitcode::LIST_CONCAT, ), _ => { unreachable!("Invalid List layout for List.concat {:?}", list_layout); diff --git a/compiler/gen_llvm/src/llvm/build_str.rs b/compiler/gen_llvm/src/llvm/build_str.rs index ee8576ceb8..b7bc32def6 100644 --- a/compiler/gen_llvm/src/llvm/build_str.rs +++ b/compiler/gen_llvm/src/llvm/build_str.rs @@ -27,7 +27,7 @@ pub fn str_split<'a, 'ctx, 'env>( let segment_count = call_bitcode_fn( env, &[str_i128.into(), delim_i128.into()], - &bitcode::STR_COUNT_SEGMENTS, + bitcode::STR_COUNT_SEGMENTS, ) .into_int_value(); @@ -47,7 +47,7 @@ pub fn str_split<'a, 'ctx, 'env>( call_void_bitcode_fn( env, &[ret_list_ptr_zig_rocstr, str_i128.into(), delim_i128.into()], - &bitcode::STR_STR_SPLIT_IN_PLACE, + bitcode::STR_STR_SPLIT_IN_PLACE, ); store_list(env, ret_list_ptr, segment_count) @@ -62,7 +62,7 @@ fn str_symbol_to_i128<'a, 'ctx, 'env>( let i128_type = env.context.i128_type().into(); - complex_bitcast(&env.builder, string, i128_type, "str_to_i128").into_int_value() + complex_bitcast(env.builder, string, i128_type, "str_to_i128").into_int_value() } pub fn str_to_i128<'a, 'ctx, 'env>( @@ -119,7 +119,7 @@ pub fn str_concat<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str1_i128.into(), str2_i128.into()], - &bitcode::STR_CONCAT, + bitcode::STR_CONCAT, ) } @@ -138,7 +138,7 @@ pub fn str_join_with<'a, 'ctx, 'env>( call_bitcode_fn( env, &[list_i128.into(), str_i128.into()], - &bitcode::STR_JOIN_WITH, + bitcode::STR_JOIN_WITH, ) } @@ -151,7 +151,7 @@ pub fn str_number_of_bytes<'a, 'ctx, 'env>( // the builtin will always return an u64 let length = - call_bitcode_fn(env, &[str_i128.into()], &bitcode::STR_NUMBER_OF_BYTES).into_int_value(); + call_bitcode_fn(env, &[str_i128.into()], bitcode::STR_NUMBER_OF_BYTES).into_int_value(); // cast to the appropriate usize of the current build env.builder @@ -171,7 +171,7 @@ pub fn str_starts_with<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str_i128.into(), prefix_i128.into()], - &bitcode::STR_STARTS_WITH, + bitcode::STR_STARTS_WITH, ) } @@ -188,7 +188,7 @@ pub fn str_starts_with_code_point<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str_i128.into(), prefix], - &bitcode::STR_STARTS_WITH_CODE_POINT, + bitcode::STR_STARTS_WITH_CODE_POINT, ) } @@ -205,7 +205,7 @@ pub fn str_ends_with<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str_i128.into(), prefix_i128.into()], - &bitcode::STR_ENDS_WITH, + bitcode::STR_ENDS_WITH, ) } @@ -220,7 +220,7 @@ pub fn str_count_graphemes<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str_i128.into()], - &bitcode::STR_COUNT_GRAPEHEME_CLUSTERS, + bitcode::STR_COUNT_GRAPEHEME_CLUSTERS, ) } @@ -232,7 +232,7 @@ pub fn str_from_int<'a, 'ctx, 'env>( ) -> BasicValueEnum<'ctx> { let int = load_symbol(scope, &int_symbol); - call_bitcode_fn(env, &[int], &bitcode::STR_FROM_INT) + call_bitcode_fn(env, &[int], bitcode::STR_FROM_INT) } /// Str.toBytes : Str -> List U8 @@ -247,7 +247,7 @@ pub fn str_to_bytes<'a, 'ctx, 'env>( "to_bytes", ); - call_bitcode_fn_returns_list(env, &[string], &bitcode::STR_TO_BYTES) + call_bitcode_fn_returns_list(env, &[string], bitcode::STR_TO_BYTES) } /// Str.fromUtf8 : List U8 -> { a : Bool, b : Str, c : Nat, d : I8 } @@ -273,7 +273,7 @@ pub fn str_from_utf8<'a, 'ctx, 'env>( ), result_ptr.into(), ], - &bitcode::STR_FROM_UTF8, + bitcode::STR_FROM_UTF8, ); let record_type = env.context.struct_type( @@ -306,7 +306,7 @@ pub fn str_from_float<'a, 'ctx, 'env>( ) -> BasicValueEnum<'ctx> { let float = load_symbol(scope, &int_symbol); - call_bitcode_fn(env, &[float], &bitcode::STR_FROM_FLOAT) + call_bitcode_fn(env, &[float], bitcode::STR_FROM_FLOAT) } /// Str.equal : Str, Str -> Bool @@ -321,7 +321,7 @@ pub fn str_equal<'a, 'ctx, 'env>( call_bitcode_fn( env, &[str1_i128.into(), str2_i128.into()], - &bitcode::STR_EQUAL, + bitcode::STR_EQUAL, ) } diff --git a/compiler/gen_llvm/src/llvm/compare.rs b/compiler/gen_llvm/src/llvm/compare.rs index 4810e44063..4d0a70763c 100644 --- a/compiler/gen_llvm/src/llvm/compare.rs +++ b/compiler/gen_llvm/src/llvm/compare.rs @@ -99,7 +99,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>( Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"), - Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_EQ), + Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_EQ), Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"), Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"), Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"), @@ -245,7 +245,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>( Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"), - Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_NEQ), + Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_NEQ), Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"), Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"), Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"), @@ -361,13 +361,13 @@ fn build_list_eq<'a, 'ctx, 'env>( let symbol = Symbol::LIST_EQ; let fn_name = layout_ids - .get(symbol, &element_layout) + .get(symbol, element_layout) .to_symbol_string(symbol, &env.interns); let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let arg_type = basic_type_from_layout(env, &list_layout); + let arg_type = basic_type_from_layout(env, list_layout); let function_value = crate::llvm::refcounting::build_header_help( env, @@ -428,7 +428,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>( /* current_scope */ lexical_block.as_debug_info_scope(), /* inlined_at */ None, ); - builder.set_current_debug_location(&ctx, loc); + builder.set_current_debug_location(ctx, loc); } // Add args to scope @@ -636,7 +636,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>( /* current_scope */ lexical_block.as_debug_info_scope(), /* inlined_at */ None, ); - builder.set_current_debug_location(&ctx, loc); + builder.set_current_debug_location(ctx, loc); } // Add args to scope @@ -752,13 +752,13 @@ fn build_tag_eq<'a, 'ctx, 'env>( let symbol = Symbol::GENERIC_EQ; let fn_name = layout_ids - .get(symbol, &tag_layout) + .get(symbol, tag_layout) .to_symbol_string(symbol, &env.interns); let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let arg_type = basic_type_from_layout(env, &tag_layout); + let arg_type = basic_type_from_layout(env, tag_layout); let function_value = crate::llvm::refcounting::build_header_help( env, @@ -817,7 +817,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>( /* current_scope */ lexical_block.as_debug_info_scope(), /* inlined_at */ None, ); - builder.set_current_debug_location(&ctx, loc); + builder.set_current_debug_location(ctx, loc); } // Add args to scope diff --git a/compiler/gen_llvm/src/llvm/convert.rs b/compiler/gen_llvm/src/llvm/convert.rs index 34a55dd2db..3ec1f749f8 100644 --- a/compiler/gen_llvm/src/llvm/convert.rs +++ b/compiler/gen_llvm/src/llvm/convert.rs @@ -59,7 +59,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>( } NullableUnwrapped { other_fields, .. } => { let block = - block_of_memory_slices(env.context, &[&other_fields], env.ptr_bytes); + block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes); block.ptr_type(AddressSpace::Generic).into() } NonNullableUnwrapped(fields) => { diff --git a/compiler/gen_llvm/src/llvm/refcounting.rs b/compiler/gen_llvm/src/llvm/refcounting.rs index 9c09469a97..e474dd8651 100644 --- a/compiler/gen_llvm/src/llvm/refcounting.rs +++ b/compiler/gen_llvm/src/llvm/refcounting.rs @@ -720,14 +720,14 @@ fn modify_refcount_list<'a, 'ctx, 'env>( &env.interns, "increment_list", "decrement_list", - &layout, + layout, mode, ); let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let basic_type = basic_type_from_layout(env, &layout); + let basic_type = basic_type_from_layout(env, layout); let function_value = build_header(env, basic_type, mode, &fn_name); modify_refcount_list_help( @@ -857,14 +857,14 @@ fn modify_refcount_str<'a, 'ctx, 'env>( &env.interns, "increment_str", "decrement_str", - &layout, + layout, mode, ); let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let basic_type = basic_type_from_layout(env, &layout); + let basic_type = basic_type_from_layout(env, layout); let function_value = build_header(env, basic_type, mode, &fn_name); modify_refcount_str_help(env, mode, layout, function_value); @@ -956,14 +956,14 @@ fn modify_refcount_dict<'a, 'ctx, 'env>( &env.interns, "increment_dict", "decrement_dict", - &layout, + layout, mode, ); let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let basic_type = basic_type_from_layout(env, &layout); + let basic_type = basic_type_from_layout(env, layout); let function_value = build_header(env, basic_type, mode, &fn_name); modify_refcount_dict_help( @@ -1118,7 +1118,7 @@ pub fn build_header_help<'a, 'ctx, 'env>( FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention. ); - let subprogram = env.new_subprogram(&fn_name); + let subprogram = env.new_subprogram(fn_name); fn_val.set_subprogram(subprogram); env.dibuilder.finalize(); diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index fd8fd1dc4b..8bdc2105c5 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -225,7 +225,7 @@ impl<'a> Dependencies<'a> { if let Some(to_notify) = self.notifies.get(&key) { for notify_key in to_notify { let mut is_empty = false; - if let Some(waiting_for_pairs) = self.waiting_for.get_mut(¬ify_key) { + if let Some(waiting_for_pairs) = self.waiting_for.get_mut(notify_key) { waiting_for_pairs.remove(&key); is_empty = waiting_for_pairs.is_empty(); } @@ -469,7 +469,7 @@ fn start_phase<'a>( for dep_id in deps_by_name.values() { // We already verified that these are all present, // so unwrapping should always succeed here. - let idents = ident_ids_by_module.get(&dep_id).unwrap(); + let idents = ident_ids_by_module.get(dep_id).unwrap(); dep_idents.insert(*dep_id, idents.clone()); } @@ -535,7 +535,7 @@ fn start_phase<'a>( var_store, imported_modules, &mut state.exposed_types, - &state.stdlib, + state.stdlib, declarations, ) } @@ -1635,7 +1635,7 @@ fn start_tasks<'a>( ) -> Result<(), LoadingProblem<'a>> { for (module_id, phase) in work { for task in start_phase(module_id, phase, arena, state) { - enqueue_task(&injector, worker_listeners, task)? + enqueue_task(injector, worker_listeners, task)? } } @@ -1759,11 +1759,11 @@ fn update<'a>( state.module_cache.headers.insert(header.module_id, header); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; let work = state.dependencies.notify(home, Phase::LoadHeader); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; Ok(state) } @@ -1796,7 +1796,7 @@ fn update<'a>( let work = state.dependencies.notify(module_id, Phase::Parse); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; Ok(state) } @@ -1831,7 +1831,7 @@ fn update<'a>( .dependencies .notify(module_id, Phase::CanonicalizeAndConstrain); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; Ok(state) } @@ -1882,7 +1882,7 @@ fn update<'a>( .notify(module_id, Phase::CanonicalizeAndConstrain), ); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; Ok(state) } @@ -1986,7 +1986,7 @@ fn update<'a>( state.constrained_ident_ids.insert(module_id, ident_ids); } - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; } Ok(state) @@ -2041,7 +2041,7 @@ fn update<'a>( .dependencies .notify(module_id, Phase::FindSpecializations); - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; Ok(state) } @@ -2143,7 +2143,7 @@ fn update<'a>( existing.extend(requested); } - start_tasks(arena, &mut state, work, &injector, worker_listeners)?; + start_tasks(arena, &mut state, work, injector, worker_listeners)?; } Ok(state) @@ -2348,7 +2348,7 @@ fn load_pkg_config<'a>( let parse_start = SystemTime::now(); let bytes = arena.alloc(bytes_vec); let parse_state = parser::State::new(bytes); - let parsed = roc_parse::module::parse_header(&arena, parse_state); + let parsed = roc_parse::module::parse_header(arena, parse_state); let parse_header_duration = parse_start.elapsed().unwrap(); // Insert the first entries for this module's timings @@ -2518,7 +2518,7 @@ fn parse_header<'a>( ) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> { let parse_start = SystemTime::now(); let parse_state = parser::State::new(src_bytes); - let parsed = roc_parse::module::parse_header(&arena, parse_state); + let parsed = roc_parse::module::parse_header(arena, parse_state); let parse_header_duration = parse_start.elapsed().unwrap(); // Insert the first entries for this module's timings @@ -2667,7 +2667,7 @@ fn parse_header<'a>( } Ok((ast::Module::Platform { header }, _parse_state)) => Ok(fabricate_effects_module( arena, - &"", + "", module_ids, ident_ids_by_module, header, @@ -2825,7 +2825,7 @@ fn send_header<'a>( let name = match opt_shorthand { Some(shorthand) => { - PQModuleName::Qualified(&shorthand, declared_name.as_inline_str().clone()) + PQModuleName::Qualified(shorthand, declared_name.as_inline_str().clone()) } None => PQModuleName::Unqualified(declared_name.as_inline_str().clone()), }; @@ -2901,13 +2901,13 @@ fn send_header<'a>( } if cfg!(debug_assertions) { - home.register_debug_idents(&ident_ids); + home.register_debug_idents(ident_ids); } ident_ids.clone() }; - let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect(); + let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect(); let mut package_entries = MutMap::default(); while let Some(parse_entry) = parse_entries.pop() { @@ -3053,7 +3053,7 @@ fn send_header_two<'a>( let mut module_ids = (*module_ids).lock(); let mut ident_ids_by_module = (*ident_ids_by_module).lock(); - let name = PQModuleName::Qualified(&shorthand, declared_name); + let name = PQModuleName::Qualified(shorthand, declared_name); home = module_ids.get_or_insert(&name); // Ensure this module has an entry in the exposed_ident_ids map. @@ -3138,13 +3138,13 @@ fn send_header_two<'a>( } if cfg!(debug_assertions) { - home.register_debug_idents(&ident_ids); + home.register_debug_idents(ident_ids); } ident_ids.clone() }; - let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect(); + let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect(); let mut package_entries = MutMap::default(); while let Some(parse_entry) = parse_entries.pop() { @@ -3390,7 +3390,7 @@ fn fabricate_effects_module<'a>( let module_id: ModuleId; - let effect_entries = unpack_exposes_entries(arena, &effects.entries); + let effect_entries = unpack_exposes_entries(arena, effects.entries); let name = effects.effect_type_name; let declared_name: ModuleName = name.into(); @@ -3464,7 +3464,7 @@ fn fabricate_effects_module<'a>( } if cfg!(debug_assertions) { - module_id.register_debug_idents(&ident_ids); + module_id.register_debug_idents(ident_ids); } ident_ids.clone() @@ -3685,7 +3685,7 @@ where let mut var_store = VarStore::default(); let canonicalized = canonicalize_module_defs( - &arena, + arena, parsed_defs, module_id, module_ids, @@ -3712,7 +3712,7 @@ where module_output.scope, name.as_str().into(), &module_output.ident_ids, - &parsed_defs, + parsed_defs, )), }; @@ -3761,7 +3761,7 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result, Loadi let parse_start = SystemTime::now(); let source = header.parse_state.bytes; let parse_state = header.parse_state; - let parsed_defs = match module_defs().parse(&arena, parse_state) { + let parsed_defs = match module_defs().parse(arena, parse_state) { Ok((_, success, _state)) => success, Err((_, fail, _)) => { return Err(LoadingProblem::ParsingFailed(fail.into_parse_problem( diff --git a/compiler/load/tests/test_load.rs b/compiler/load/tests/test_load.rs index fe2c1caf7e..6716acda0c 100644 --- a/compiler/load/tests/test_load.rs +++ b/compiler/load/tests/test_load.rs @@ -188,8 +188,8 @@ mod test_load { name_all_type_vars(*expr_var, subs); - let actual_str = content_to_string(content, subs, home, &interns); - let fully_qualified = symbol.fully_qualified(&interns, home).to_string(); + let actual_str = content_to_string(content, subs, home, interns); + let fully_qualified = symbol.fully_qualified(interns, home).to_string(); let expected_type = expected_types .remove(fully_qualified.as_str()) .unwrap_or_else(|| { diff --git a/compiler/module/src/symbol.rs b/compiler/module/src/symbol.rs index b8291d2a6f..187bc2a734 100644 --- a/compiler/module/src/symbol.rs +++ b/compiler/module/src/symbol.rs @@ -368,7 +368,7 @@ impl<'a> PackageModuleIds<'a> { self.by_name.insert(module_name.clone(), module_id); if cfg!(debug_assertions) { - Self::insert_debug_name(module_id, &module_name); + Self::insert_debug_name(module_id, module_name); } module_id @@ -449,7 +449,7 @@ impl ModuleIds { self.by_name.insert(module_name.clone(), module_id); if cfg!(debug_assertions) { - Self::insert_debug_name(module_id, &module_name); + Self::insert_debug_name(module_id, module_name); } module_id diff --git a/compiler/mono/src/alias_analysis.rs b/compiler/mono/src/alias_analysis.rs index efe7c01712..878cf7e3e2 100644 --- a/compiler/mono/src/alias_analysis.rs +++ b/compiler/mono/src/alias_analysis.rs @@ -1108,7 +1108,7 @@ fn expr_spec<'a>( let index = (*index) as u32; let tag_value_id = env.symbols[structure]; - let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes(); + let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes(); let type_name = TypeName(&type_name_bytes); let union_id = builder.add_unwrap_named(block, MOD_APP, type_name, tag_value_id)?; @@ -1128,7 +1128,7 @@ fn expr_spec<'a>( let tag_value_id = env.symbols[structure]; - let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes(); + let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes(); let type_name = TypeName(&type_name_bytes); let variant_id = @@ -1234,7 +1234,7 @@ fn layout_spec_help( | UnionLayout::NullableUnwrapped { .. } | UnionLayout::NullableWrapped { .. } | UnionLayout::NonNullableUnwrapped(_) => { - let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes(); + let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes(); let type_name = TypeName(&type_name_bytes); Ok(builder.add_named_type(MOD_APP, type_name)) diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index cb4c0f1c6f..d847d8c7dd 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -924,7 +924,7 @@ fn pick_path<'a>(branches: &'a [Branch]) -> &'a Vec { for (path, pattern) in &branch.patterns { // NOTE we no longer check for the guard here // if !branch.guard.is_none() || needs_tests(&pattern) { - if needs_tests(&pattern) { + if needs_tests(pattern) { all_paths.push(path); } else { // do nothing @@ -996,7 +996,7 @@ where let mut min_paths = vec![first_path]; for path in all_paths { - let weight = small_defaults(branches, &path); + let weight = small_defaults(branches, path); use std::cmp::Ordering; match weight.cmp(&min_weight) { @@ -1219,7 +1219,7 @@ fn test_to_equality<'a>( test: Test<'a>, ) -> (StoresVec<'a>, Symbol, Symbol, Option>) { let (rhs_symbol, mut stores, test_layout) = - path_to_expr_help(env, cond_symbol, &path, *cond_layout); + path_to_expr_help(env, cond_symbol, path, *cond_layout); match test { Test::IsCtor { tag_id, union, .. } => { @@ -1328,7 +1328,7 @@ fn stores_and_condition<'a>( tests.push(test_to_equality( env, cond_symbol, - &cond_layout, + cond_layout, &path, test, )) @@ -1540,7 +1540,7 @@ fn decide_to_branching<'a>( match decider { Leaf(Jump(label)) => { let index = jumps - .binary_search_by_key(&label, |ref r| r.0) + .binary_search_by_key(&label, |r| r.0) .expect("jump not in list of jumps"); Stmt::Jump(jumps[index].1, &[]) diff --git a/compiler/mono/src/expand_rc.rs b/compiler/mono/src/expand_rc.rs index 01ee612edd..55a2faa258 100644 --- a/compiler/mono/src/expand_rc.rs +++ b/compiler/mono/src/expand_rc.rs @@ -187,7 +187,7 @@ impl<'a, 'i> Env<'a, 'i> { pub fn unique_symbol(&mut self) -> Symbol { let ident_id = self.ident_ids.gen_unique(); - self.home.register_debug_idents(&self.ident_ids); + self.home.register_debug_idents(self.ident_ids); Symbol::new(self.home, ident_id) } @@ -195,7 +195,7 @@ impl<'a, 'i> Env<'a, 'i> { fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol { let ident_id = ident_ids.gen_unique(); - home.register_debug_idents(&ident_ids); + home.register_debug_idents(ident_ids); Symbol::new(home, ident_id) } diff --git a/compiler/mono/src/inc_dec.rs b/compiler/mono/src/inc_dec.rs index 622946c0f4..5da365c516 100644 --- a/compiler/mono/src/inc_dec.rs +++ b/compiler/mono/src/inc_dec.rs @@ -740,7 +740,7 @@ impl<'a> Context<'a> { ) -> (&'a Stmt<'a>, LiveVarSet) { use Expr::*; - let mut live_vars = update_live_vars(&v, &b_live_vars); + let mut live_vars = update_live_vars(&v, b_live_vars); live_vars.remove(&z); let new_b = match v { @@ -750,7 +750,7 @@ impl<'a> Context<'a> { | Array { elems: ys, .. } => self.add_inc_before_consume_all( ys, self.arena.alloc(Stmt::Let(z, v, l, b)), - &b_live_vars, + b_live_vars, ), Call(crate::ir::Call { diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 1296aa3030..dbc5655942 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -809,7 +809,7 @@ impl<'a, 'i> Env<'a, 'i> { pub fn unique_symbol(&mut self) -> Symbol { let ident_id = self.ident_ids.gen_unique(); - self.home.register_debug_idents(&self.ident_ids); + self.home.register_debug_idents(self.ident_ids); Symbol::new(self.home, ident_id) } @@ -2468,7 +2468,7 @@ fn specialize_solved_type<'a>( // for debugging only let attempted_layout = layout_cache - .from_var(&env.arena, fn_var, env.subs) + .from_var(env.arena, fn_var, env.subs) .unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err)); let raw = match attempted_layout { @@ -2509,7 +2509,7 @@ fn specialize_solved_type<'a>( debug_assert_eq!( attempted_layout, layout_cache - .from_var(&env.arena, fn_var, env.subs) + .from_var(env.arena, fn_var, env.subs) .unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err)) ); @@ -3855,7 +3855,7 @@ pub fn with_hole<'a>( let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena); for (_, arg_expr) in args.iter() { - arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr)); + arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr)); } let arg_symbols = arg_symbols.into_bump_slice(); @@ -3885,7 +3885,7 @@ pub fn with_hole<'a>( let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena); for (_, arg_expr) in args.iter() { - arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr)); + arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr)); } let arg_symbols = arg_symbols.into_bump_slice(); @@ -5540,7 +5540,7 @@ fn store_pattern_help<'a>( layout_cache, outer_symbol, &layout, - &arguments, + arguments, stmt, ); } @@ -5557,7 +5557,7 @@ fn store_pattern_help<'a>( layout_cache, outer_symbol, *layout, - &arguments, + arguments, *tag_id, stmt, ); @@ -6374,7 +6374,7 @@ fn call_by_name_help<'a>( // the variables of the given arguments let mut pattern_vars = Vec::with_capacity_in(loc_args.len(), arena); for (var, _) in &loc_args { - match layout_cache.from_var(&env.arena, *var, &env.subs) { + match layout_cache.from_var(env.arena, *var, env.subs) { Ok(_) => { pattern_vars.push(*var); } diff --git a/compiler/mono/src/layout.rs b/compiler/mono/src/layout.rs index 720a80dc31..d4d99087f1 100644 --- a/compiler/mono/src/layout.rs +++ b/compiler/mono/src/layout.rs @@ -1317,7 +1317,7 @@ fn layout_from_flat_type<'a>( } } else if tag_layouts.len() == 1 { // drop the tag id - UnionLayout::NonNullableUnwrapped(&tag_layouts.pop().unwrap()) + UnionLayout::NonNullableUnwrapped(tag_layouts.pop().unwrap()) } else { UnionLayout::Recursive(tag_layouts.into_bump_slice()) }; @@ -2114,7 +2114,7 @@ impl<'a> LayoutIds<'a> { }); // Get the id associated with this layout, or default to next_id. - let answer = ids.by_id.get(&layout).copied().unwrap_or(ids.next_id); + let answer = ids.by_id.get(layout).copied().unwrap_or(ids.next_id); // If we had to default to next_id, it must not have been found; // store the ID we're going to return and increment next_id. @@ -2145,7 +2145,7 @@ impl<'a> LayoutIds<'a> { // Get the id associated with this layout, or default to next_id. let answer = ids .toplevels_by_id - .get(&layout) + .get(layout) .copied() .unwrap_or(ids.next_id); diff --git a/compiler/mono/src/reset_reuse.rs b/compiler/mono/src/reset_reuse.rs index cb3db23427..10bbd05939 100644 --- a/compiler/mono/src/reset_reuse.rs +++ b/compiler/mono/src/reset_reuse.rs @@ -58,7 +58,7 @@ impl<'a, 'i> Env<'a, 'i> { fn unique_symbol(&mut self) -> Symbol { let ident_id = self.ident_ids.gen_unique(); - self.home.register_debug_idents(&self.ident_ids); + self.home.register_debug_idents(self.ident_ids); Symbol::new(self.home, ident_id) } diff --git a/compiler/parse/src/expr.rs b/compiler/parse/src/expr.rs index 5f8f972d43..81cc0f33cc 100644 --- a/compiler/parse/src/expr.rs +++ b/compiler/parse/src/expr.rs @@ -252,7 +252,7 @@ fn underscore_expression<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> { match output { Some(name) => Ok((MadeProgress, Expr::Underscore(name), final_state)), - None => Ok((MadeProgress, Expr::Underscore(&""), final_state)), + None => Ok((MadeProgress, Expr::Underscore(""), final_state)), } } } diff --git a/compiler/parse/src/number_literal.rs b/compiler/parse/src/number_literal.rs index 2c1796a0b8..2386f7803a 100644 --- a/compiler/parse/src/number_literal.rs +++ b/compiler/parse/src/number_literal.rs @@ -15,7 +15,7 @@ pub fn positive_number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number> move |_arena, state: State<'a>| { match state.bytes.get(0) { Some(first_byte) if (*first_byte as char).is_ascii_digit() => { - parse_number_base(false, &state.bytes, state) + parse_number_base(false, state.bytes, state) } _ => { // this is not a number at all @@ -33,7 +33,7 @@ pub fn number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number> { parse_number_base(true, &state.bytes[1..], state) } Some(first_byte) if (*first_byte as char).is_ascii_digit() => { - parse_number_base(false, &state.bytes, state) + parse_number_base(false, state.bytes, state) } _ => { // this is not a number at all diff --git a/compiler/parse/src/pattern.rs b/compiler/parse/src/pattern.rs index 1ae58f38a1..b4a2f9b406 100644 --- a/compiler/parse/src/pattern.rs +++ b/compiler/parse/src/pattern.rs @@ -259,7 +259,7 @@ fn loc_ident_pattern_help<'a>( Located { region: loc_ident.region, value: Pattern::Malformed( - String::from_str_in(&malformed_str, &arena).into_bump_str(), + String::from_str_in(&malformed_str, arena).into_bump_str(), ), }, state, @@ -299,7 +299,7 @@ fn underscore_pattern_help<'a>() -> impl Parser<'a, Pattern<'a>, EPattern<'a>> { match output { Some(name) => Ok((MadeProgress, Pattern::Underscore(name), final_state)), - None => Ok((MadeProgress, Pattern::Underscore(&""), final_state)), + None => Ok((MadeProgress, Pattern::Underscore(""), final_state)), } } } diff --git a/compiler/parse/src/type_annotation.rs b/compiler/parse/src/type_annotation.rs index 6b1f718552..ac95ca185e 100644 --- a/compiler/parse/src/type_annotation.rs +++ b/compiler/parse/src/type_annotation.rs @@ -303,12 +303,12 @@ fn applied_type<'a>(min_indent: u16) -> impl Parser<'a, TypeAnnotation<'a>, Type ), |(ctor, args): (TypeAnnotation<'a>, Vec<'a, Located>>)| { match &ctor { - TypeAnnotation::Apply(ref module_name, ref name, _) => { + TypeAnnotation::Apply(module_name, name, _) => { if args.is_empty() { // ctor is already an Apply with no args, so return it directly. ctor } else { - TypeAnnotation::Apply(*module_name, *name, args.into_bump_slice()) + TypeAnnotation::Apply(module_name, name, args.into_bump_slice()) } } TypeAnnotation::Malformed(_) => ctor, @@ -371,7 +371,7 @@ fn expression<'a>(min_indent: u16) -> impl Parser<'a, Located .parse(arena, state)?; // prepare arguments - let mut arguments = Vec::with_capacity_in(rest.len() + 1, &arena); + let mut arguments = Vec::with_capacity_in(rest.len() + 1, arena); arguments.push(first); arguments.extend(rest); let output = arena.alloc(arguments); diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index 58ca1d2dee..03b1a0273b 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -1609,7 +1609,7 @@ mod test_parse { #[test] fn single_underscore_closure() { let arena = Bump::new(); - let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore(&"")); + let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore("")); let patterns = &[pattern]; let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42")))); let actual = parse_expr_with(&arena, "\\_ -> 42"); @@ -1629,7 +1629,7 @@ mod test_parse { 0, 1, 11, - Pattern::MalformedIdent(&"the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)), + Pattern::MalformedIdent("the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)), ); let patterns = &[pattern]; let expr = Located::new(0, 0, 15, 17, Expr::Num("42")); @@ -1671,8 +1671,8 @@ mod test_parse { #[test] fn closure_with_underscores() { let arena = Bump::new(); - let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore(&"")); - let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore(&"name")); + let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore("")); + let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore("name")); let patterns = bumpalo::vec![in &arena; underscore1, underscore2]; let expected = Closure( arena.alloc(patterns), @@ -1906,7 +1906,7 @@ mod test_parse { fn underscore_backpassing() { let arena = Bump::new(); let newlines = bumpalo::vec![in &arena; Newline, Newline]; - let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore(&"")); + let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore("")); let identifier_y = Located::new(1, 1, 7, 8, Identifier("y")); let num_4 = Num("4"); @@ -3531,7 +3531,7 @@ mod test_parse { match parsed { Ok((_, _, _state)) => { // dbg!(_state); - return; + } Err((_, _fail, _state)) => { // dbg!(_fail, _state); @@ -3707,7 +3707,7 @@ mod test_parse { guard: None, }); let newlines = &[Newline]; - let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines); + let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines); let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2); let expr2 = Num("4"); let loc_expr2 = Located::new(2, 2, 9, 10, expr2); @@ -3752,7 +3752,7 @@ mod test_parse { guard: None, }); let newlines = &[Newline]; - let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines); + let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines); let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2); let expr2 = Num("4"); let loc_expr2 = Located::new(2, 2, 9, 10, expr2); diff --git a/compiler/reporting/src/error/parse.rs b/compiler/reporting/src/error/parse.rs index bf9da32395..ea62283fa8 100644 --- a/compiler/reporting/src/error/parse.rs +++ b/compiler/reporting/src/error/parse.rs @@ -159,17 +159,17 @@ fn to_syntax_report<'a>( title: "PARSE PROBLEM".to_string(), } } - Type(typ) => to_type_report(alloc, filename, &typ, 0, 0), - Pattern(pat) => to_pattern_report(alloc, filename, &pat, 0, 0), + Type(typ) => to_type_report(alloc, filename, typ, 0, 0), + Pattern(pat) => to_pattern_report(alloc, filename, pat, 0, 0), Expr(expr) => to_expr_report( alloc, filename, Context::InDef(start_row, start_col), - &expr, + expr, 0, 0, ), - Header(header) => to_header_report(alloc, filename, &header, 0, 0), + Header(header) => to_header_report(alloc, filename, header, 0, 0), _ => todo!("unhandled parse error: {:?}", parse_problem), } } @@ -205,19 +205,19 @@ fn to_expr_report<'a>( use roc_parse::parser::EExpr; match parse_problem { - EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, &if_, *row, *col), - EExpr::When(when, row, col) => to_when_report(alloc, filename, context, &when, *row, *col), + EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, if_, *row, *col), + EExpr::When(when, row, col) => to_when_report(alloc, filename, context, when, *row, *col), EExpr::Lambda(lambda, row, col) => { - to_lambda_report(alloc, filename, context, &lambda, *row, *col) + to_lambda_report(alloc, filename, context, lambda, *row, *col) } - EExpr::List(list, row, col) => to_list_report(alloc, filename, context, &list, *row, *col), + EExpr::List(list, row, col) => to_list_report(alloc, filename, context, list, *row, *col), EExpr::Str(string, row, col) => { - to_str_report(alloc, filename, context, &string, *row, *col) + to_str_report(alloc, filename, context, string, *row, *col) } EExpr::InParens(expr, row, col) => { - to_expr_in_parens_report(alloc, filename, context, &expr, *row, *col) + to_expr_in_parens_report(alloc, filename, context, expr, *row, *col) } - EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, &tipe, *row, *col), + EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, tipe, *row, *col), EExpr::ElmStyleFunction(region, row, col) => { let surroundings = Region::from_rows_cols(start_row, start_col, *row, *col); let region = *region; @@ -529,7 +529,7 @@ fn to_expr_report<'a>( } } - EExpr::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col), + EExpr::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col), _ => todo!("unhandled parse error: {:?}", parse_problem), } @@ -1557,10 +1557,10 @@ fn to_pattern_report<'a>( } } EPattern::Record(record, row, col) => { - to_precord_report(alloc, filename, &record, *row, *col) + to_precord_report(alloc, filename, record, *row, *col) } EPattern::PInParens(inparens, row, col) => { - to_pattern_in_parens_report(alloc, filename, &inparens, *row, *col) + to_pattern_in_parens_report(alloc, filename, inparens, *row, *col) } _ => todo!("unhandled parse error: {:?}", parse_problem), } @@ -1958,14 +1958,14 @@ fn to_type_report<'a>( use roc_parse::parser::Type; match parse_problem { - Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, &record, *row, *col), + Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, record, *row, *col), Type::TTagUnion(tag_union, row, col) => { - to_ttag_union_report(alloc, filename, &tag_union, *row, *col) + to_ttag_union_report(alloc, filename, tag_union, *row, *col) } Type::TInParens(tinparens, row, col) => { - to_tinparens_report(alloc, filename, &tinparens, *row, *col) + to_tinparens_report(alloc, filename, tinparens, *row, *col) } - Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, &tapply, *row, *col), + Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, tapply, *row, *col), Type::TFunctionArgument(row, col) => match what_is_next(alloc.src_lines, *row, *col) { Next::Other(Some(',')) => { @@ -2856,27 +2856,27 @@ fn to_header_report<'a>( match parse_problem { EHeader::Provides(provides, row, col) => { - to_provides_report(alloc, filename, &provides, *row, *col) + to_provides_report(alloc, filename, provides, *row, *col) } EHeader::Exposes(exposes, row, col) => { - to_exposes_report(alloc, filename, &exposes, *row, *col) + to_exposes_report(alloc, filename, exposes, *row, *col) } EHeader::Imports(imports, row, col) => { - to_imports_report(alloc, filename, &imports, *row, *col) + to_imports_report(alloc, filename, imports, *row, *col) } EHeader::Requires(requires, row, col) => { - to_requires_report(alloc, filename, &requires, *row, *col) + to_requires_report(alloc, filename, requires, *row, *col) } EHeader::Packages(packages, row, col) => { - to_packages_report(alloc, filename, &packages, *row, *col) + to_packages_report(alloc, filename, packages, *row, *col) } EHeader::Effects(effects, row, col) => { - to_effects_report(alloc, filename, &effects, *row, *col) + to_effects_report(alloc, filename, effects, *row, *col) } EHeader::IndentStart(row, col) => { @@ -2988,7 +2988,7 @@ fn to_header_report<'a>( } } - EHeader::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col), + EHeader::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col), } } diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index f4f3723257..e5c6763279 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -214,7 +214,7 @@ fn report_bad_type<'b>( alloc, found, expected_type, - add_category(alloc, this_is, &category), + add_category(alloc, this_is, category), further_details, ), ]; @@ -1443,7 +1443,7 @@ pub fn to_doc<'b>( Record(fields_map, ext) => { let mut fields = fields_map.into_iter().collect::>(); - fields.sort_by(|(a, _), (b, _)| a.cmp(&b)); + fields.sort_by(|(a, _), (b, _)| a.cmp(b)); report_text::record( alloc, @@ -1482,7 +1482,7 @@ pub fn to_doc<'b>( ) }) .collect::>(); - tags.sort_by(|(a, _), (b, _)| a.cmp(&b)); + tags.sort_by(|(a, _), (b, _)| a.cmp(b)); report_text::tag_union( alloc, @@ -1505,7 +1505,7 @@ pub fn to_doc<'b>( ) }) .collect::>(); - tags.sort_by(|(a, _), (b, _)| a.cmp(&b)); + tags.sort_by(|(a, _), (b, _)| a.cmp(b)); report_text::recursive_tag_union( alloc, diff --git a/compiler/reporting/src/report.rs b/compiler/reporting/src/report.rs index a96480fa78..672f1d332f 100644 --- a/compiler/reporting/src/report.rs +++ b/compiler/reporting/src/report.rs @@ -70,7 +70,7 @@ impl<'b> Report<'b> { pub fn render_ci(self, buf: &'b mut String, alloc: &'b RocDocAllocator<'b>) { let err_msg = ""; - self.pretty(&alloc) + self.pretty(alloc) .1 .render_raw(70, &mut CiWrite::new(buf)) .expect(err_msg); @@ -85,7 +85,7 @@ impl<'b> Report<'b> { ) { let err_msg = ""; - self.pretty(&alloc) + self.pretty(alloc) .1 .render_raw(70, &mut ColorWrite::new(palette, buf)) .expect(err_msg); diff --git a/compiler/reporting/tests/helpers/mod.rs b/compiler/reporting/tests/helpers/mod.rs index 3cade3ded1..c301471f9f 100644 --- a/compiler/reporting/tests/helpers/mod.rs +++ b/compiler/reporting/tests/helpers/mod.rs @@ -110,7 +110,7 @@ pub fn can_expr_with<'a>( home: ModuleId, expr_str: &'a str, ) -> Result> { - let loc_expr = match roc_parse::test_helpers::parse_loc_with(&arena, expr_str) { + let loc_expr = match roc_parse::test_helpers::parse_loc_with(arena, expr_str) { Ok(e) => e, Err(fail) => { let interns = Interns::default(); diff --git a/compiler/reporting/tests/test_reporting.rs b/compiler/reporting/tests/test_reporting.rs index 7dfa302a34..b645a5c55e 100644 --- a/compiler/reporting/tests/test_reporting.rs +++ b/compiler/reporting/tests/test_reporting.rs @@ -65,7 +65,7 @@ mod test_reporting { problems: can_problems, .. } = can_expr(arena, expr_src)?; - let mut subs = Subs::new(var_store.into()); + let mut subs = Subs::new(var_store); for (var, name) in output.introduced_variables.name_by_var { subs.rigid_var(var, name); @@ -223,11 +223,9 @@ mod test_reporting { list_reports(&arena, src, &mut buf, callback); // convenient to copy-paste the generated message - if true { - if buf != expected_rendering { - for line in buf.split("\n") { - println!(" {}", line); - } + if true && buf != expected_rendering { + for line in buf.split('\n') { + println!(" {}", line); } } @@ -247,11 +245,9 @@ mod test_reporting { list_header_reports(&arena, src, &mut buf, callback); // convenient to copy-paste the generated message - if true { - if buf != expected_rendering { - for line in buf.split("\n") { - println!(" {}", line); - } + if true && buf != expected_rendering { + for line in buf.split('\n') { + println!(" {}", line); } } diff --git a/compiler/solve/src/module.rs b/compiler/solve/src/module.rs index f921b20709..525818e554 100644 --- a/compiler/solve/src/module.rs +++ b/compiler/solve/src/module.rs @@ -56,10 +56,10 @@ pub fn make_solved_types( for loc_named_var in alias.type_variables.iter() { let (name, var) = &loc_named_var.value; - args.push((name.clone(), SolvedType::new(&solved_subs, *var))); + args.push((name.clone(), SolvedType::new(solved_subs, *var))); } - let solved_type = SolvedType::from_type(&solved_subs, &alias.typ); + let solved_type = SolvedType::from_type(solved_subs, &alias.typ); let solved_alias = SolvedType::Alias(*symbol, args, Box::new(solved_type)); solved_types.insert(*symbol, solved_alias); @@ -71,7 +71,7 @@ pub fn make_solved_types( // other modules will generate constraints for imported values // within the context of their own Subs. for (symbol, var) in exposed_vars_by_symbol.iter() { - let solved_type = SolvedType::new(&solved_subs, *var); + let solved_type = SolvedType::new(solved_subs, *var); solved_types.insert(*symbol, solved_type); } diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 914c7149b7..78f46164c9 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -257,7 +257,7 @@ fn solve( } } Lookup(symbol, expectation, region) => { - match env.vars_by_symbol.get(&symbol) { + match env.vars_by_symbol.get(symbol) { Some(var) => { // Deep copy the vars associated with this symbol before unifying them. // Otherwise, suppose we have this: @@ -390,7 +390,7 @@ fn solve( // If the return expression is guaranteed to solve, // solve the assignments themselves and move on. solve( - &env, + env, state, rank, pools, @@ -508,7 +508,7 @@ fn solve( env: saved_env, mark, } = solve( - &env, + env, state, next_rank, next_pools, @@ -577,7 +577,7 @@ fn solve( let mut new_env = env.clone(); for (symbol, loc_var) in local_def_vars.iter() { // when there are duplicates, keep the one from `env` - if !new_env.vars_by_symbol.contains_key(&symbol) { + if !new_env.vars_by_symbol.contains_key(symbol) { new_env.vars_by_symbol.insert(*symbol, loc_var.value); } } @@ -599,7 +599,7 @@ fn solve( problems, cached_aliases, subs, - &ret_con, + ret_con, ); for (symbol, loc_var) in local_def_vars { @@ -1004,7 +1004,7 @@ fn adjust_rank( unsafe { &*ptr } }; - let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, &content); + let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, content); subs.set_rank_mark(var, max_rank, visit_mark); diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index 70b877e711..546085fedf 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -118,7 +118,7 @@ mod solve_expr { subs.get(variable).content }; - let actual_str = content_to_string(content, &subs, home, &interns); + let actual_str = content_to_string(content, subs, home, &interns); // Disregard UnusedDef problems, because those are unavoidable when // returning a function from the test expression. diff --git a/compiler/test_gen/src/gen_num.rs b/compiler/test_gen/src/gen_num.rs index c57f1fda3d..fb1621eb8c 100644 --- a/compiler/test_gen/src/gen_num.rs +++ b/compiler/test_gen/src/gen_num.rs @@ -339,7 +339,7 @@ mod gen_num { x "# ), - RocDec::from_str_to_i128_unsafe(&"2.1"), + RocDec::from_str_to_i128_unsafe("2.1"), i128 ); } @@ -576,7 +576,7 @@ mod gen_num { z "# ), - RocDec::from_str_to_i128_unsafe(&"5.2"), + RocDec::from_str_to_i128_unsafe("5.2"), i128 ); } @@ -639,7 +639,7 @@ mod gen_num { Err _ -> -1 "# ), - RocDec::from_str_to_i128_unsafe(&"3.333333333333333333"), + RocDec::from_str_to_i128_unsafe("3.333333333333333333"), i128 ); } @@ -755,7 +755,7 @@ mod gen_num { (x - y) - z "# ), - RocDec::from_str_to_i128_unsafe(&"-3.9"), + RocDec::from_str_to_i128_unsafe("-3.9"), i128 ); } @@ -803,7 +803,7 @@ mod gen_num { x * y * z "# ), - RocDec::from_str_to_i128_unsafe(&"48.0"), + RocDec::from_str_to_i128_unsafe("48.0"), i128 ); } diff --git a/compiler/test_gen/src/helpers/eval.rs b/compiler/test_gen/src/helpers/eval.rs index 713f1b8a30..02436deccd 100644 --- a/compiler/test_gen/src/helpers/eval.rs +++ b/compiler/test_gen/src/helpers/eval.rs @@ -60,7 +60,7 @@ pub fn helper<'a>( let loaded = roc_load::file::load_and_monomorphize_from_str( arena, filename, - &module_src, + module_src, stdlib, src_dir, exposed_types, @@ -211,7 +211,7 @@ pub fn helper<'a>( // Compile and add all the Procs before adding main let env = roc_gen_llvm::llvm::build::Env { - arena: &arena, + arena, builder: &builder, dibuilder: &dibuilder, compile_unit: &compile_unit, @@ -252,7 +252,7 @@ pub fn helper<'a>( // Uncomment this to see the module's optimized LLVM instruction output: // env.module.print_to_stderr(); - let lib = module_to_dylib(&env.module, &target, opt_level) + let lib = module_to_dylib(env.module, &target, opt_level) .expect("Error loading compiled dylib for test"); (main_fn_name, delayed_errors.join("\n"), lib) diff --git a/compiler/test_mono/src/lib.rs b/compiler/test_mono/src/lib.rs index 403ef32904..2d05f9cd16 100644 --- a/compiler/test_mono/src/lib.rs +++ b/compiler/test_mono/src/lib.rs @@ -3,7 +3,7 @@ // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. #![allow(clippy::large_enum_variant)] // we actually want to compare against the literal float bits -#![allow(clippy::clippy::float_cmp)] +#![allow(clippy::float_cmp)] #[macro_use] extern crate pretty_assertions; @@ -100,7 +100,7 @@ fn compiles_to_ir(test_name: &str, src: &str) { let loaded = roc_load::file::load_and_monomorphize_from_str( arena, filename, - &module_src, + module_src, &stdlib, src_dir, exposed_types, diff --git a/compiler/types/src/pretty_print.rs b/compiler/types/src/pretty_print.rs index ddd9565a3a..1b651873e2 100644 --- a/compiler/types/src/pretty_print.rs +++ b/compiler/types/src/pretty_print.rs @@ -452,7 +452,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String sorted_fields.sort_by(|(a, _), (b, _)| { a.clone() .as_string(interns, home) - .cmp(&b.as_string(&interns, home)) + .cmp(&b.as_string(interns, home)) }); let mut any_written_yet = false; @@ -464,7 +464,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String any_written_yet = true; } - buf.push_str(&label.as_string(&interns, home)); + buf.push_str(&label.as_string(interns, home)); for var in vars { buf.push(' '); @@ -496,7 +496,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String buf.push_str("[ "); - buf.push_str(&tag_name.as_string(&interns, home)); + buf.push_str(&tag_name.as_string(interns, home)); buf.push_str(" ]"); @@ -539,7 +539,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String } else { any_written_yet = true; } - buf.push_str(&label.as_string(&interns, home)); + buf.push_str(&label.as_string(interns, home)); for var in vars { buf.push(' '); @@ -757,7 +757,7 @@ fn write_symbol(env: &Env, symbol: Symbol, buf: &mut String) { // Don't qualify the symbol if it's in our home module, // or if it's a builtin (since all their types are always in scope) if module_id != env.home && !module_id.is_builtin() { - buf.push_str(module_id.to_string(&interns)); + buf.push_str(module_id.to_string(interns)); buf.push('.'); } diff --git a/compiler/types/src/solved_types.rs b/compiler/types/src/solved_types.rs index 4bf65f0966..d75bb0e0d6 100644 --- a/compiler/types/src/solved_types.rs +++ b/compiler/types/src/solved_types.rs @@ -513,11 +513,11 @@ pub fn to_type( let mut new_args = Vec::with_capacity(args.len()); for arg in args { - new_args.push(to_type(&arg, free_vars, var_store)); + new_args.push(to_type(arg, free_vars, var_store)); } - let new_ret = to_type(&ret, free_vars, var_store); - let new_closure = to_type(&closure, free_vars, var_store); + let new_ret = to_type(ret, free_vars, var_store); + let new_closure = to_type(closure, free_vars, var_store); Type::Function(new_args, Box::new(new_closure), Box::new(new_ret)) } @@ -525,13 +525,13 @@ pub fn to_type( let mut new_args = Vec::with_capacity(args.len()); for arg in args { - new_args.push(to_type(&arg, free_vars, var_store)); + new_args.push(to_type(arg, free_vars, var_store)); } Type::Apply(*symbol, new_args) } Rigid(lowercase) => { - if let Some(var) = free_vars.named_vars.get(&lowercase) { + if let Some(var) = free_vars.named_vars.get(lowercase) { Type::Variable(*var) } else { let var = var_store.fresh(); @@ -552,9 +552,9 @@ pub fn to_type( for (label, field) in fields { let field_val = match field { - Required(typ) => Required(to_type(&typ, free_vars, var_store)), - Optional(typ) => Optional(to_type(&typ, free_vars, var_store)), - Demanded(typ) => Demanded(to_type(&typ, free_vars, var_store)), + Required(typ) => Required(to_type(typ, free_vars, var_store)), + Optional(typ) => Optional(to_type(typ, free_vars, var_store)), + Demanded(typ) => Demanded(to_type(typ, free_vars, var_store)), }; new_fields.insert(label.clone(), field_val); diff --git a/compiler/types/src/types.rs b/compiler/types/src/types.rs index 7e0e54d3f4..e6ffa5ecc9 100644 --- a/compiler/types/src/types.rs +++ b/compiler/types/src/types.rs @@ -406,7 +406,7 @@ impl Type { match self { Variable(v) => { - if let Some(replacement) = substitutions.get(&v) { + if let Some(replacement) = substitutions.get(v) { *self = replacement.clone(); } } @@ -762,15 +762,15 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet) { match tipe { Function(args, closure, ret) => { - symbols_help(&ret, accum); - symbols_help(&closure, accum); + symbols_help(ret, accum); + symbols_help(closure, accum); args.iter().for_each(|arg| symbols_help(arg, accum)); } FunctionOrTagUnion(_, _, ext) => { - symbols_help(&ext, accum); + symbols_help(ext, accum); } RecursiveTagUnion(_, tags, ext) | TagUnion(tags, ext) => { - symbols_help(&ext, accum); + symbols_help(ext, accum); tags.iter() .map(|v| v.1.iter()) .flatten() @@ -778,7 +778,7 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet) { } Record(fields, ext) => { - symbols_help(&ext, accum); + symbols_help(ext, accum); fields.values().for_each(|field| { use RecordField::*; @@ -791,11 +791,11 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet) { } Alias(alias_symbol, _, actual_type) => { accum.insert(*alias_symbol); - symbols_help(&actual_type, accum); + symbols_help(actual_type, accum); } HostExposedAlias { name, actual, .. } => { accum.insert(*name); - symbols_help(&actual, accum); + symbols_help(actual, accum); } Apply(symbol, args) => { accum.insert(*symbol); diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index b4b2e87f8a..a6c388963f 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -177,7 +177,7 @@ fn unify_alias( match other_content { FlexVar(_) => { // Alias wins - merge(subs, &ctx, Alias(symbol, args.to_owned(), real_var)) + merge(subs, ctx, Alias(symbol, args.to_owned(), real_var)) } RecursionVar { structure, .. } => unify_pool(subs, pool, real_var, *structure), RigidVar(_) => unify_pool(subs, pool, real_var, ctx.second), @@ -190,7 +190,7 @@ fn unify_alias( } if problems.is_empty() { - problems.extend(merge(subs, &ctx, other_content.clone())); + problems.extend(merge(subs, ctx, other_content.clone())); } if problems.is_empty() { diff --git a/docs/src/lib.rs b/docs/src/lib.rs index d99409cfbd..5b6f906aac 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -145,7 +145,7 @@ fn render_main_content( } } - type_annotation_to_html(0, &mut content, &type_ann); + type_annotation_to_html(0, &mut content, type_ann); buf.push_str( html_node( @@ -541,7 +541,7 @@ fn should_be_multiline(type_ann: &TypeAnnotation) -> bool { if is_multiline { break; } - is_multiline = should_be_multiline(&value); + is_multiline = should_be_multiline(value); } } diff --git a/editor/src/editor/code_lines.rs b/editor/src/editor/code_lines.rs index 0e72978a02..63f7b52472 100644 --- a/editor/src/editor/code_lines.rs +++ b/editor/src/editor/code_lines.rs @@ -66,7 +66,7 @@ impl Lines for CodeLines { fn get_line(&self, line_nr: usize) -> UIResult<&str> { let line_string = slice_get(line_nr, &self.lines)?; - Ok(&line_string) + Ok(line_string) } fn line_len(&self, line_nr: usize) -> UIResult { @@ -85,7 +85,7 @@ impl Lines for CodeLines { let mut lines = BumpString::with_capacity_in(self.nr_of_chars(), arena); for line in &self.lines { - lines.push_str(&line); + lines.push_str(line); } lines diff --git a/editor/src/editor/ed_error.rs b/editor/src/editor/ed_error.rs index 19a6124606..b534ca52bb 100644 --- a/editor/src/editor/ed_error.rs +++ b/editor/src/editor/ed_error.rs @@ -194,7 +194,7 @@ fn color_backtrace(backtrace: &snafu::Backtrace) -> String { for line in backtrace_split { let new_line = if line.contains("src") { - if !contains_one_of(&line, &irrelevant_src) { + if !contains_one_of(line, &irrelevant_src) { if let Some(prev_line) = prev_line_opt { prev_line_opt = Some(format!("{}", prev_line.truecolor(255, 30, 30))); } diff --git a/editor/src/editor/markup/nodes.rs b/editor/src/editor/markup/nodes.rs index 8390cd70dd..fdbfc98213 100644 --- a/editor/src/editor/markup/nodes.rs +++ b/editor/src/editor/markup/nodes.rs @@ -129,7 +129,7 @@ impl MarkupNode { } } - let closest_ast_child = slice_get(best_index, &children_ids)?; + let closest_ast_child = slice_get(best_index, children_ids)?; let closest_ast_child_index = index_of(*closest_ast_child, &child_ids_with_ast)?; @@ -259,7 +259,7 @@ pub fn expr2_to_markup<'a, 'b>( | Expr2::I128 { text, .. } | Expr2::U128 { text, .. } | Expr2::Float { text, .. } => { - let num_str = get_string(env, &text); + let num_str = get_string(env, text); new_markup_node( num_str, @@ -275,7 +275,7 @@ pub fn expr2_to_markup<'a, 'b>( markup_node_pool, ), Expr2::GlobalTag { name, .. } => new_markup_node( - get_string(env, &name), + get_string(env, name), expr2_node_id, HighlightStyle::Type, markup_node_pool, diff --git a/editor/src/editor/mvc/ed_model.rs b/editor/src/editor/mvc/ed_model.rs index b57a36df8a..6cd9373408 100644 --- a/editor/src/editor/mvc/ed_model.rs +++ b/editor/src/editor/mvc/ed_model.rs @@ -59,7 +59,7 @@ pub fn init_model<'a>( interns: &'a Interns, code_arena: &'a Bump, ) -> EdResult> { - let mut module = EdModule::new(&code_str, env, code_arena)?; + let mut module = EdModule::new(code_str, env, code_arena)?; let ast_root_id = module.ast_root_id; let mut markup_node_pool = SlowPool::new(); @@ -175,7 +175,7 @@ impl<'a> EdModule<'a> { let region = Region::new(0, 0, 0, 0); - let expr2_result = str_to_expr2(&ast_arena, &code_str, &mut env, &mut scope, region); + let expr2_result = str_to_expr2(ast_arena, code_str, &mut env, &mut scope, region); match expr2_result { Ok((expr2, _output)) => { @@ -239,7 +239,7 @@ pub mod test_ed_model { ); ed_model::init_model( - &code_str, + code_str, file_path, env, &ed_model_refs.interns, diff --git a/editor/src/editor/mvc/ed_update.rs b/editor/src/editor/mvc/ed_update.rs index cf510dfd7f..23bba5bdbe 100644 --- a/editor/src/editor/mvc/ed_update.rs +++ b/editor/src/editor/mvc/ed_update.rs @@ -221,7 +221,7 @@ impl<'a> EdModel<'a> { if self.grid_node_map.node_exists_at_pos(caret_pos) { let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self .grid_node_map - .get_expr_start_end_pos(self.get_caret(), &self)?; + .get_expr_start_end_pos(self.get_caret(), self)?; self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?; } else if self @@ -230,7 +230,7 @@ impl<'a> EdModel<'a> { { let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self .grid_node_map - .get_expr_start_end_pos(self.get_caret().decrement_col(), &self)?; + .get_expr_start_end_pos(self.get_caret().decrement_col(), self)?; self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?; } @@ -247,7 +247,7 @@ impl<'a> EdModel<'a> { let constrained = constrain_expr( &arena, &mut self.module.env, - &expr, + expr, Expected::NoExpectation(Type2::Variable(var)), Region::zero(), ); @@ -275,7 +275,7 @@ impl<'a> EdModel<'a> { let content = subs.get(var).content; PoolStr::new( - &content_to_string(content, &subs, self.module.env.home, self.interns), + &content_to_string(content, subs, self.module.env.home, self.interns), self.module.env.pool, ) } @@ -605,7 +605,7 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult } Expr2::SmallStr(old_arr_str) => { update_small_string( - &ch, old_arr_str, ed_model + ch, old_arr_str, ed_model )? } Expr2::Str(old_pool_str) => { @@ -2043,11 +2043,11 @@ pub mod test_ed_update { expected_tooltip: &str, new_char: char, ) -> Result<(), String> { - assert_type_tooltips_seq(pre_lines, &vec![expected_tooltip], &new_char.to_string()) + assert_type_tooltips_seq(pre_lines, &[expected_tooltip], &new_char.to_string()) } pub fn assert_type_tooltip_clean(lines: &[&str], expected_tooltip: &str) -> Result<(), String> { - assert_type_tooltips_seq(lines, &vec![expected_tooltip], "") + assert_type_tooltips_seq(lines, &[expected_tooltip], "") } // When doing ctrl+shift+up multiple times we select the surrounding expression every time, diff --git a/editor/src/editor/mvc/int_update.rs b/editor/src/editor/mvc/int_update.rs index 8af06a2abe..af6eb80f84 100644 --- a/editor/src/editor/mvc/int_update.rs +++ b/editor/src/editor/mvc/int_update.rs @@ -22,7 +22,7 @@ pub fn start_new_int(ed_model: &mut EdModel, digit_char: &char) -> EdResult EdResult { curr_mark_node, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; let is_blank_node = curr_mark_node.is_blank(); @@ -101,7 +101,7 @@ pub fn add_blank_child( curr_mark_node: _, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; let trip_result: EdResult<(ExprId, ExprId, MarkNodeId)> = if let Some(parent_id) = parent_id_opt { diff --git a/editor/src/editor/mvc/record_update.rs b/editor/src/editor/mvc/record_update.rs index 9cf37c95e0..bacb17db46 100644 --- a/editor/src/editor/mvc/record_update.rs +++ b/editor/src/editor/mvc/record_update.rs @@ -24,7 +24,7 @@ pub fn start_new_record(ed_model: &mut EdModel) -> EdResult { curr_mark_node, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; let is_blank_node = curr_mark_node.is_blank(); @@ -109,7 +109,7 @@ pub fn update_empty_record( curr_mark_node, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; if prev_mark_node.get_content()? == nodes::LEFT_ACCOLADE && curr_mark_node.get_content()? == nodes::RIGHT_ACCOLADE @@ -182,7 +182,7 @@ pub fn update_record_colon( curr_mark_node, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; if let Some(parent_id) = parent_id_opt { let curr_ast_node = ed_model.module.env.pool.get(ast_node_id); diff --git a/editor/src/editor/mvc/string_update.rs b/editor/src/editor/mvc/string_update.rs index 3080a03e2a..b0145804ac 100644 --- a/editor/src/editor/mvc/string_update.rs +++ b/editor/src/editor/mvc/string_update.rs @@ -22,7 +22,7 @@ pub fn update_small_string( curr_mark_node: _, parent_id_opt: _, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; let new_input = &new_char.to_string(); @@ -84,7 +84,7 @@ pub fn update_string( curr_mark_node: _, parent_id_opt: _, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; // update markup let curr_mark_node_mut = ed_model.markup_node_pool.get_mut(curr_mark_node_id); @@ -129,7 +129,7 @@ pub fn start_new_string(ed_model: &mut EdModel) -> EdResult { curr_mark_node, parent_id_opt, ast_node_id, - } = get_node_context(&ed_model)?; + } = get_node_context(ed_model)?; if curr_mark_node.is_blank() { let new_expr2_node = Expr2::SmallStr(arraystring::ArrayString::new()); diff --git a/editor/src/editor/render_ast.rs b/editor/src/editor/render_ast.rs index d862b196a2..e7b01ab55b 100644 --- a/editor/src/editor/render_ast.rs +++ b/editor/src/editor/render_ast.rs @@ -108,7 +108,7 @@ fn markup_to_wgpu_helper<'a>( attributes: _, parent_id_opt: _, } => { - let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?; + let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?; let glyph_text = glyph_brush::OwnedText::new(content) .with_color(colors::to_slice(*highlight_color)) @@ -127,7 +127,7 @@ fn markup_to_wgpu_helper<'a>( .with_color(colors::to_slice(colors::WHITE)) .with_scale(code_style.font_size); - let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?; + let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?; let char_width = code_style.glyph_dim_rect.width; let char_height = code_style.glyph_dim_rect.height; diff --git a/editor/src/graphics/lowlevel/buffer.rs b/editor/src/graphics/lowlevel/buffer.rs index 539f52301a..f9cf9fc9a4 100644 --- a/editor/src/graphics/lowlevel/buffer.rs +++ b/editor/src/graphics/lowlevel/buffer.rs @@ -121,10 +121,10 @@ pub fn create_rect_buffers( let num_rects = { let mut quad_buffer_builder = QuadBufferBuilder::new(); for rect in rects { - quad_buffer_builder = quad_buffer_builder.push_rect(&rect); + quad_buffer_builder = quad_buffer_builder.push_rect(rect); } - let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(&gpu_device); + let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(gpu_device); stg_vertex.copy_to_buffer(encoder, &vertex_buffer); stg_index.copy_to_buffer(encoder, &index_buffer); diff --git a/editor/src/graphics/lowlevel/pipelines.rs b/editor/src/graphics/lowlevel/pipelines.rs index 79e3437f2e..810766ccfd 100644 --- a/editor/src/graphics/lowlevel/pipelines.rs +++ b/editor/src/graphics/lowlevel/pipelines.rs @@ -19,7 +19,7 @@ pub fn make_rect_pipeline( label: Some("Rectangle pipeline layout"), }); let pipeline = create_render_pipeline( - &gpu_device, + gpu_device, &pipeline_layout, swap_chain_descr.format, &wgpu::ShaderModuleDescriptor { @@ -42,7 +42,7 @@ pub fn create_render_pipeline( device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render pipeline"), - layout: Some(&layout), + layout: Some(layout), vertex: wgpu::VertexState { module: &shader, entry_point: "vs_main", diff --git a/editor/src/graphics/primitives/text.rs b/editor/src/graphics/primitives/text.rs index 8910ceef38..4cc016d5cf 100644 --- a/editor/src/graphics/primitives/text.rs +++ b/editor/src/graphics/primitives/text.rs @@ -81,7 +81,7 @@ fn section_from_text<'a>( ..Section::default() } .add_text( - wgpu_glyph::Text::new(&text.text) + wgpu_glyph::Text::new(text.text) .with_color(Vector4::from(text.color)) .with_scale(text.size), ) @@ -156,5 +156,5 @@ pub fn build_glyph_brush( ) -> Result, InvalidFont> { let inconsolata = FontArc::try_from_slice(include_bytes!("../../../Inconsolata-Regular.ttf"))?; - Ok(GlyphBrushBuilder::using_font(inconsolata).build(&gpu_device, render_format)) + Ok(GlyphBrushBuilder::using_font(inconsolata).build(gpu_device, render_format)) } diff --git a/editor/src/lang/ast.rs b/editor/src/lang/ast.rs index 9f421b252b..e48cb42ebd 100644 --- a/editor/src/lang/ast.rs +++ b/editor/src/lang/ast.rs @@ -472,7 +472,7 @@ fn expr2_to_string_helper( Expr2::EmptyRecord => out_string.push_str("EmptyRecord"), Expr2::Record { record_var, fields } => { out_string.push_str("Record:\n"); - out_string.push_str(&var_to_string(&record_var, indent_level + 1)); + out_string.push_str(&var_to_string(record_var, indent_level + 1)); out_string.push_str(&format!("{}fields: [\n", get_spacing(indent_level + 1))); diff --git a/editor/src/lang/constrain.rs b/editor/src/lang/constrain.rs index cb1ed061bc..ef52f2b7bb 100644 --- a/editor/src/lang/constrain.rs +++ b/editor/src/lang/constrain.rs @@ -1129,7 +1129,7 @@ pub fn constrain_pattern<'a>( let pat_type = Type2::Variable(*var); let expected = PExpected::NoExpectation(pat_type.shallow_clone()); - if !state.headers.contains_key(&symbol) { + if !state.headers.contains_key(symbol) { state.headers.insert(*symbol, pat_type.shallow_clone()); } diff --git a/editor/src/lang/roc_file.rs b/editor/src/lang/roc_file.rs index 98f1a25210..5379e9097a 100644 --- a/editor/src/lang/roc_file.rs +++ b/editor/src/lang/roc_file.rs @@ -37,11 +37,11 @@ impl<'a> File<'a> { let allocation = arena.alloc(bytes); let module_parse_state = parser::State::new(allocation); - let parsed_module = roc_parse::module::parse_header(&arena, module_parse_state); + let parsed_module = roc_parse::module::parse_header(arena, module_parse_state); match parsed_module { Ok((module, state)) => { - let parsed_defs = module_defs().parse(&arena, state); + let parsed_defs = module_defs().parse(arena, state); match parsed_defs { Ok((_, defs, _)) => Ok(File { diff --git a/editor/src/ui/tooltip.rs b/editor/src/ui/tooltip.rs index 0eeed5c04b..9262a71f65 100644 --- a/editor/src/ui/tooltip.rs +++ b/editor/src/ui/tooltip.rs @@ -44,7 +44,7 @@ impl<'a> ToolTip<'a> { ) .into(), color: ui_theme.tooltip_text, - text: &self.text, + text: self.text, size: ui_theme.default_font_size, ..Default::default() } diff --git a/editor/tests/solve_expr2.rs b/editor/tests/solve_expr2.rs index a25c88b077..0850a6af18 100644 --- a/editor/tests/solve_expr2.rs +++ b/editor/tests/solve_expr2.rs @@ -121,7 +121,7 @@ fn infer_eq(actual: &str, expected_str: &str) { all_ident_ids: dep_idents, }; - let actual_str = content_to_string(content, &subs, mod_id, &interns); + let actual_str = content_to_string(content, subs, mod_id, &interns); assert_eq!(actual_str, expected_str); } diff --git a/vendor/morphic_lib/src/api.rs b/vendor/morphic_lib/src/api.rs index f45c2dbd53..6dc57d1c6f 100644 --- a/vendor/morphic_lib/src/api.rs +++ b/vendor/morphic_lib/src/api.rs @@ -1612,7 +1612,7 @@ fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) { fn hash_func_name(mod_: ModName, func: FuncName) -> FuncSpec { let mut hasher = Sha256::new(); - hash_bstr(&mut hasher, &mod_.0); - hash_bstr(&mut hasher, &func.0); + hash_bstr(&mut hasher, mod_.0); + hash_bstr(&mut hasher, func.0); FuncSpec(hasher.finalize().into()) } diff --git a/vendor/morphic_lib/src/preprocess.rs b/vendor/morphic_lib/src/preprocess.rs index 161d61ca9f..f52e0f648b 100644 --- a/vendor/morphic_lib/src/preprocess.rs +++ b/vendor/morphic_lib/src/preprocess.rs @@ -679,8 +679,8 @@ fn preprocess_block_expr( values_in_scope, continuations_in_scope, block, - &api_node.op, - &api_node.inputs, + api_node.op, + api_node.inputs, ) .map_err(Error::annotate_binding(BindingLocation::Value( api_value_id, @@ -1149,7 +1149,7 @@ fn preprocess_func_def( let (final_block, ret_val) = preprocess_block_expr( tc, ctx, - &api_builder, + api_builder, body_types, &mut graph_builder, &mut values_in_scope, @@ -1183,7 +1183,7 @@ fn preprocess_const_def( let (final_block, ret_val) = preprocess_block_expr( tc, ctx, - &api_builder, + api_builder, body_types, &mut graph_builder, &mut values_in_scope, From e805e63db6364e391c4bb1f5809b1d257276f9bb Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 30 Jul 2021 16:54:22 +0200 Subject: [PATCH 2/5] typos --- CodeOfConduct.md | 2 +- compiler/build/src/link.rs | 4 ++-- compiler/constrain/src/pattern.rs | 2 +- compiler/fmt/src/expr.rs | 2 +- compiler/load/src/docs.rs | 2 +- compiler/module/src/symbol.rs | 2 +- compiler/mono/src/borrow.rs | 2 +- compiler/mono/src/expand_rc.rs | 2 +- compiler/mono/src/ir.rs | 2 +- compiler/mono/src/tail_recursion.rs | 6 +++--- compiler/solve/src/solve.rs | 2 +- compiler/solve/tests/solve_expr.rs | 2 +- compiler/str/README.md | 2 +- compiler/test_gen/src/gen_primitives.rs | 2 +- docs/src/lib.rs | 12 ++++++------ editor/src/lang/constrain.rs | 2 +- editor/src/lang/solve.rs | 2 +- examples/hello-world/README.md | 2 +- examples/hello-zig/README.md | 2 +- roc-for-elm-programmers.md | 8 ++++---- 20 files changed, 31 insertions(+), 31 deletions(-) diff --git a/CodeOfConduct.md b/CodeOfConduct.md index d3a4ef15dd..aa99bba432 100644 --- a/CodeOfConduct.md +++ b/CodeOfConduct.md @@ -32,7 +32,7 @@ These are the policies for upholding our community's standards of conduct. If yo In the Roc community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely. -And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Roc progammers comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. +And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Roc programmers comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. The enforcement policies listed above apply to all official Roc venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Roc Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index 8b270a34ca..db0ce5bed4 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -342,7 +342,7 @@ fn link_linux( output_path, ), LinkType::Dylib => { - // TODO: do we acually need the version number on this? + // TODO: do we actually need the version number on this? // Do we even need the "-soname" argument? // // See https://software.intel.com/content/www/us/en/develop/articles/create-a-unix-including-linux-shared-library.html @@ -505,7 +505,7 @@ pub fn module_to_dylib( app_o_file.set_file_name("app.o"); - // Emit the .o file using position-indepedent code (PIC) - needed for dylibs + // Emit the .o file using position-independent code (PIC) - needed for dylibs let reloc = RelocMode::PIC; let model = CodeModel::Default; let target_machine = diff --git a/compiler/constrain/src/pattern.rs b/compiler/constrain/src/pattern.rs index da28a4b065..310a7a251c 100644 --- a/compiler/constrain/src/pattern.rs +++ b/compiler/constrain/src/pattern.rs @@ -119,7 +119,7 @@ fn headers_from_annotation_help( } /// This accepts PatternState (rather than returning it) so that the caller can -/// intiialize the Vecs in PatternState using with_capacity +/// initialize the Vecs in PatternState using with_capacity /// based on its knowledge of their lengths. pub fn constrain_pattern( env: &Env, diff --git a/compiler/fmt/src/expr.rs b/compiler/fmt/src/expr.rs index 77f4d96b3c..54ee550ef6 100644 --- a/compiler/fmt/src/expr.rs +++ b/compiler/fmt/src/expr.rs @@ -1027,7 +1027,7 @@ fn format_field_multiline<'a, T>( format_field_multiline(buf, sub_field, indent, separator_prefix); } AssignedField::SpaceAfter(sub_field, spaces) => { - // We have somethig like that: + // We have something like that: // ``` // field # comment // , otherfield diff --git a/compiler/load/src/docs.rs b/compiler/load/src/docs.rs index 1fa5db439d..4a17ba31b4 100644 --- a/compiler/load/src/docs.rs +++ b/compiler/load/src/docs.rs @@ -148,7 +148,7 @@ fn generate_entry_doc<'a>( match def { Def::SpaceBefore(sub_def, comments_or_new_lines) => { - // Comments before a definition are attached to the current defition + // Comments before a definition are attached to the current definition for detached_doc in detached_docs_from_comments_and_new_lines(comments_or_new_lines) { acc.push(DetachedDoc(detached_doc)); diff --git a/compiler/module/src/symbol.rs b/compiler/module/src/symbol.rs index 187bc2a734..41d1c57316 100644 --- a/compiler/module/src/symbol.rs +++ b/compiler/module/src/symbol.rs @@ -317,7 +317,7 @@ impl fmt::Debug for ModuleId { } } - /// In relese builds, all we have access to is the number, so only display that. + /// In release builds, all we have access to is the number, so only display that. #[cfg(not(debug_assertions))] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index cd7fbbf9ef..4968fe7f06 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -475,7 +475,7 @@ impl<'a> BorrowInfState<'a> { } } - /// This looks at the assignement + /// This looks at the assignment /// /// let z = e in ... /// diff --git a/compiler/mono/src/expand_rc.rs b/compiler/mono/src/expand_rc.rs index 55a2faa258..820fcf5395 100644 --- a/compiler/mono/src/expand_rc.rs +++ b/compiler/mono/src/expand_rc.rs @@ -50,7 +50,7 @@ use roc_module::symbol::{IdentIds, ModuleId, Symbol}; // Let's work through the `Cons x xx` example // // First we need to know the constructor of `xs` in the particular block. This information would -// normally be lost when we compile pattern matches, but we keep it in the `BrachInfo` field of +// normally be lost when we compile pattern matches, but we keep it in the `BranchInfo` field of // switch branches. here we also store the symbol that was switched on, and the layout of that // symbol. // diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index dbc5655942..6c8c8af85e 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -1700,7 +1700,7 @@ fn pattern_to_when<'a>( UnsupportedPattern(region) => { // create the runtime error here, instead of delegating to When. - // UnsupportedPattern should then never occcur in When + // UnsupportedPattern should then never occur in When let error = roc_problem::can::RuntimeError::UnsupportedPattern(*region); (env.unique_symbol(), Located::at_zero(RuntimeError(error))) } diff --git a/compiler/mono/src/tail_recursion.rs b/compiler/mono/src/tail_recursion.rs index 0eae4df30a..f0efd1736d 100644 --- a/compiler/mono/src/tail_recursion.rs +++ b/compiler/mono/src/tail_recursion.rs @@ -35,9 +35,9 @@ pub fn make_tail_recursive<'a>( stmt: Stmt<'a>, args: &'a [(Layout<'a>, Symbol)], ) -> Stmt<'a> { - let alloced = arena.alloc(stmt); - match insert_jumps(arena, alloced, id, needle) { - None => alloced.clone(), + let allocated = arena.alloc(stmt); + match insert_jumps(arena, allocated, id, needle) { + None => allocated.clone(), Some(new) => { // jumps were inserted, we must now add a join point diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 78f46164c9..972b3f9b1f 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -114,7 +114,7 @@ impl Pools { pub fn split_last(&self) -> (&Vec, &[Vec]) { self.0 .split_last() - .unwrap_or_else(|| panic!("Attempted to split_last() on non-empy Pools")) + .unwrap_or_else(|| panic!("Attempted to split_last() on non-empty Pools")) } pub fn extend_to(&mut self, n: usize) { diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index 546085fedf..b2dd6a74e6 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -3820,7 +3820,7 @@ mod solve_expr { } #[test] - fn recursive_functon_with_rigid() { + fn recursive_function_with_rigid() { infer_eq_without_problem( indoc!( r#" diff --git a/compiler/str/README.md b/compiler/str/README.md index 2ab0c3c25d..04af2f5e9f 100644 --- a/compiler/str/README.md +++ b/compiler/str/README.md @@ -13,7 +13,7 @@ struct List { } ``` -On a 64-bit system, this `struct` would take up 16B in memory. On a 32-bit sysem, it would take up 8B. +On a 64-bit system, this `struct` would take up 16B in memory. On a 32-bit system, it would take up 8B. Here's what the fields mean: diff --git a/compiler/test_gen/src/gen_primitives.rs b/compiler/test_gen/src/gen_primitives.rs index 77b4f7cb24..46d3816aa4 100644 --- a/compiler/test_gen/src/gen_primitives.rs +++ b/compiler/test_gen/src/gen_primitives.rs @@ -1280,7 +1280,7 @@ fn linked_list_singleton() { } #[test] -fn recursive_functon_with_rigid() { +fn recursive_function_with_rigid() { assert_non_opt_evals_to!( indoc!( r#" diff --git a/docs/src/lib.rs b/docs/src/lib.rs index 5b6f906aac..6ed02513c0 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -218,17 +218,17 @@ fn render_name_and_version(name: &str, version: &str) -> String { .as_str(), ); - let mut verions_href = String::new(); + let mut versions_href = String::new(); - verions_href.push('/'); - verions_href.push_str(name); - verions_href.push('/'); - verions_href.push_str(version); + versions_href.push('/'); + versions_href.push_str(name); + versions_href.push('/'); + versions_href.push_str(version); buf.push_str( html_node( "a", - vec![("class", "version"), ("href", verions_href.as_str())], + vec![("class", "version"), ("href", versions_href.as_str())], version, ) .as_str(), diff --git a/editor/src/lang/constrain.rs b/editor/src/lang/constrain.rs index ef52f2b7bb..8350a2db28 100644 --- a/editor/src/lang/constrain.rs +++ b/editor/src/lang/constrain.rs @@ -1038,7 +1038,7 @@ fn constrain_when_branch<'a>( } /// This accepts PatternState (rather than returning it) so that the caller can -/// intiialize the Vecs in PatternState using with_capacity +/// initialize the Vecs in PatternState using with_capacity /// based on its knowledge of their lengths. pub fn constrain_pattern<'a>( arena: &'a Bump, diff --git a/editor/src/lang/solve.rs b/editor/src/lang/solve.rs index f248cc4999..fb69fed9d8 100644 --- a/editor/src/lang/solve.rs +++ b/editor/src/lang/solve.rs @@ -118,7 +118,7 @@ impl Pools { pub fn split_last(&self) -> (&Vec, &[Vec]) { self.0 .split_last() - .unwrap_or_else(|| panic!("Attempted to split_last() on non-empy Pools")) + .unwrap_or_else(|| panic!("Attempted to split_last() on non-empty Pools")) } pub fn extend_to(&mut self, n: usize) { diff --git a/examples/hello-world/README.md b/examples/hello-world/README.md index a2890f03ed..4aab7c1346 100644 --- a/examples/hello-world/README.md +++ b/examples/hello-world/README.md @@ -40,7 +40,7 @@ can write (it would be plain Roc code, but with some extra keywords that aren't available in normal modules - kinda like `port module` in Elm), and which describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary. Roc application authors only care about the Roc-host/Roc-app portion, and the -host author only cares about the Roc-host/C bounary when implementing the host. +host author only cares about the Roc-host/C boundary when implementing the host. Using this glue code, the Roc compiler can generate C header files describing the boundary. This not only gets us host compatibility with C compilers, but also diff --git a/examples/hello-zig/README.md b/examples/hello-zig/README.md index a2890f03ed..4aab7c1346 100644 --- a/examples/hello-zig/README.md +++ b/examples/hello-zig/README.md @@ -40,7 +40,7 @@ can write (it would be plain Roc code, but with some extra keywords that aren't available in normal modules - kinda like `port module` in Elm), and which describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary. Roc application authors only care about the Roc-host/Roc-app portion, and the -host author only cares about the Roc-host/C bounary when implementing the host. +host author only cares about the Roc-host/C boundary when implementing the host. Using this glue code, the Roc compiler can generate C header files describing the boundary. This not only gets us host compatibility with C compilers, but also diff --git a/roc-for-elm-programmers.md b/roc-for-elm-programmers.md index 575eb461e3..c624fd8985 100644 --- a/roc-for-elm-programmers.md +++ b/roc-for-elm-programmers.md @@ -437,7 +437,7 @@ when error is # File.WriteErr possibilities DirectoryNotFound -> ... - WriteAcessDenied -> ... + WriteAccessDenied -> ... DiskFull -> ... ``` @@ -819,7 +819,7 @@ Dict.fromList [ KV "Sam" True, KV "Ali" False KV firstName False This works, but is not nearly as nice to read. -Additionally, map literals can compile direcly to efficient initialization code +Additionally, map literals can compile directly to efficient initialization code without needing to (hopefully be able to) optimize away the intermediate `List` involved in `fromList`. @@ -969,7 +969,7 @@ test "it works" This is convenient with higher-order functions which take a function as their final argument. Since many Roc functions have the same type as Elm functions except with their arguments flipped, this means it's possible to end a lot -of expessions with anonymous functions - e.g. +of expressions with anonymous functions - e.g. ```elm modifiedNums = @@ -1357,7 +1357,7 @@ are all unions containing a single tag. That means they hold no information at r that is, discarded prior to code generation. During code generation, Roc treats `Quantity [ Km ] Int` as equivalent to `Quantity Int`. -Then, becaue `Quantity Int` is an alias for `[ Quantity Int ]`, it will unbox again +Then, because `Quantity Int` is an alias for `[ Quantity Int ]`, it will unbox again and reduce that all the way down to to `Int`. This means that, just like phantom *types*, phantom *values* affect type checking From 981e026a58aa37a39a2b755cbd7b5ed7fd8b3de0 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 30 Jul 2021 16:57:43 +0200 Subject: [PATCH 3/5] lower version of typos-cli --- Earthfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Earthfile b/Earthfile index 3415c05a3b..3c2c67163b 100644 --- a/Earthfile +++ b/Earthfile @@ -1,4 +1,4 @@ -FROM rust:1.53-slim-buster +FROM rust:1.54-slim-buster WORKDIR /earthbuild prep-debian: @@ -101,7 +101,7 @@ check-rustfmt: RUN cargo fmt --all -- --check check-typos: - RUN cargo install typos-cli + RUN cargo install --version 1.0.11 typos-cli COPY --dir .github ci cli compiler docs editor examples nightly_benches packages roc_std www *.md LEGAL_DETAILS shell.nix ./ RUN typos From e0648d348dacdc3b8229b549a835beb46b72c619 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 30 Jul 2021 17:13:50 +0200 Subject: [PATCH 4/5] new formatting --- compiler/can/src/def.rs | 6 ++---- compiler/gen_llvm/src/llvm/build_dict.rs | 3 +-- compiler/gen_llvm/src/llvm/convert.rs | 3 +-- compiler/mono/src/decision_tree.rs | 8 +------- compiler/parse/tests/test_parse.rs | 1 - compiler/reporting/src/error/parse.rs | 4 +--- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index 146ecf838f..1c8f99f3ff 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -1110,10 +1110,8 @@ fn canonicalize_pending_def<'a>( // identifier (e.g. `f = \x -> ...`), then this symbol can be tail-called. let outer_identifier = env.tailcallable_symbol; - if let ( - &ast::Pattern::Identifier(_name), - &Pattern::Identifier(ref defined_symbol), - ) = (&loc_pattern.value, &loc_can_pattern.value) + if let (&ast::Pattern::Identifier(_name), &Pattern::Identifier(ref defined_symbol)) = + (&loc_pattern.value, &loc_can_pattern.value) { env.tailcallable_symbol = Some(*defined_symbol); diff --git a/compiler/gen_llvm/src/llvm/build_dict.rs b/compiler/gen_llvm/src/llvm/build_dict.rs index bb6c8189bc..b056cf6b2b 100644 --- a/compiler/gen_llvm/src/llvm/build_dict.rs +++ b/compiler/gen_llvm/src/llvm/build_dict.rs @@ -867,8 +867,7 @@ fn dict_symbol_to_zig_dict<'a, 'ctx, 'env>( let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap(); - complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict") - .into_struct_value() + complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict").into_struct_value() } fn zig_dict_type<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> inkwell::types::StructType<'ctx> { diff --git a/compiler/gen_llvm/src/llvm/convert.rs b/compiler/gen_llvm/src/llvm/convert.rs index 3ec1f749f8..df4a074e68 100644 --- a/compiler/gen_llvm/src/llvm/convert.rs +++ b/compiler/gen_llvm/src/llvm/convert.rs @@ -58,8 +58,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>( } } NullableUnwrapped { other_fields, .. } => { - let block = - block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes); + let block = block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes); block.ptr_type(AddressSpace::Generic).into() } NonNullableUnwrapped(fields) => { diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index d847d8c7dd..67a9ab8bca 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -1325,13 +1325,7 @@ fn stores_and_condition<'a>( // Assumption: there is at most 1 guard, and it is the outer layer. for (path, test) in test_chain { - tests.push(test_to_equality( - env, - cond_symbol, - cond_layout, - &path, - test, - )) + tests.push(test_to_equality(env, cond_symbol, cond_layout, &path, test)) } tests diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index 03b1a0273b..f172d9453d 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -3531,7 +3531,6 @@ mod test_parse { match parsed { Ok((_, _, _state)) => { // dbg!(_state); - } Err((_, _fail, _state)) => { // dbg!(_fail, _state); diff --git a/compiler/reporting/src/error/parse.rs b/compiler/reporting/src/error/parse.rs index ea62283fa8..1fbfac0d3a 100644 --- a/compiler/reporting/src/error/parse.rs +++ b/compiler/reporting/src/error/parse.rs @@ -211,9 +211,7 @@ fn to_expr_report<'a>( to_lambda_report(alloc, filename, context, lambda, *row, *col) } EExpr::List(list, row, col) => to_list_report(alloc, filename, context, list, *row, *col), - EExpr::Str(string, row, col) => { - to_str_report(alloc, filename, context, string, *row, *col) - } + EExpr::Str(string, row, col) => to_str_report(alloc, filename, context, string, *row, *col), EExpr::InParens(expr, row, col) => { to_expr_in_parens_report(alloc, filename, context, expr, *row, *col) } From 29953e9218aed236dc9cc98a2ae62cd1fccd3959 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 30 Jul 2021 17:44:38 +0200 Subject: [PATCH 5/5] fix unused result --- cli/tests/cli_run.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/tests/cli_run.rs b/cli/tests/cli_run.rs index 4b7de59b6a..01d52871d3 100644 --- a/cli/tests/cli_run.rs +++ b/cli/tests/cli_run.rs @@ -38,7 +38,9 @@ mod cli_run { emit_bin, zig_host_src, zig_str_path, - ); + ) + .map(|_| ()) + .unwrap_or(()); }); }