diff --git a/crates/ast/src/lang/core/expr/expr_to_expr2.rs b/crates/ast/src/lang/core/expr/expr_to_expr2.rs index e47fe69bab..62d6a5d6dd 100644 --- a/crates/ast/src/lang/core/expr/expr_to_expr2.rs +++ b/crates/ast/src/lang/core/expr/expr_to_expr2.rs @@ -352,7 +352,7 @@ pub fn expr_to_expr2<'a>( for (node_id, branch) in can_branches.iter_node_ids().zip(branches.iter()) { let (can_when_branch, branch_references) = - canonicalize_when_branch(env, scope, *branch, &mut output); + canonicalize_when_branch(env, scope, branch, &mut output); output.references.union_mut(branch_references); diff --git a/crates/ast/src/lang/core/expr/introduced_vars.rs b/crates/ast/src/lang/core/expr/introduced_vars.rs index 26bbe6b738..91d5b7cdbe 100644 --- a/crates/ast/src/lang/core/expr/introduced_vars.rs +++ b/crates/ast/src/lang/core/expr/introduced_vars.rs @@ -3,7 +3,7 @@ use roc_module::ident::Lowercase; use roc_module::symbol::Symbol; use roc_types::subs::Variable; -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct IntroducedVariables { // Rigids must be unique within a type annotation. // E.g. in `identity : a -> a`, there should only be one diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 67e86bdd4e..11ed45bfe4 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -1154,7 +1154,7 @@ fn run_with_wasmer(wasm_path: &std::path::Path, stdin: &[&str]) -> String { // .unwrap(); let store = Store::default(); - let module = Module::from_file(&store, &wasm_path).unwrap(); + let module = Module::from_file(&store, wasm_path).unwrap(); let mut fake_stdin = wasmer_wasi::Pipe::new(); let fake_stdout = wasmer_wasi::Pipe::new(); diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index b37c235d77..a31669a34f 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -124,7 +124,7 @@ pub fn build_zig_host_native( bitcode::get_builtins_host_obj_path() }; - zig_cmd.args(&[ + zig_cmd.args([ "build-exe", "-fPIE", "-rdynamic", // make sure roc_alloc and friends are exposed @@ -132,10 +132,10 @@ pub fn build_zig_host_native( &builtins_obj, ]); } else { - zig_cmd.args(&["build-obj", "-fPIC"]); + zig_cmd.args(["build-obj", "-fPIC"]); } - zig_cmd.args(&[ + zig_cmd.args([ zig_host_src, &format!("-femit-bin={}", emit_bin), "--pkg-begin", @@ -154,7 +154,7 @@ pub fn build_zig_host_native( // when we use zig 0.9. It looks like zig 0.10 is going to fix // this problem for us, so this is a temporary workaround if !target.contains("windows") { - zig_cmd.args(&[ + zig_cmd.args([ // include the zig runtime "-fcompiler-rt", ]); @@ -162,13 +162,13 @@ pub fn build_zig_host_native( // valgrind does not yet support avx512 instructions, see #1963. if env::var("NO_AVX512").is_ok() { - zig_cmd.args(&["-mcpu", "x86_64"]); + zig_cmd.args(["-mcpu", "x86_64"]); } if matches!(opt_level, OptLevel::Optimize) { - zig_cmd.args(&["-O", "ReleaseSafe"]); + zig_cmd.args(["-O", "ReleaseSafe"]); } else if matches!(opt_level, OptLevel::Size) { - zig_cmd.args(&["-O", "ReleaseSmall"]); + zig_cmd.args(["-O", "ReleaseSmall"]); } zig_cmd @@ -378,9 +378,9 @@ pub fn build_zig_host_wasm32( .args(args); if matches!(opt_level, OptLevel::Optimize) { - zig_cmd.args(&["-O", "ReleaseSafe"]); + zig_cmd.args(["-O", "ReleaseSafe"]); } else if matches!(opt_level, OptLevel::Size) { - zig_cmd.args(&["-O", "ReleaseSmall"]); + zig_cmd.args(["-O", "ReleaseSmall"]); } zig_cmd @@ -400,11 +400,11 @@ pub fn build_c_host_native( let mut clang_cmd = clang(); clang_cmd .env_clear() - .env("PATH", &env_path) - .env("CPATH", &env_cpath) - .env("HOME", &env_home) + .env("PATH", env_path) + .env("CPATH", env_cpath) + .env("HOME", env_home) .args(sources) - .args(&["-o", dest]); + .args(["-o", dest]); if let Some(shared_lib_path) = shared_lib_path { match target.operating_system { OperatingSystem::Windows => { @@ -425,7 +425,7 @@ pub fn build_c_host_native( ); } _ => { - clang_cmd.args(&[ + clang_cmd.args([ shared_lib_path.to_str().unwrap(), // This line is commented out because // @bhansconnect: With the addition of Str.graphemes, always @@ -444,7 +444,7 @@ pub fn build_c_host_native( } } } else { - clang_cmd.args(&["-fPIC", "-c"]); + clang_cmd.args(["-fPIC", "-c"]); } if matches!(opt_level, OptLevel::Optimize) { clang_cmd.arg("-O3"); @@ -473,8 +473,8 @@ pub fn build_swift_host_native( let mut command = Command::new("arch"); command .env_clear() - .env("PATH", &env_path) - .env("HOME", &env_home); + .env("PATH", env_path) + .env("HOME", env_home); match arch { Architecture::Aarch64(_) => command.arg("-arm64"), @@ -487,10 +487,10 @@ pub fn build_swift_host_native( .args(sources) .arg("-emit-object") .arg("-parse-as-library") - .args(&["-o", dest]); + .args(["-o", dest]); if let Some(objc_header) = objc_header_path { - command.args(&["-import-objc-header", objc_header]); + command.args(["-import-objc-header", objc_header]); } if matches!(opt_level, OptLevel::Optimize) { @@ -641,7 +641,7 @@ pub fn rebuild_host( let source_file = if shared_lib_path.is_some() { cargo_cmd.env("RUSTFLAGS", "-C link-dead-code"); - cargo_cmd.args(&["--bin", "host"]); + cargo_cmd.args(["--bin", "host"]); "src/main.rs" } else { cargo_cmd.arg("--lib"); @@ -673,7 +673,7 @@ pub fn rebuild_host( let mut ld_cmd = Command::new("ld"); - ld_cmd.env_clear().env("PATH", &env_path).args(&[ + ld_cmd.env_clear().env("PATH", &env_path).args([ "-r", "-L", cargo_out_dir.to_str().unwrap(), @@ -693,7 +693,7 @@ pub fn rebuild_host( } else if rust_host_src.exists() { // Compile and link host.rs, if it exists let mut rustc_cmd = Command::new("rustc"); - rustc_cmd.args(&[ + rustc_cmd.args([ rust_host_src.to_str().unwrap(), "-o", rust_host_dest.to_str().unwrap(), @@ -739,7 +739,7 @@ pub fn rebuild_host( let mut ld_cmd = Command::new("ld"); - ld_cmd.env_clear().env("PATH", &env_path).args(&[ + ld_cmd.env_clear().env("PATH", &env_path).args([ "-r", c_host_dest.to_str().unwrap(), rust_host_dest.to_str().unwrap(), @@ -856,9 +856,9 @@ fn link_linux( if let Architecture::X86_32(_) = target.architecture { return Ok(( zig() - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) - .args(&[ + .args([ "-target", "i386-linux-musl", "-lc", @@ -1011,7 +1011,7 @@ fn link_linux( .filter(|&(ref k, _)| k.starts_with("NIX_")) .collect::>(), ) - .args(&[ + .args([ "--gc-sections", "--eh-frame-hdr", "-A", @@ -1021,11 +1021,11 @@ fn link_linux( &*crtn_path.to_string_lossy(), ]) .args(&base_args) - .args(&["-dynamic-linker", ld_linux]) + .args(["-dynamic-linker", ld_linux]) .args(input_paths) // ld.lld requires this argument, and does not accept --arch // .args(&["-L/usr/lib/x86_64-linux-gnu"]) - .args(&[ + .args([ // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496365925 // for discussion and further references "-lc", @@ -1076,7 +1076,7 @@ fn link_macos( // The `-l` flags should go after the `.o` arguments // Don't allow LD_ env vars to affect this .env_clear() - .args(&[ + .args([ // NOTE: we don't do --gc-sections on macOS because the default // macOS linker doesn't support it, but it's a performance // optimization, so if we ever switch to a different linker, @@ -1108,7 +1108,7 @@ fn link_macos( ld_command.arg(roc_link_flag); } - ld_command.args(&[ + ld_command.args([ // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496392274 // for discussion and further references "-lSystem", @@ -1148,7 +1148,7 @@ fn link_macos( Architecture::Aarch64(_) => { ld_child.wait()?; let codesign_child = Command::new("codesign") - .args(&["-s", "-", output_path.to_str().unwrap()]) + .args(["-s", "-", output_path.to_str().unwrap()]) .spawn()?; Ok((codesign_child, output_path)) @@ -1187,7 +1187,7 @@ fn link_wasm32( let child = zig() // .env_clear() // .env("PATH", &env_path) - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) .args([ // include wasi libc @@ -1222,7 +1222,7 @@ fn link_windows( match link_type { LinkType::Dylib => { let child = zig() - .args(&["build-lib"]) + .args(["build-lib"]) .args(input_paths) .args([ "-lc", @@ -1244,7 +1244,7 @@ fn link_windows( } LinkType::Executable => { let child = zig() - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) .args([ "-target", diff --git a/crates/compiler/build/src/program.rs b/crates/compiler/build/src/program.rs index 50ddf387c0..99bb3d62fa 100644 --- a/crates/compiler/build/src/program.rs +++ b/crates/compiler/build/src/program.rs @@ -347,7 +347,7 @@ fn gen_from_mono_module_llvm( // run the debugir https://github.com/vaivaswatha/debugir tool match Command::new("debugir") - .args(&["-instnamer", app_ll_file.to_str().unwrap()]) + .args(["-instnamer", app_ll_file.to_str().unwrap()]) .output() { Ok(_) => {} @@ -369,7 +369,7 @@ fn gen_from_mono_module_llvm( | Architecture::Aarch64(_) | Architecture::Wasm32 => { let ll_to_bc = Command::new("llvm-as") - .args(&[ + .args([ app_ll_dbg_file.to_str().unwrap(), "-o", app_bc_file.to_str().unwrap(), diff --git a/crates/compiler/builtins/build.rs b/crates/compiler/builtins/build.rs index 6b937fa18c..b72aa3673f 100644 --- a/crates/compiler/builtins/build.rs +++ b/crates/compiler/builtins/build.rs @@ -90,7 +90,7 @@ fn generate_object_file(bitcode_path: &Path, zig_object: &str, object_file_name: let mut zig_cmd = zig(); zig_cmd - .current_dir(&bitcode_path) + .current_dir(bitcode_path) .args(["build", zig_object, "-Drelease=true"]); run_command(zig_cmd, 0); @@ -126,7 +126,7 @@ fn generate_bc_file(bitcode_path: &Path, zig_object: &str, file_name: &str) { let mut zig_cmd = zig(); zig_cmd - .current_dir(&bitcode_path) + .current_dir(bitcode_path) .args(["build", zig_object, "-Drelease=true"]); run_command(zig_cmd, 0); @@ -168,7 +168,7 @@ fn copy_zig_builtins_to_target_dir(bitcode_path: &Path) { // recursively copy all the .zig files from this directory, but do *not* recurse into zig-cache/ fn cp_unless_zig_cache(src_dir: &Path, target_dir: &Path) -> io::Result<()> { // Make sure the destination directory exists before we try to copy anything into it. - std::fs::create_dir_all(&target_dir).unwrap_or_else(|err| { + std::fs::create_dir_all(target_dir).unwrap_or_else(|err| { panic!( "Failed to create output library directory for zig bitcode {:?}: {:?}", target_dir, err diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index cab1a7d929..1dde05adab 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -28,7 +28,7 @@ pub struct MemberVariables { /// The member and its signature is defined locally, in the module the store is created for. /// We need to instantiate and introduce this during solving. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ResolvedMemberType(Variable); /// Member type information that needs to be resolved from imports. @@ -56,7 +56,7 @@ impl ResolvePhase for Pending { type MemberType = PendingMemberType; } -#[derive(Default, Debug, Clone, Copy, PartialEq)] +#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)] pub struct Resolved; impl ResolvePhase for Resolved { type MemberType = ResolvedMemberType; diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 20c648125b..24fba9813d 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -1821,7 +1821,7 @@ pub(crate) fn sort_can_defs( .strongly_connected_components_subset(group); debug_assert!( - !group.iter_ones().any(|index| matches!((&defs[index]).as_ref().unwrap().loc_pattern.value, Pattern::AbilityMemberSpecialization{..})), + !group.iter_ones().any(|index| matches!(defs[index].as_ref().unwrap().loc_pattern.value, Pattern::AbilityMemberSpecialization{..})), "A specialization is involved in a recursive cycle - this should not be knowable until solving"); let declaration = if direct_sccs.groups().count() == 1 { diff --git a/crates/compiler/can/src/expr.rs b/crates/compiler/can/src/expr.rs index 4e7e9d13d4..1d7fc6d75b 100644 --- a/crates/compiler/can/src/expr.rs +++ b/crates/compiler/can/src/expr.rs @@ -65,7 +65,7 @@ impl Output { } } -#[derive(Clone, Debug, PartialEq, Copy)] +#[derive(Clone, Debug, PartialEq, Eq, Copy)] pub enum IntValue { I128([u8; 16]), U128([u8; 16]), @@ -345,7 +345,7 @@ pub struct ClosureData { /// /// We distinguish them from closures so we can have better error messages /// during constraint generation. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct AccessorData { pub name: Symbol, pub function_var: Variable, @@ -485,7 +485,7 @@ pub struct Field { pub loc_expr: Box>, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Recursive { NotRecursive = 0, Recursive = 1, @@ -888,7 +888,7 @@ pub fn canonicalize_expr<'a>( var_store, inner_scope, region, - *branch, + branch, &mut output, ) }); @@ -2737,7 +2737,7 @@ fn get_lookup_symbols(expr: &Expr) -> Vec { | Expr::ExpectFx { loc_continuation, .. } => { - stack.push(&(*loc_continuation).value); + stack.push(&loc_continuation.value); // Intentionally ignore the lookups in the nested `expect` condition itself, // because they couldn't possibly influence the outcome of this `expect`! diff --git a/crates/compiler/can/src/operator.rs b/crates/compiler/can/src/operator.rs index 9a46592f0a..fac3cf2b37 100644 --- a/crates/compiler/can/src/operator.rs +++ b/crates/compiler/can/src/operator.rs @@ -79,7 +79,7 @@ fn desugar_value_def<'a>(arena: &'a Bump, def: &'a ValueDef<'a>) -> ValueDef<'a> ann_pattern, ann_type, comment: *comment, - body_pattern: *body_pattern, + body_pattern, body_expr: desugar_expr(arena, body_expr), }, Expect { diff --git a/crates/compiler/collections/src/vec_set.rs b/crates/compiler/collections/src/vec_set.rs index d5fd02a63c..8415bbc102 100644 --- a/crates/compiler/collections/src/vec_set.rs +++ b/crates/compiler/collections/src/vec_set.rs @@ -1,6 +1,6 @@ use std::{borrow::Borrow, iter::FromIterator}; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct VecSet { elements: Vec, } diff --git a/crates/compiler/derive_key/src/lib.rs b/crates/compiler/derive_key/src/lib.rs index 65a0062a7d..a994a622e3 100644 --- a/crates/compiler/derive_key/src/lib.rs +++ b/crates/compiler/derive_key/src/lib.rs @@ -25,7 +25,7 @@ use hash::{FlatHash, FlatHashKey}; use roc_module::symbol::Symbol; use roc_types::subs::{Subs, Variable}; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum DeriveError { /// Unbound variable present in the type-to-derive. It may be possible to derive for this type /// once the unbound variable is resolved. diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 9fcdb4bf12..308b1075c3 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -166,8 +166,8 @@ impl<'a> Formattable for TypeAnnotation<'a> { Wildcard | Inferred | BoundVariable(_) | Malformed(_) => false, Function(args, result) => { - (&result.value).is_multiline() - || args.iter().any(|loc_arg| (&loc_arg.value).is_multiline()) + result.value.is_multiline() + || args.iter().any(|loc_arg| loc_arg.value.is_multiline()) } Apply(_, _, args) => args.iter().any(|loc_arg| loc_arg.value.is_multiline()), As(lhs, _, _) => lhs.value.is_multiline(), @@ -226,7 +226,7 @@ impl<'a> Formattable for TypeAnnotation<'a> { buf.newline(); } - (&argument.value).format_with_options( + argument.value.format_with_options( buf, Parens::InFunctionType, Newlines::No, @@ -251,7 +251,7 @@ impl<'a> Formattable for TypeAnnotation<'a> { buf.push_str("->"); buf.spaces(1); - (&ret.value).format_with_options(buf, Parens::InFunctionType, Newlines::No, indent); + ret.value.format_with_options(buf, Parens::InFunctionType, Newlines::No, indent); if needs_parens { buf.push(')') @@ -275,7 +275,7 @@ impl<'a> Formattable for TypeAnnotation<'a> { for argument in *arguments { buf.spaces(1); - (&argument.value).format_with_options( + argument.value.format_with_options( buf, Parens::InApply, Newlines::No, @@ -497,7 +497,7 @@ impl<'a> Formattable for Tag<'a> { use self::Tag::*; match self { - Apply { args, .. } => args.iter().any(|arg| (&arg.value).is_multiline()), + Apply { args, .. } => args.iter().any(|arg| arg.value.is_multiline()), Tag::SpaceBefore(_, _) | Tag::SpaceAfter(_, _) => true, Malformed(text) => text.chars().any(|c| c == '\n'), } diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index f5395e6d24..6cb1709863 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -542,7 +542,7 @@ fn fmt_binops<'a, 'buf>( indent: u16, ) { let is_multiline = part_of_multi_line_binops - || (&loc_right_side.value).is_multiline() + || loc_right_side.value.is_multiline() || lefts.iter().any(|(expr, _)| expr.value.is_multiline()); for (loc_left_side, loc_binop) in lefts { @@ -1045,7 +1045,7 @@ fn fmt_closure<'a, 'buf>( buf.push_str("->"); - let is_multiline = (&loc_ret.value).is_multiline(); + let is_multiline = loc_ret.value.is_multiline(); // If the body is multiline, go down a line and indent. let body_indent = if is_multiline { @@ -1156,7 +1156,7 @@ fn fmt_backpassing<'a, 'buf>( buf.push_str("<-"); - let is_multiline = (&loc_ret.value).is_multiline(); + let is_multiline = loc_ret.value.is_multiline(); // If the body is multiline, go down a line and indent. let body_indent = if is_multiline { diff --git a/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs b/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs index f6af4bd81a..5461c54fd0 100644 --- a/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs +++ b/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs @@ -19,7 +19,7 @@ macro_rules! disassembler_test { // TODO: Not sure if there is a better way to merge these together, // but I like the end use of this a lot better than the old tests. ($assemble_fn: expr, $format_fn: expr) => {{ - use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers; + use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers; let arena = bumpalo::Bump::new(); let (mut buf, cs) = setup_capstone_and_arena(&arena); $assemble_fn(&mut buf); diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index fce88a8178..37ee037557 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -1011,7 +1011,7 @@ impl Assembler for X86_64Assembler { #[inline(always)] fn call(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>, fn_name: String) { - buf.extend(&[0xE8, 0x00, 0x00, 0x00, 0x00]); + buf.extend([0xE8, 0x00, 0x00, 0x00, 0x00]); relocs.push(Relocation::LinkedFunction { offset: buf.len() as u64 - 4, name: fn_name, @@ -1478,7 +1478,7 @@ fn binop_reg64_reg64( let rex = add_reg_extension(src, rex); let dst_mod = dst as u8 % 8; let src_mod = (src as u8 % 8) << 3; - buf.extend(&[rex, op_code, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, op_code, 0xC0 | dst_mod | src_mod]); } #[inline(always)] @@ -1493,7 +1493,7 @@ fn extended_binop_reg64_reg64( let rex = add_reg_extension(src, rex); let dst_mod = dst as u8 % 8; let src_mod = (src as u8 % 8) << 3; - buf.extend(&[rex, op_code1, op_code2, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, op_code1, op_code2, 0xC0 | dst_mod | src_mod]); } // Below here are the functions for all of the assembly instructions. @@ -1508,8 +1508,8 @@ fn add_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xC0 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xC0 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `ADD r/m64,r64` -> Add r64 to r/m64. @@ -1547,7 +1547,7 @@ fn addsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1555,7 +1555,7 @@ fn addsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1567,7 +1567,7 @@ fn addss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1575,7 +1575,7 @@ fn addss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1587,7 +1587,7 @@ fn mulsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1595,7 +1595,7 @@ fn mulsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1607,7 +1607,7 @@ fn divss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1615,7 +1615,7 @@ fn divss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1627,7 +1627,7 @@ fn divsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1635,7 +1635,7 @@ fn divsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1647,7 +1647,7 @@ fn mulss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1655,7 +1655,7 @@ fn mulss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1667,7 +1667,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0x66, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1675,7 +1675,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0x66, 0x0F, 0x54, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0x66, 0x0F, 0x54, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1684,7 +1684,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl fn and_reg64_imm8(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i8) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; - buf.extend(&[rex, 0x83, 0xE0 | dst_mod, imm as u8]); + buf.extend([rex, 0x83, 0xE0 | dst_mod, imm as u8]); } /// `CMOVL r64,r/m64` -> Move if less (SF≠ OF). @@ -1694,7 +1694,7 @@ fn cmovl_reg64_reg64(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, src: X86_64Ge let rex = add_rm_extension(src, rex); let dst_mod = (dst as u8 % 8) << 3; let src_mod = src as u8 % 8; - buf.extend(&[rex, 0x0F, 0x4C, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, 0x0F, 0x4C, 0xC0 | dst_mod | src_mod]); } /// `CMP r/m64,i32` -> Compare i32 to r/m64. @@ -1703,8 +1703,8 @@ fn cmp_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xF8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xF8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `CMP r/m64,r64` -> Compare r64 to r/m64. @@ -1738,7 +1738,7 @@ fn mul_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { rex |= REX_PREFIX_B; } - buf.extend(&[rex, 0xF7, 0b1110_0000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1110_0000 | (src as u8 % 8)]); } /// `IDIV r/m64` -> Signed divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder. @@ -1756,9 +1756,9 @@ fn idiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { // // The CQO instruction (available in 64-bit mode only) copies the sign (bit 63) // of the value in the RAX register into every bit position in the RDX register - buf.extend(&[0x48, 0x99]); + buf.extend([0x48, 0x99]); - buf.extend(&[rex, 0xF7, 0b1111_1000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1111_1000 | (src as u8 % 8)]); } /// `DIV r/m64` -> Unsigned divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder. @@ -1776,10 +1776,10 @@ fn udiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { // // The CQO instruction (available in 64-bit mode only) copies the sign (bit 63) // of the value in the RAX register into every bit position in the RDX register - buf.extend(&[0x48, 0x99]); + buf.extend([0x48, 0x99]); // adds a cqo (convert doubleword to quadword) - buf.extend(&[rex, 0xF7, 0b1111_0000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1111_0000 | (src as u8 % 8)]); } /// Jump near, relative, RIP = RIP + 32-bit displacement sign extended to 64-bits. @@ -1787,7 +1787,7 @@ fn udiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { fn jmp_imm32(buf: &mut Vec<'_, u8>, imm: i32) { buf.reserve(5); buf.push(0xE9); - buf.extend(&imm.to_le_bytes()); + buf.extend(imm.to_le_bytes()); } /// Jump near if not equal (ZF=0). @@ -1796,7 +1796,7 @@ fn jne_imm32(buf: &mut Vec<'_, u8>, imm: i32) { buf.reserve(6); buf.push(0x0F); buf.push(0x85); - buf.extend(&imm.to_le_bytes()); + buf.extend(imm.to_le_bytes()); } /// `MOV r/m64, imm32` -> Move imm32 sign extended to 64-bits to r/m64. @@ -1805,8 +1805,8 @@ fn mov_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0xC7, 0xC0 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0xC7, 0xC0 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `MOV r64, imm64` -> Move imm64 to r64. @@ -1818,8 +1818,8 @@ fn mov_reg64_imm64(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i64) { let rex = add_opcode_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(10); - buf.extend(&[rex, 0xB8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0xB8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } } @@ -1854,12 +1854,12 @@ fn mov_base64_offset32_reg64( let src_mod = (src as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(8); - buf.extend(&[rex, 0x89, 0x80 | src_mod | base_mod]); + buf.extend([rex, 0x89, 0x80 | src_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOV r64,r/m64` -> Move r/m64 to r64, where m64 references a base + offset. @@ -1875,12 +1875,12 @@ fn mov_reg64_base64_offset32( let dst_mod = (dst as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(8); - buf.extend(&[rex, 0x8B, 0x80 | dst_mod | base_mod]); + buf.extend([rex, 0x8B, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVZX r64,r/m8` -> Move r/m8 with zero extention to r64, where m8 references a base + offset. @@ -1896,12 +1896,12 @@ fn movzx_reg64_base8_offset32( let dst_mod = (dst as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(9); - buf.extend(&[rex, 0x0F, 0xB6, 0x80 | dst_mod | base_mod]); + buf.extend([rex, 0x0F, 0xB6, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD xmm1,xmm2` -> Move scalar double-precision floating-point value from xmm2 to xmm1 register. @@ -1922,7 +1922,7 @@ fn raw_movsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1930,7 +1930,7 @@ fn raw_movsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1952,7 +1952,7 @@ fn raw_movss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1960,7 +1960,7 @@ fn raw_movss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1970,12 +1970,12 @@ fn movss_freg32_rip_offset32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, offset: let dst_mod = dst as u8 % 8; if dst as u8 > 7 { buf.reserve(9); - buf.extend(&[0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } else { buf.reserve(8); - buf.extend(&[0xF3, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF3, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } // `MOVSD xmm, m64` -> Load scalar double-precision floating-point value from m64 to xmm register. @@ -1984,12 +1984,12 @@ fn movsd_freg64_rip_offset32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, offset: let dst_mod = dst as u8 % 8; if dst as u8 > 7 { buf.reserve(9); - buf.extend(&[0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } else { buf.reserve(8); - buf.extend(&[0xF2, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF2, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD r/m64,xmm1` -> Move xmm1 to r/m64. where m64 references the base pointer. @@ -2009,12 +2009,12 @@ fn movsd_base64_offset32_freg64( if src as u8 > 7 || base as u8 > 7 { buf.push(rex); } - buf.extend(&[0x0F, 0x11, 0x80 | src_mod | base_mod]); + buf.extend([0x0F, 0x11, 0x80 | src_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD xmm1,r/m64` -> Move r/m64 to xmm1. where m64 references the base pointer. @@ -2034,12 +2034,12 @@ fn movsd_freg64_base64_offset32( if dst as u8 > 7 || base as u8 > 7 { buf.push(rex); } - buf.extend(&[0x0F, 0x10, 0x80 | dst_mod | base_mod]); + buf.extend([0x0F, 0x10, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `NEG r/m64` -> Two's complement negate r/m64. @@ -2047,7 +2047,7 @@ fn movsd_freg64_base64_offset32( fn neg_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let rex = add_rm_extension(reg, REX_W); let reg_mod = reg as u8 % 8; - buf.extend(&[rex, 0xF7, 0xD8 | reg_mod]); + buf.extend([rex, 0xF7, 0xD8 | reg_mod]); } // helper function for `set*` instructions @@ -2060,10 +2060,10 @@ fn set_reg64_help(op_code: u8, buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; use X86_64GeneralReg::*; match reg { - RAX | RCX | RDX | RBX => buf.extend(&[0x0F, op_code, 0xC0 | reg_mod]), - RSP | RBP | RSI | RDI => buf.extend(&[REX, 0x0F, op_code, 0xC0 | reg_mod]), + RAX | RCX | RDX | RBX => buf.extend([0x0F, op_code, 0xC0 | reg_mod]), + RSP | RBP | RSI | RDI => buf.extend([REX, 0x0F, op_code, 0xC0 | reg_mod]), R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 => { - buf.extend(&[REX | 1, 0x0F, op_code, 0xC0 | reg_mod]) + buf.extend([REX | 1, 0x0F, op_code, 0xC0 | reg_mod]) } } @@ -2085,7 +2085,7 @@ fn cvtsi2_help( let mod1 = (dst.value() % 8) << 3; let mod2 = src.value() % 8; - buf.extend(&[op_code1, rex, 0x0F, op_code2, 0xC0 | mod1 | mod2]) + buf.extend([op_code1, rex, 0x0F, op_code2, 0xC0 | mod1 | mod2]) } #[inline(always)] @@ -2099,7 +2099,7 @@ fn cvtsx2_help( let mod1 = (dst.value() % 8) << 3; let mod2 = src.value() % 8; - buf.extend(&[op_code1, 0x0F, op_code2, 0xC0 | mod1 | mod2]) + buf.extend([op_code1, 0x0F, op_code2, 0xC0 | mod1 | mod2]) } /// `SETE r/m64` -> Set Byte on Condition - zero/equal (ZF=1) @@ -2183,8 +2183,8 @@ fn sub_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xE8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xE8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `SUB r/m64,r64` -> Sub r64 to r/m64. @@ -2199,7 +2199,7 @@ fn pop_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; if reg as u8 > 7 { let rex = add_opcode_extension(reg, REX); - buf.extend(&[rex, 0x58 | reg_mod]); + buf.extend([rex, 0x58 | reg_mod]); } else { buf.push(0x58 | reg_mod); } @@ -2211,7 +2211,7 @@ fn push_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; if reg as u8 > 7 { let rex = add_opcode_extension(reg, REX); - buf.extend(&[rex, 0x50 | reg_mod]); + buf.extend([rex, 0x50 | reg_mod]); } else { buf.push(0x50 | reg_mod); } diff --git a/crates/compiler/gen_dev/src/lib.rs b/crates/compiler/gen_dev/src/lib.rs index bcdcf51862..128d689ea5 100644 --- a/crates/compiler/gen_dev/src/lib.rs +++ b/crates/compiler/gen_dev/src/lib.rs @@ -156,7 +156,7 @@ trait Backend<'a> { let module_id = env.module_id; let ident_ids = interns.all_ident_ids.get_mut(&module_id).unwrap(); - rc_proc_gen.expand_refcount_stmt(ident_ids, layout, modify, *following) + rc_proc_gen.expand_refcount_stmt(ident_ids, layout, modify, following) }; for spec in new_specializations.into_iter() { diff --git a/crates/compiler/gen_dev/src/object_builder.rs b/crates/compiler/gen_dev/src/object_builder.rs index 85cb925361..51b90f7735 100644 --- a/crates/compiler/gen_dev/src/object_builder.rs +++ b/crates/compiler/gen_dev/src/object_builder.rs @@ -421,7 +421,7 @@ fn build_proc<'a, B: Backend<'a>>( } Relocation::LinkedFunction { offset, name } => { // If the symbol is an undefined roc function, we need to add it here. - if output.symbol_id(name.as_bytes()) == None && name.starts_with("roc_") { + if output.symbol_id(name.as_bytes()).is_none() && name.starts_with("roc_") { let builtin_symbol = Symbol { name: name.as_bytes().to_vec(), value: 0, @@ -435,7 +435,7 @@ fn build_proc<'a, B: Backend<'a>>( output.add_symbol(builtin_symbol); } // If the symbol is an undefined reference counting procedure, we need to add it here. - if output.symbol_id(name.as_bytes()) == None { + if output.symbol_id(name.as_bytes()).is_none() { for (sym, rc_name) in rc_proc_names.iter() { if name == rc_name { let section_id = output.add_section( diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index 73126c90b1..a811989b95 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -126,7 +126,7 @@ impl<'ctx> Iterator for FunctionIterator<'ctx> { } } -#[derive(Default, Debug, Clone, PartialEq)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct Scope<'a, 'ctx> { symbols: ImMap, BasicValueEnum<'ctx>)>, pub top_level_thunks: ImMap, FunctionValue<'ctx>)>, @@ -973,7 +973,7 @@ pub fn build_exp_literal<'a, 'ctx, 'env>( _ => unreachable!("incorrect small_str_bytes"), } } else { - let ptr = define_global_str_literal_ptr(env, *str_literal); + let ptr = define_global_str_literal_ptr(env, str_literal); let number_of_elements = env.ptr_int().const_int(str_literal.len() as u64, false); let alloca = @@ -4554,7 +4554,7 @@ fn build_procedures_help<'a, 'ctx, 'env>( fn_val.print_to_stderr(); if let Some(app_ll_file) = debug_output_file { - env.module.print_to_file(&app_ll_file).unwrap(); + env.module.print_to_file(app_ll_file).unwrap(); panic!( r"😱 LLVM errors when defining function {:?}; I wrote the full LLVM IR to {:?}", diff --git a/crates/compiler/gen_llvm/src/llvm/refcounting.rs b/crates/compiler/gen_llvm/src/llvm/refcounting.rs index 25cbea9e1c..7480fe84d5 100644 --- a/crates/compiler/gen_llvm/src/llvm/refcounting.rs +++ b/crates/compiler/gen_llvm/src/llvm/refcounting.rs @@ -1366,7 +1366,7 @@ fn union_layout_tags<'a>( match union_layout { NullableWrapped { other_tags: tags, .. - } => *tags, + } => tags, NullableUnwrapped { other_fields, .. } => arena.alloc([*other_fields]), NonNullableUnwrapped(fields) => arena.alloc([*fields]), Recursive(tags) => tags, diff --git a/crates/compiler/gen_wasm/src/backend.rs b/crates/compiler/gen_wasm/src/backend.rs index 1b8b26f3d7..53f6a48981 100644 --- a/crates/compiler/gen_wasm/src/backend.rs +++ b/crates/compiler/gen_wasm/src/backend.rs @@ -1237,7 +1237,7 @@ impl<'a> WasmBackend<'a> { } CallType::HigherOrder(higher_order_lowlevel) => { - call_higher_order_lowlevel(self, ret_sym, ret_layout, *higher_order_lowlevel) + call_higher_order_lowlevel(self, ret_sym, ret_layout, higher_order_lowlevel) } CallType::Foreign { diff --git a/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs b/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs index 5adb833a60..d4b1ef3c36 100644 --- a/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs +++ b/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs @@ -69,7 +69,7 @@ impl std::fmt::Debug for VmBlock<'_> { /// Rust representation matches Wasm encoding. /// It's an error to specify alignment higher than the "natural" alignment of the instruction #[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)] pub enum Align { Bytes1 = 0, Bytes2 = 1, @@ -111,7 +111,7 @@ impl From for Align { } } -#[derive(Debug, Clone, PartialEq, Copy)] +#[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum VmSymbolState { /// Value doesn't exist yet NotYetPushed, diff --git a/crates/compiler/gen_wasm/src/wasm_module/sections.rs b/crates/compiler/gen_wasm/src/wasm_module/sections.rs index dfb69bc7dd..66f86eb175 100644 --- a/crates/compiler/gen_wasm/src/wasm_module/sections.rs +++ b/crates/compiler/gen_wasm/src/wasm_module/sections.rs @@ -551,7 +551,7 @@ impl Parse<()> for RefType { } } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct TableType { pub ref_type: RefType, pub limits: Limits, @@ -659,7 +659,7 @@ impl Serialize for TableSection { * *******************************************************************/ -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Limits { Min(u32), MinMax(u32, u32), @@ -749,7 +749,7 @@ section_impl!(MemorySection, SectionId::Memory); * *******************************************************************/ -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct GlobalType { pub value_type: ValueType, pub is_mutable: bool, diff --git a/crates/compiler/load/build.rs b/crates/compiler/load/build.rs index 204f6af893..e13232efc8 100644 --- a/crates/compiler/load/build.rs +++ b/crates/compiler/load/build.rs @@ -44,7 +44,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) { println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap()); let mut output_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - output_path.extend(&[filename]); + output_path.extend([filename]); output_path.set_extension("dat"); #[cfg(not(windows))] @@ -64,7 +64,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) { fn write_types_for_module_dummy(output_path: &Path) { // write out a dummy file - std::fs::write(output_path, &[]).unwrap(); + std::fs::write(output_path, []).unwrap(); } #[cfg(not(windows))] @@ -107,7 +107,7 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path: let abilities = module.abilities_store; let solved_implementations = module.resolved_implementations; - let mut file = std::fs::File::create(&output_path).unwrap(); + let mut file = std::fs::File::create(output_path).unwrap(); let type_state = TypeState { subs, diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 31d280dca7..9bbf5c37d1 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3100,7 +3100,7 @@ fn load_platform_module<'a>( ) -> Result, LoadingProblem<'a>> { let module_start_time = Instant::now(); let file_io_start = Instant::now(); - let file = fs::read(&filename); + let file = fs::read(filename); let file_io_duration = file_io_start.elapsed(); match file { diff --git a/crates/compiler/module/src/called_via.rs b/crates/compiler/module/src/called_via.rs index bc314e0eec..17017a1917 100644 --- a/crates/compiler/module/src/called_via.rs +++ b/crates/compiler/module/src/called_via.rs @@ -70,7 +70,7 @@ pub enum ArgSide { Right, } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Associativity { /// left-associative operators: /// diff --git a/crates/compiler/mono/src/code_gen_help/mod.rs b/crates/compiler/mono/src/code_gen_help/mod.rs index a9532aed88..07a27df060 100644 --- a/crates/compiler/mono/src/code_gen_help/mod.rs +++ b/crates/compiler/mono/src/code_gen_help/mod.rs @@ -471,7 +471,7 @@ impl<'a> CodeGenHelp<'a> { ) -> (bool, Vec<'a, Option>) { use UnionLayout::*; match union { - NonRecursive(_) => return (false, bumpalo::vec![in self.arena]), + NonRecursive(_) => (false, bumpalo::vec![in self.arena]), Recursive(tags) => self.union_tail_recursion_fields_help(tags), diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 0dfdf0cdf8..80faf64dda 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -284,7 +284,7 @@ impl AbilityAliases { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CapturedSymbols<'a> { None, Captured(&'a [(Symbol, Variable)]), @@ -317,7 +317,7 @@ pub struct Proc<'a> { pub host_exposed_layouts: HostExposedLayouts<'a>, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum HostExposedLayouts<'a> { NotHostExposed, HostExposed { @@ -326,13 +326,13 @@ pub enum HostExposedLayouts<'a> { }, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum SelfRecursive { NotSelfRecursive, SelfRecursive(JoinPointId), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Parens { NotNeeded, InTypeParam, @@ -1575,7 +1575,7 @@ impl<'a, 'i> Env<'a, 'i> { #[derive(Clone, Debug, PartialEq, Copy, Eq, Hash)] pub struct JoinPointId(pub Symbol); -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Param<'a> { pub symbol: Symbol, pub borrow: bool, @@ -1659,7 +1659,7 @@ pub enum Stmt<'a> { } /// in the block below, symbol `scrutinee` is assumed be be of shape `tag_id` -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum BranchInfo<'a> { None, Constructor { @@ -1702,7 +1702,7 @@ impl<'a> BranchInfo<'a> { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ModifyRc { /// Increment a reference count Inc(Symbol, u64), @@ -1848,7 +1848,7 @@ impl<'a> Call<'a> { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CallSpecId { id: u32, } @@ -1863,7 +1863,7 @@ impl CallSpecId { pub const BACKEND_DUMMY: Self = Self { id: 0 }; } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct UpdateModeId { id: u32, } @@ -1878,7 +1878,7 @@ impl UpdateModeId { pub const BACKEND_DUMMY: Self = Self { id: 0 }; } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct UpdateModeIds { next: u32, } @@ -1914,7 +1914,7 @@ pub enum CallType<'a> { HigherOrder(&'a HigherOrderLowLevel<'a>), } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct PassedFunction<'a> { /// name of the top-level function that is passed as an argument /// e.g. in `List.map xs Num.abs` this would be `Num.abs` @@ -1931,7 +1931,7 @@ pub struct PassedFunction<'a> { pub owns_captured_environment: bool, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct HigherOrderLowLevel<'a> { pub op: crate::low_level::HigherOrder, @@ -7009,7 +7009,7 @@ fn substitute_in_call<'a>( } => substitute(subs, name.name()).map(|new| CallType::ByName { name: name.replace_name(new), arg_layouts, - ret_layout: *ret_layout, + ret_layout, specialization_id: *specialization_id, }), CallType::Foreign { .. } => None, @@ -7158,7 +7158,7 @@ fn substitute_in_expr<'a>( } => match substitute(subs, *structure) { Some(structure) => Some(StructAtIndex { index: *index, - field_layouts: *field_layouts, + field_layouts, structure, }), None => None, diff --git a/crates/compiler/mono/src/low_level.rs b/crates/compiler/mono/src/low_level.rs index 3856e95ba9..ddad554c81 100644 --- a/crates/compiler/mono/src/low_level.rs +++ b/crates/compiler/mono/src/low_level.rs @@ -1,6 +1,6 @@ use roc_module::symbol::Symbol; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum HigherOrder { ListMap { xs: Symbol, diff --git a/crates/compiler/mono/src/reset_reuse.rs b/crates/compiler/mono/src/reset_reuse.rs index feec4fe8e4..6b2447c250 100644 --- a/crates/compiler/mono/src/reset_reuse.rs +++ b/crates/compiler/mono/src/reset_reuse.rs @@ -128,7 +128,7 @@ fn function_s<'a, 'i>( remainder, } => { let id = *id; - let body: &Stmt = *body; + let body: &Stmt = body; let new_body = function_s(env, w, c, body); let new_join = if std::ptr::eq(body, new_body) || body == new_body { @@ -179,7 +179,7 @@ fn function_s<'a, 'i>( arena.alloc(new_switch) } Refcounting(op, continuation) => { - let continuation: &Stmt = *continuation; + let continuation: &Stmt = continuation; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { @@ -198,7 +198,7 @@ fn function_s<'a, 'i>( layouts, remainder, } => { - let continuation: &Stmt = *remainder; + let continuation: &Stmt = remainder; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { @@ -223,7 +223,7 @@ fn function_s<'a, 'i>( layouts, remainder, } => { - let continuation: &Stmt = *remainder; + let continuation: &Stmt = remainder; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 16ce506c3d..1ec6995a8f 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -109,7 +109,7 @@ pub enum StrSegment<'a> { Interpolated(Loc<&'a Expr<'a>>), // e.g. (name) in "Hi, \(name)!" } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum EscapedChar { Newline, // \n Tab, // \t @@ -581,7 +581,7 @@ pub enum AssignedField<'a, Val> { Malformed(&'a str), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CommentOrNewline<'a> { Newline, LineComment(&'a str), @@ -880,7 +880,7 @@ impl<'a, T> Collection<'a, T> { pub fn final_comments(&self) -> &'a [CommentOrNewline<'a>] { if let Some(final_comments) = self.final_comments { - *final_comments + final_comments } else { &[] } diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 757af05a69..a51d01ba64 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -546,7 +546,7 @@ fn numeric_negate_expression<'a, T>( expr: Loc>, spaces: &'a [CommentOrNewline<'a>], ) -> Loc> { - debug_assert_eq!(state.bytes().get(0), Some(&b'-')); + debug_assert_eq!(state.bytes().first(), Some(&b'-')); // for overflow reasons, we must make the unary minus part of the number literal. let start = state.pos(); let region = Region::new(start, expr.region.end()); @@ -941,7 +941,7 @@ fn parse_defs_end<'a>( ann_type: arena.alloc(*ann_type), comment, body_pattern: arena.alloc(loc_pattern), - body_expr: *arena.alloc(loc_def_expr), + body_expr: arena.alloc(loc_def_expr), }; let region = @@ -980,7 +980,7 @@ fn parse_defs_end<'a>( ann_type: arena.alloc(*ann_type), comment, body_pattern: arena.alloc(loc_pattern), - body_expr: *arena.alloc(loc_def_expr), + body_expr: arena.alloc(loc_def_expr), }; let region = @@ -1904,7 +1904,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result Err(()), Expr::Str(string) => Ok(Pattern::StrLiteral(*string)), - Expr::SingleQuote(string) => Ok(Pattern::SingleQuote(*string)), + Expr::SingleQuote(string) => Ok(Pattern::SingleQuote(string)), Expr::MalformedIdent(string, _problem) => Ok(Pattern::Malformed(string)), } } diff --git a/crates/compiler/parse/src/header.rs b/crates/compiler/parse/src/header.rs index 4fd3266e65..8c09f2daf1 100644 --- a/crates/compiler/parse/src/header.rs +++ b/crates/compiler/parse/src/header.rs @@ -52,7 +52,7 @@ pub enum VersionComparison { DisallowsEqual, } -#[derive(Copy, Clone, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct PackageName<'a>(&'a str); impl<'a> PackageName<'a> { @@ -160,7 +160,7 @@ pub struct HostedHeader<'a> { pub after_with: &'a [CommentOrNewline<'a>], } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum To<'a> { ExistingPackage(&'a str), NewPackage(PackageName<'a>), @@ -262,7 +262,7 @@ pub struct TypedIdent<'a> { pub ann: Loc>, } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct PackageEntry<'a> { pub shorthand: &'a str, pub spaces_after_shorthand: &'a [CommentOrNewline<'a>], diff --git a/crates/compiler/problem/src/can.rs b/crates/compiler/problem/src/can.rs index 627b97a1ad..c97c78a075 100644 --- a/crates/compiler/problem/src/can.rs +++ b/crates/compiler/problem/src/can.rs @@ -7,19 +7,19 @@ use roc_parse::pattern::PatternType; use roc_region::all::{Loc, Region}; use roc_types::types::AliasKind; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CycleEntry { pub symbol: Symbol, pub symbol_region: Region, pub expr_region: Region, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum BadPattern { Unsupported(PatternType), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ShadowKind { Variable, Alias(Symbol), @@ -28,7 +28,7 @@ pub enum ShadowKind { } /// Problems that can occur in the course of canonicalization. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Problem { UnusedDef(Symbol, Region), UnusedImport(Symbol, Region), @@ -190,13 +190,13 @@ pub enum Problem { }, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum ExtensionTypeKind { Record, TagUnion, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum PrecedenceProblem { BothNonAssociative(Region, Loc, Loc), } @@ -245,7 +245,7 @@ pub enum FloatErrorKind { IntSuffix, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum RuntimeError { Shadowing { original_region: Region, @@ -368,7 +368,7 @@ impl RuntimeError { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum MalformedPatternProblem { MalformedInt, MalformedFloat, diff --git a/crates/compiler/solve/src/ability.rs b/crates/compiler/solve/src/ability.rs index 130dcf3447..fc85ba7b94 100644 --- a/crates/compiler/solve/src/ability.rs +++ b/crates/compiler/solve/src/ability.rs @@ -31,7 +31,7 @@ pub enum AbilityImplError { } /// Indexes a requested deriving of an ability for an opaque type. -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct RequestedDeriveKey { pub opaque: Symbol, pub ability: Symbol, diff --git a/crates/compiler/solve_problem/src/lib.rs b/crates/compiler/solve_problem/src/lib.rs index e1de64944d..1e52243999 100644 --- a/crates/compiler/solve_problem/src/lib.rs +++ b/crates/compiler/solve_problem/src/lib.rs @@ -51,7 +51,7 @@ pub enum Unfulfilled { }, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum UnderivableReason { NotABuiltin, /// The surface type is not derivable @@ -60,7 +60,7 @@ pub enum UnderivableReason { NestedNotDerivable(ErrorType, NotDerivableContext), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableContext { NoContext, Function, @@ -70,12 +70,12 @@ pub enum NotDerivableContext { Eq(NotDerivableEq), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableDecode { OptionalRecordField(Lowercase), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableEq { FloatingPoint, } diff --git a/crates/compiler/test_gen/src/helpers/llvm.rs b/crates/compiler/test_gen/src/helpers/llvm.rs index 896c050d72..70856acc73 100644 --- a/crates/compiler/test_gen/src/helpers/llvm.rs +++ b/crates/compiler/test_gen/src/helpers/llvm.rs @@ -341,11 +341,11 @@ fn annotate_with_debug_info<'ctx>( let app_bc_file = "/tmp/roc-debugir.bc"; // write the ll code to a file, so we can modify it - module.print_to_file(&app_ll_file).unwrap(); + module.print_to_file(app_ll_file).unwrap(); // run the debugir https://github.com/vaivaswatha/debugir tool match Command::new("debugir") - .args(&["-instnamer", app_ll_file]) + .args(["-instnamer", app_ll_file]) .output() { Ok(_) => {} @@ -361,11 +361,11 @@ fn annotate_with_debug_info<'ctx>( } Command::new("llvm-as") - .args(&[app_dbg_ll_file, "-o", app_bc_file]) + .args([app_dbg_ll_file, "-o", app_bc_file]) .output() .unwrap(); - inkwell::module::Module::parse_bitcode_from_path(&app_bc_file, context).unwrap() + inkwell::module::Module::parse_bitcode_from_path(app_bc_file, context).unwrap() } #[allow(dead_code)] @@ -459,7 +459,7 @@ fn llvm_module_to_wasm_file( let output = zig() .current_dir(dir_path) - .args(&[ + .args([ "wasm-ld", concat!(env!("OUT_DIR"), "/wasm_test_platform.wasm"), test_a_path.to_str().unwrap(), diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 4436c815f7..3c767b9509 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -174,7 +174,7 @@ fn verify_procedures<'a>( use std::process::Command; let is_tracked = Command::new("git") - .args(&["ls-files", "--error-unmatch", &path]) + .args(["ls-files", "--error-unmatch", &path]) .output() .unwrap(); @@ -186,7 +186,7 @@ fn verify_procedures<'a>( } let has_changes = Command::new("git") - .args(&["diff", "--color=always", &path]) + .args(["diff", "--color=always", &path]) .output() .unwrap(); diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index 67ff778cd6..bfe2126d98 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -30,7 +30,7 @@ static EMPTY_TAG_UNION: &str = "[]"; /// List (List I64) /// /// Otherwise, parens are unnecessary. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Parens { InFn, InTypeParam, diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index 50fbfb6af1..54410fe90e 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -2250,7 +2250,7 @@ pub enum Reason { }, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum Category { Lookup(Symbol), CallResult(Option, CalledVia), @@ -2334,7 +2334,7 @@ impl AliasKind { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct AliasVar { pub name: Lowercase, pub var: Variable, diff --git a/crates/editor/src/editor/main.rs b/crates/editor/src/editor/main.rs index b345815db5..1095bcec47 100644 --- a/crates/editor/src/editor/main.rs +++ b/crates/editor/src/editor/main.rs @@ -507,7 +507,7 @@ fn read_main_roc_file(project_dir_path_opt: Option<&Path>) -> (PathBuf, String) if let Some(&roc_file_name) = roc_file_names.first() { let full_roc_file_path = project_dir_path.join(roc_file_name); - let file_as_str = std::fs::read_to_string(&Path::new(&full_roc_file_path)) + let file_as_str = std::fs::read_to_string(Path::new(&full_roc_file_path)) .unwrap_or_else(|err| panic!("In the provided project {:?}, I found the roc file {:?}, but I failed to read it: {}", &project_dir_path, full_roc_file_path, err)); (full_roc_file_path, file_as_str) diff --git a/crates/editor/src/graphics/lowlevel/buffer.rs b/crates/editor/src/graphics/lowlevel/buffer.rs index 76f26e0480..593309460e 100644 --- a/crates/editor/src/graphics/lowlevel/buffer.rs +++ b/crates/editor/src/graphics/lowlevel/buffer.rs @@ -42,7 +42,7 @@ impl QuadBufferBuilder { max_y: f32, color: [f32; 4], ) -> Self { - self.vertex_data.extend(&[ + self.vertex_data.extend([ Vertex { position: (min_x, min_y).into(), color, @@ -60,7 +60,7 @@ impl QuadBufferBuilder { color, }, ]); - self.index_data.extend(&[ + self.index_data.extend([ self.current_quad * 4, self.current_quad * 4 + 1, self.current_quad * 4 + 2, diff --git a/crates/highlight/src/highlight_parser.rs b/crates/highlight/src/highlight_parser.rs index f096cf7cec..2943a14eec 100644 --- a/crates/highlight/src/highlight_parser.rs +++ b/crates/highlight/src/highlight_parser.rs @@ -232,8 +232,7 @@ pub mod highlight_tests { node_to_string_w_children( *highlight_defs("a = 0", &mut mark_node_pool) - .unwrap() - .get(0) + .unwrap().first() .unwrap(), &mut str_buffer, &mark_node_pool, diff --git a/crates/linker/src/elf.rs b/crates/linker/src/elf.rs index 29ac545944..3b59d08bd0 100644 --- a/crates/linker/src/elf.rs +++ b/crates/linker/src/elf.rs @@ -1597,7 +1597,7 @@ mod tests { // we need to compile the app first let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-obj", "app.zig", "-fPIC", @@ -1637,7 +1637,7 @@ mod tests { // now we can compile the host (it uses libapp.so, hence the order here) let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "libapp.so", "host.zig", @@ -1672,7 +1672,7 @@ mod tests { std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap(); surgery_elf( - &*roc_app, + &roc_app, &dir.join("metadata"), &dir.join("final"), false, diff --git a/crates/linker/src/generate_dylib/macho.rs b/crates/linker/src/generate_dylib/macho.rs index 4c80fb06eb..f1c6ba5342 100644 --- a/crates/linker/src/generate_dylib/macho.rs +++ b/crates/linker/src/generate_dylib/macho.rs @@ -47,7 +47,7 @@ pub fn create_dylib_macho( } std::fs::write( - &dummy_obj_file, + dummy_obj_file, out_object.write().expect("failed to build output object"), ) .expect("failed to write object to file"); @@ -67,7 +67,7 @@ pub fn create_dylib_macho( let output = Command::new("ld") .args(ld_prefix_args) - .args(&[ + .args([ ld_flag_soname, dummy_lib_file.file_name().unwrap().to_str().unwrap(), dummy_obj_file.to_str().unwrap(), diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index b731035ad1..6f96d5aade 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -226,7 +226,7 @@ fn generate_import_library(stub_lib_path: &Path, custom_names: &[String]) { // > https://github.com/messense/implib-rs let output = std::process::Command::new(&zig) .current_dir(stub_lib_path.parent().unwrap()) - .args(&[ + .args([ "dlltool", "-d", def_filename.to_str().unwrap(), diff --git a/crates/linker/src/metadata.rs b/crates/linker/src/metadata.rs index aa665988a0..30b1aa1327 100644 --- a/crates/linker/src/metadata.rs +++ b/crates/linker/src/metadata.rs @@ -8,13 +8,13 @@ use roc_collections::all::MutMap; use roc_error_macros::internal_error; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] pub enum VirtualOffset { Absolute, Relative(u64), } -#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] pub struct SurgeryEntry { pub file_offset: u64, pub virtual_offset: VirtualOffset, diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index 211d249bcd..8a0846d8a2 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -1617,7 +1617,7 @@ mod test { // we need to compile the app first let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-obj", "app.zig", "-target", @@ -1642,7 +1642,7 @@ mod test { let file = std::fs::File::open(dir.join("app.obj")).unwrap(); let roc_app = unsafe { memmap2::Mmap::map(&file) }.unwrap(); - let roc_app_sections = AppSections::from_data(&*roc_app); + let roc_app_sections = AppSections::from_data(&roc_app); let symbols = roc_app_sections.roc_symbols; // make the dummy dylib based on the app object @@ -1653,7 +1653,7 @@ mod test { // now we can compile the host (it uses libapp.dll, hence the order here) let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "libapp.dll", "host.zig", @@ -1689,7 +1689,7 @@ mod test { std::fs::copy(&dir.join("preprocessedhost"), &dir.join("app.exe")).unwrap(); - surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &*roc_app); + surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app); } #[allow(dead_code)] @@ -1731,7 +1731,7 @@ mod test { let output = std::process::Command::new("wine") .current_dir(dir) - .args(&["app.exe"]) + .args(["app.exe"]) .output() .unwrap(); @@ -1869,7 +1869,7 @@ mod test { let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "host.zig", "-lc", diff --git a/crates/repl_expect/src/run.rs b/crates/repl_expect/src/run.rs index 39044c45e6..af95645efb 100644 --- a/crates/repl_expect/src/run.rs +++ b/crates/repl_expect/src/run.rs @@ -239,7 +239,7 @@ fn run_expect_fx<'a, W: std::io::Write>( ) -> std::io::Result { use signal_hook::{consts::signal::SIGCHLD, consts::signal::SIGUSR1, iterator::Signals}; - let mut signals = Signals::new(&[SIGCHLD, SIGUSR1]).unwrap(); + let mut signals = Signals::new([SIGCHLD, SIGUSR1]).unwrap(); match unsafe { libc::fork() } { 0 => unsafe { diff --git a/crates/repl_wasm/build.rs b/crates/repl_wasm/build.rs index 93f869ef43..f7397754d7 100644 --- a/crates/repl_wasm/build.rs +++ b/crates/repl_wasm/build.rs @@ -20,7 +20,7 @@ fn main() { let platform_obj = build_wasm_platform(&out_dir, &source_path); let mut pre_linked_binary_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - pre_linked_binary_path.extend(&["pre_linked_binary"]); + pre_linked_binary_path.extend(["pre_linked_binary"]); pre_linked_binary_path.set_extension("o"); let output = Command::new(&zig_executable()) diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 78619e5e3c..ec90be9814 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; #[doc(hidden)] pub use pretty_assertions::assert_eq as _pretty_assert_eq; -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub struct DebugAsDisplay(pub T); impl std::fmt::Debug for DebugAsDisplay { @@ -31,7 +31,7 @@ impl TmpDir { let path = std::path::Path::new(dir); // ensure_empty_dir will fail if the dir doesn't already exist std::fs::create_dir_all(path).unwrap(); - remove_dir_all::ensure_empty_dir(&path).unwrap(); + remove_dir_all::ensure_empty_dir(path).unwrap(); let mut pathbuf = std::path::PathBuf::new(); pathbuf.push(path); diff --git a/crates/vendor/morphic_lib/src/analyze.rs b/crates/vendor/morphic_lib/src/analyze.rs index 498a2c279b..44f58da4ad 100644 --- a/crates/vendor/morphic_lib/src/analyze.rs +++ b/crates/vendor/morphic_lib/src/analyze.rs @@ -1562,11 +1562,11 @@ impl Query { } hasher.update((self.arg_slots_touched.len() as u64).to_le_bytes()); for &arg_touched in &self.arg_slots_touched { - hasher.update(&[arg_touched as u8]); + hasher.update([arg_touched as u8]); } hasher.update((self.ret_slots_touched.len() as u64).to_le_bytes()); for &ret_touched in &self.ret_slots_touched { - hasher.update(&[ret_touched as u8]); + hasher.update([ret_touched as u8]); } api::FuncSpec(hasher.finalize().into()) } @@ -1775,7 +1775,7 @@ pub(crate) fn analyze(tc: TypeCache, program: &ir::Program) -> ProgramSolutions fn hash_func_id_trivial(func_id: FuncId) -> api::FuncSpec { use sha2::{Digest, Sha256}; let mut hasher = Sha256::new(); - hasher.update(&func_id.0.to_le_bytes()); + hasher.update(func_id.0.to_le_bytes()); api::FuncSpec(hasher.finalize().into()) } diff --git a/crates/vendor/morphic_lib/src/api.rs b/crates/vendor/morphic_lib/src/api.rs index b93180764c..70ec8efa19 100644 --- a/crates/vendor/morphic_lib/src/api.rs +++ b/crates/vendor/morphic_lib/src/api.rs @@ -1654,7 +1654,7 @@ pub fn solve_trivial(api_program: Program) -> Result { // solutions fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) { let header = (bstr.len() as u64).to_le_bytes(); - hasher.update(&header); + hasher.update(header); hasher.update(bstr); }