1.65 clippy fixes

This commit is contained in:
Folkert 2022-11-03 16:20:37 +01:00
parent f0d6e418fa
commit 66a1ba00eb
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
53 changed files with 224 additions and 225 deletions

View file

@ -352,7 +352,7 @@ pub fn expr_to_expr2<'a>(
for (node_id, branch) in can_branches.iter_node_ids().zip(branches.iter()) { for (node_id, branch) in can_branches.iter_node_ids().zip(branches.iter()) {
let (can_when_branch, branch_references) = 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); output.references.union_mut(branch_references);

View file

@ -3,7 +3,7 @@ use roc_module::ident::Lowercase;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_types::subs::Variable; use roc_types::subs::Variable;
#[derive(Clone, Debug, PartialEq, Default)] #[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct IntroducedVariables { pub struct IntroducedVariables {
// Rigids must be unique within a type annotation. // Rigids must be unique within a type annotation.
// E.g. in `identity : a -> a`, there should only be one // E.g. in `identity : a -> a`, there should only be one

View file

@ -1154,7 +1154,7 @@ fn run_with_wasmer(wasm_path: &std::path::Path, stdin: &[&str]) -> String {
// .unwrap(); // .unwrap();
let store = Store::default(); 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 mut fake_stdin = wasmer_wasi::Pipe::new();
let fake_stdout = wasmer_wasi::Pipe::new(); let fake_stdout = wasmer_wasi::Pipe::new();

View file

@ -124,7 +124,7 @@ pub fn build_zig_host_native(
bitcode::get_builtins_host_obj_path() bitcode::get_builtins_host_obj_path()
}; };
zig_cmd.args(&[ zig_cmd.args([
"build-exe", "build-exe",
"-fPIE", "-fPIE",
"-rdynamic", // make sure roc_alloc and friends are exposed "-rdynamic", // make sure roc_alloc and friends are exposed
@ -132,10 +132,10 @@ pub fn build_zig_host_native(
&builtins_obj, &builtins_obj,
]); ]);
} else { } else {
zig_cmd.args(&["build-obj", "-fPIC"]); zig_cmd.args(["build-obj", "-fPIC"]);
} }
zig_cmd.args(&[ zig_cmd.args([
zig_host_src, zig_host_src,
&format!("-femit-bin={}", emit_bin), &format!("-femit-bin={}", emit_bin),
"--pkg-begin", "--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 // 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 // this problem for us, so this is a temporary workaround
if !target.contains("windows") { if !target.contains("windows") {
zig_cmd.args(&[ zig_cmd.args([
// include the zig runtime // include the zig runtime
"-fcompiler-rt", "-fcompiler-rt",
]); ]);
@ -162,13 +162,13 @@ pub fn build_zig_host_native(
// valgrind does not yet support avx512 instructions, see #1963. // valgrind does not yet support avx512 instructions, see #1963.
if env::var("NO_AVX512").is_ok() { 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) { if matches!(opt_level, OptLevel::Optimize) {
zig_cmd.args(&["-O", "ReleaseSafe"]); zig_cmd.args(["-O", "ReleaseSafe"]);
} else if matches!(opt_level, OptLevel::Size) { } else if matches!(opt_level, OptLevel::Size) {
zig_cmd.args(&["-O", "ReleaseSmall"]); zig_cmd.args(["-O", "ReleaseSmall"]);
} }
zig_cmd zig_cmd
@ -378,9 +378,9 @@ pub fn build_zig_host_wasm32(
.args(args); .args(args);
if matches!(opt_level, OptLevel::Optimize) { if matches!(opt_level, OptLevel::Optimize) {
zig_cmd.args(&["-O", "ReleaseSafe"]); zig_cmd.args(["-O", "ReleaseSafe"]);
} else if matches!(opt_level, OptLevel::Size) { } else if matches!(opt_level, OptLevel::Size) {
zig_cmd.args(&["-O", "ReleaseSmall"]); zig_cmd.args(["-O", "ReleaseSmall"]);
} }
zig_cmd zig_cmd
@ -400,11 +400,11 @@ pub fn build_c_host_native(
let mut clang_cmd = clang(); let mut clang_cmd = clang();
clang_cmd clang_cmd
.env_clear() .env_clear()
.env("PATH", &env_path) .env("PATH", env_path)
.env("CPATH", &env_cpath) .env("CPATH", env_cpath)
.env("HOME", &env_home) .env("HOME", env_home)
.args(sources) .args(sources)
.args(&["-o", dest]); .args(["-o", dest]);
if let Some(shared_lib_path) = shared_lib_path { if let Some(shared_lib_path) = shared_lib_path {
match target.operating_system { match target.operating_system {
OperatingSystem::Windows => { OperatingSystem::Windows => {
@ -425,7 +425,7 @@ pub fn build_c_host_native(
); );
} }
_ => { _ => {
clang_cmd.args(&[ clang_cmd.args([
shared_lib_path.to_str().unwrap(), shared_lib_path.to_str().unwrap(),
// This line is commented out because // This line is commented out because
// @bhansconnect: With the addition of Str.graphemes, always // @bhansconnect: With the addition of Str.graphemes, always
@ -444,7 +444,7 @@ pub fn build_c_host_native(
} }
} }
} else { } else {
clang_cmd.args(&["-fPIC", "-c"]); clang_cmd.args(["-fPIC", "-c"]);
} }
if matches!(opt_level, OptLevel::Optimize) { if matches!(opt_level, OptLevel::Optimize) {
clang_cmd.arg("-O3"); clang_cmd.arg("-O3");
@ -473,8 +473,8 @@ pub fn build_swift_host_native(
let mut command = Command::new("arch"); let mut command = Command::new("arch");
command command
.env_clear() .env_clear()
.env("PATH", &env_path) .env("PATH", env_path)
.env("HOME", &env_home); .env("HOME", env_home);
match arch { match arch {
Architecture::Aarch64(_) => command.arg("-arm64"), Architecture::Aarch64(_) => command.arg("-arm64"),
@ -487,10 +487,10 @@ pub fn build_swift_host_native(
.args(sources) .args(sources)
.arg("-emit-object") .arg("-emit-object")
.arg("-parse-as-library") .arg("-parse-as-library")
.args(&["-o", dest]); .args(["-o", dest]);
if let Some(objc_header) = objc_header_path { 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) { if matches!(opt_level, OptLevel::Optimize) {
@ -641,7 +641,7 @@ pub fn rebuild_host(
let source_file = if shared_lib_path.is_some() { let source_file = if shared_lib_path.is_some() {
cargo_cmd.env("RUSTFLAGS", "-C link-dead-code"); cargo_cmd.env("RUSTFLAGS", "-C link-dead-code");
cargo_cmd.args(&["--bin", "host"]); cargo_cmd.args(["--bin", "host"]);
"src/main.rs" "src/main.rs"
} else { } else {
cargo_cmd.arg("--lib"); cargo_cmd.arg("--lib");
@ -673,7 +673,7 @@ pub fn rebuild_host(
let mut ld_cmd = Command::new("ld"); 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", "-r",
"-L", "-L",
cargo_out_dir.to_str().unwrap(), cargo_out_dir.to_str().unwrap(),
@ -693,7 +693,7 @@ pub fn rebuild_host(
} else if rust_host_src.exists() { } else if rust_host_src.exists() {
// Compile and link host.rs, if it exists // Compile and link host.rs, if it exists
let mut rustc_cmd = Command::new("rustc"); let mut rustc_cmd = Command::new("rustc");
rustc_cmd.args(&[ rustc_cmd.args([
rust_host_src.to_str().unwrap(), rust_host_src.to_str().unwrap(),
"-o", "-o",
rust_host_dest.to_str().unwrap(), rust_host_dest.to_str().unwrap(),
@ -739,7 +739,7 @@ pub fn rebuild_host(
let mut ld_cmd = Command::new("ld"); 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", "-r",
c_host_dest.to_str().unwrap(), c_host_dest.to_str().unwrap(),
rust_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 { if let Architecture::X86_32(_) = target.architecture {
return Ok(( return Ok((
zig() zig()
.args(&["build-exe"]) .args(["build-exe"])
.args(input_paths) .args(input_paths)
.args(&[ .args([
"-target", "-target",
"i386-linux-musl", "i386-linux-musl",
"-lc", "-lc",
@ -1011,7 +1011,7 @@ fn link_linux(
.filter(|&(ref k, _)| k.starts_with("NIX_")) .filter(|&(ref k, _)| k.starts_with("NIX_"))
.collect::<HashMap<String, String>>(), .collect::<HashMap<String, String>>(),
) )
.args(&[ .args([
"--gc-sections", "--gc-sections",
"--eh-frame-hdr", "--eh-frame-hdr",
"-A", "-A",
@ -1021,11 +1021,11 @@ fn link_linux(
&*crtn_path.to_string_lossy(), &*crtn_path.to_string_lossy(),
]) ])
.args(&base_args) .args(&base_args)
.args(&["-dynamic-linker", ld_linux]) .args(["-dynamic-linker", ld_linux])
.args(input_paths) .args(input_paths)
// ld.lld requires this argument, and does not accept --arch // ld.lld requires this argument, and does not accept --arch
// .args(&["-L/usr/lib/x86_64-linux-gnu"]) // .args(&["-L/usr/lib/x86_64-linux-gnu"])
.args(&[ .args([
// Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496365925 // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496365925
// for discussion and further references // for discussion and further references
"-lc", "-lc",
@ -1076,7 +1076,7 @@ fn link_macos(
// The `-l` flags should go after the `.o` arguments // The `-l` flags should go after the `.o` arguments
// Don't allow LD_ env vars to affect this // Don't allow LD_ env vars to affect this
.env_clear() .env_clear()
.args(&[ .args([
// NOTE: we don't do --gc-sections on macOS because the default // NOTE: we don't do --gc-sections on macOS because the default
// macOS linker doesn't support it, but it's a performance // macOS linker doesn't support it, but it's a performance
// optimization, so if we ever switch to a different linker, // 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.arg(roc_link_flag);
} }
ld_command.args(&[ ld_command.args([
// Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496392274 // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496392274
// for discussion and further references // for discussion and further references
"-lSystem", "-lSystem",
@ -1148,7 +1148,7 @@ fn link_macos(
Architecture::Aarch64(_) => { Architecture::Aarch64(_) => {
ld_child.wait()?; ld_child.wait()?;
let codesign_child = Command::new("codesign") let codesign_child = Command::new("codesign")
.args(&["-s", "-", output_path.to_str().unwrap()]) .args(["-s", "-", output_path.to_str().unwrap()])
.spawn()?; .spawn()?;
Ok((codesign_child, output_path)) Ok((codesign_child, output_path))
@ -1187,7 +1187,7 @@ fn link_wasm32(
let child = zig() let child = zig()
// .env_clear() // .env_clear()
// .env("PATH", &env_path) // .env("PATH", &env_path)
.args(&["build-exe"]) .args(["build-exe"])
.args(input_paths) .args(input_paths)
.args([ .args([
// include wasi libc // include wasi libc
@ -1222,7 +1222,7 @@ fn link_windows(
match link_type { match link_type {
LinkType::Dylib => { LinkType::Dylib => {
let child = zig() let child = zig()
.args(&["build-lib"]) .args(["build-lib"])
.args(input_paths) .args(input_paths)
.args([ .args([
"-lc", "-lc",
@ -1244,7 +1244,7 @@ fn link_windows(
} }
LinkType::Executable => { LinkType::Executable => {
let child = zig() let child = zig()
.args(&["build-exe"]) .args(["build-exe"])
.args(input_paths) .args(input_paths)
.args([ .args([
"-target", "-target",

View file

@ -347,7 +347,7 @@ fn gen_from_mono_module_llvm(
// run the debugir https://github.com/vaivaswatha/debugir tool // run the debugir https://github.com/vaivaswatha/debugir tool
match Command::new("debugir") match Command::new("debugir")
.args(&["-instnamer", app_ll_file.to_str().unwrap()]) .args(["-instnamer", app_ll_file.to_str().unwrap()])
.output() .output()
{ {
Ok(_) => {} Ok(_) => {}
@ -369,7 +369,7 @@ fn gen_from_mono_module_llvm(
| Architecture::Aarch64(_) | Architecture::Aarch64(_)
| Architecture::Wasm32 => { | Architecture::Wasm32 => {
let ll_to_bc = Command::new("llvm-as") let ll_to_bc = Command::new("llvm-as")
.args(&[ .args([
app_ll_dbg_file.to_str().unwrap(), app_ll_dbg_file.to_str().unwrap(),
"-o", "-o",
app_bc_file.to_str().unwrap(), app_bc_file.to_str().unwrap(),

View file

@ -90,7 +90,7 @@ fn generate_object_file(bitcode_path: &Path, zig_object: &str, object_file_name:
let mut zig_cmd = zig(); let mut zig_cmd = zig();
zig_cmd zig_cmd
.current_dir(&bitcode_path) .current_dir(bitcode_path)
.args(["build", zig_object, "-Drelease=true"]); .args(["build", zig_object, "-Drelease=true"]);
run_command(zig_cmd, 0); 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(); let mut zig_cmd = zig();
zig_cmd zig_cmd
.current_dir(&bitcode_path) .current_dir(bitcode_path)
.args(["build", zig_object, "-Drelease=true"]); .args(["build", zig_object, "-Drelease=true"]);
run_command(zig_cmd, 0); 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/ // 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<()> { 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. // 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!( panic!(
"Failed to create output library directory for zig bitcode {:?}: {:?}", "Failed to create output library directory for zig bitcode {:?}: {:?}",
target_dir, err target_dir, err

View file

@ -28,7 +28,7 @@ pub struct MemberVariables {
/// The member and its signature is defined locally, in the module the store is created for. /// 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. /// We need to instantiate and introduce this during solving.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ResolvedMemberType(Variable); pub struct ResolvedMemberType(Variable);
/// Member type information that needs to be resolved from imports. /// Member type information that needs to be resolved from imports.
@ -56,7 +56,7 @@ impl ResolvePhase for Pending {
type MemberType = PendingMemberType; type MemberType = PendingMemberType;
} }
#[derive(Default, Debug, Clone, Copy, PartialEq)] #[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
pub struct Resolved; pub struct Resolved;
impl ResolvePhase for Resolved { impl ResolvePhase for Resolved {
type MemberType = ResolvedMemberType; type MemberType = ResolvedMemberType;

View file

@ -1821,7 +1821,7 @@ pub(crate) fn sort_can_defs(
.strongly_connected_components_subset(group); .strongly_connected_components_subset(group);
debug_assert!( 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"); "A specialization is involved in a recursive cycle - this should not be knowable until solving");
let declaration = if direct_sccs.groups().count() == 1 { let declaration = if direct_sccs.groups().count() == 1 {

View file

@ -65,7 +65,7 @@ impl Output {
} }
} }
#[derive(Clone, Debug, PartialEq, Copy)] #[derive(Clone, Debug, PartialEq, Eq, Copy)]
pub enum IntValue { pub enum IntValue {
I128([u8; 16]), I128([u8; 16]),
U128([u8; 16]), U128([u8; 16]),
@ -345,7 +345,7 @@ pub struct ClosureData {
/// ///
/// We distinguish them from closures so we can have better error messages /// We distinguish them from closures so we can have better error messages
/// during constraint generation. /// during constraint generation.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct AccessorData { pub struct AccessorData {
pub name: Symbol, pub name: Symbol,
pub function_var: Variable, pub function_var: Variable,
@ -485,7 +485,7 @@ pub struct Field {
pub loc_expr: Box<Loc<Expr>>, pub loc_expr: Box<Loc<Expr>>,
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Recursive { pub enum Recursive {
NotRecursive = 0, NotRecursive = 0,
Recursive = 1, Recursive = 1,
@ -888,7 +888,7 @@ pub fn canonicalize_expr<'a>(
var_store, var_store,
inner_scope, inner_scope,
region, region,
*branch, branch,
&mut output, &mut output,
) )
}); });
@ -2737,7 +2737,7 @@ fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
| Expr::ExpectFx { | Expr::ExpectFx {
loc_continuation, .. loc_continuation, ..
} => { } => {
stack.push(&(*loc_continuation).value); stack.push(&loc_continuation.value);
// Intentionally ignore the lookups in the nested `expect` condition itself, // Intentionally ignore the lookups in the nested `expect` condition itself,
// because they couldn't possibly influence the outcome of this `expect`! // because they couldn't possibly influence the outcome of this `expect`!

View file

@ -79,7 +79,7 @@ fn desugar_value_def<'a>(arena: &'a Bump, def: &'a ValueDef<'a>) -> ValueDef<'a>
ann_pattern, ann_pattern,
ann_type, ann_type,
comment: *comment, comment: *comment,
body_pattern: *body_pattern, body_pattern,
body_expr: desugar_expr(arena, body_expr), body_expr: desugar_expr(arena, body_expr),
}, },
Expect { Expect {

View file

@ -1,6 +1,6 @@
use std::{borrow::Borrow, iter::FromIterator}; use std::{borrow::Borrow, iter::FromIterator};
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct VecSet<T> { pub struct VecSet<T> {
elements: Vec<T>, elements: Vec<T>,
} }

View file

@ -25,7 +25,7 @@ use hash::{FlatHash, FlatHashKey};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_types::subs::{Subs, Variable}; use roc_types::subs::{Subs, Variable};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum DeriveError { pub enum DeriveError {
/// Unbound variable present in the type-to-derive. It may be possible to derive for this type /// Unbound variable present in the type-to-derive. It may be possible to derive for this type
/// once the unbound variable is resolved. /// once the unbound variable is resolved.

View file

@ -166,8 +166,8 @@ impl<'a> Formattable for TypeAnnotation<'a> {
Wildcard | Inferred | BoundVariable(_) | Malformed(_) => false, Wildcard | Inferred | BoundVariable(_) | Malformed(_) => false,
Function(args, result) => { Function(args, result) => {
(&result.value).is_multiline() result.value.is_multiline()
|| args.iter().any(|loc_arg| (&loc_arg.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()), Apply(_, _, args) => args.iter().any(|loc_arg| loc_arg.value.is_multiline()),
As(lhs, _, _) => lhs.value.is_multiline(), As(lhs, _, _) => lhs.value.is_multiline(),
@ -226,7 +226,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
buf.newline(); buf.newline();
} }
(&argument.value).format_with_options( argument.value.format_with_options(
buf, buf,
Parens::InFunctionType, Parens::InFunctionType,
Newlines::No, Newlines::No,
@ -251,7 +251,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
buf.push_str("->"); buf.push_str("->");
buf.spaces(1); 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 { if needs_parens {
buf.push(')') buf.push(')')
@ -275,7 +275,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
for argument in *arguments { for argument in *arguments {
buf.spaces(1); buf.spaces(1);
(&argument.value).format_with_options( argument.value.format_with_options(
buf, buf,
Parens::InApply, Parens::InApply,
Newlines::No, Newlines::No,
@ -497,7 +497,7 @@ impl<'a> Formattable for Tag<'a> {
use self::Tag::*; use self::Tag::*;
match self { 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, Tag::SpaceBefore(_, _) | Tag::SpaceAfter(_, _) => true,
Malformed(text) => text.chars().any(|c| c == '\n'), Malformed(text) => text.chars().any(|c| c == '\n'),
} }

View file

@ -542,7 +542,7 @@ fn fmt_binops<'a, 'buf>(
indent: u16, indent: u16,
) { ) {
let is_multiline = part_of_multi_line_binops 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()); || lefts.iter().any(|(expr, _)| expr.value.is_multiline());
for (loc_left_side, loc_binop) in lefts { for (loc_left_side, loc_binop) in lefts {
@ -1045,7 +1045,7 @@ fn fmt_closure<'a, 'buf>(
buf.push_str("->"); 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. // If the body is multiline, go down a line and indent.
let body_indent = if is_multiline { let body_indent = if is_multiline {
@ -1156,7 +1156,7 @@ fn fmt_backpassing<'a, 'buf>(
buf.push_str("<-"); 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. // If the body is multiline, go down a line and indent.
let body_indent = if is_multiline { let body_indent = if is_multiline {

View file

@ -19,7 +19,7 @@ macro_rules! disassembler_test {
// TODO: Not sure if there is a better way to merge these together, // 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. // but I like the end use of this a lot better than the old tests.
($assemble_fn: expr, $format_fn: expr) => {{ ($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 arena = bumpalo::Bump::new();
let (mut buf, cs) = setup_capstone_and_arena(&arena); let (mut buf, cs) = setup_capstone_and_arena(&arena);
$assemble_fn(&mut buf); $assemble_fn(&mut buf);

View file

@ -1011,7 +1011,7 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
#[inline(always)] #[inline(always)]
fn call(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>, fn_name: String) { 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 { relocs.push(Relocation::LinkedFunction {
offset: buf.len() as u64 - 4, offset: buf.len() as u64 - 4,
name: fn_name, name: fn_name,
@ -1478,7 +1478,7 @@ fn binop_reg64_reg64(
let rex = add_reg_extension(src, rex); let rex = add_reg_extension(src, rex);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
let src_mod = (src as u8 % 8) << 3; 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)] #[inline(always)]
@ -1493,7 +1493,7 @@ fn extended_binop_reg64_reg64(
let rex = add_reg_extension(src, rex); let rex = add_reg_extension(src, rex);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
let src_mod = (src as u8 % 8) << 3; 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. // 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 rex = add_rm_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
buf.reserve(7); buf.reserve(7);
buf.extend(&[rex, 0x81, 0xC0 | dst_mod]); buf.extend([rex, 0x81, 0xC0 | dst_mod]);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
/// `ADD r/m64,r64` -> Add r64 to r/m64. /// `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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF2, 0xF2,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF3, 0xF3,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF2, 0xF2,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF3, 0xF3,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF2, 0xF2,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF3, 0xF3,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0x66, 0x66,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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) { fn and_reg64_imm8(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i8) {
let rex = add_rm_extension(dst, REX_W); let rex = add_rm_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; 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). /// `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 rex = add_rm_extension(src, rex);
let dst_mod = (dst as u8 % 8) << 3; let dst_mod = (dst as u8 % 8) << 3;
let src_mod = src as u8 % 8; 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. /// `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 rex = add_rm_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
buf.reserve(7); buf.reserve(7);
buf.extend(&[rex, 0x81, 0xF8 | dst_mod]); buf.extend([rex, 0x81, 0xF8 | dst_mod]);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
/// `CMP r/m64,r64` -> Compare r64 to r/m64. /// `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; 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. /// `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) // 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 // 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. /// `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) // 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 // 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) // 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. /// 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) { fn jmp_imm32(buf: &mut Vec<'_, u8>, imm: i32) {
buf.reserve(5); buf.reserve(5);
buf.push(0xE9); buf.push(0xE9);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
/// Jump near if not equal (ZF=0). /// Jump near if not equal (ZF=0).
@ -1796,7 +1796,7 @@ fn jne_imm32(buf: &mut Vec<'_, u8>, imm: i32) {
buf.reserve(6); buf.reserve(6);
buf.push(0x0F); buf.push(0x0F);
buf.push(0x85); 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. /// `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 rex = add_rm_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
buf.reserve(7); buf.reserve(7);
buf.extend(&[rex, 0xC7, 0xC0 | dst_mod]); buf.extend([rex, 0xC7, 0xC0 | dst_mod]);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
/// `MOV r64, imm64` -> Move imm64 to r64. /// `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 rex = add_opcode_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
buf.reserve(10); buf.reserve(10);
buf.extend(&[rex, 0xB8 | dst_mod]); buf.extend([rex, 0xB8 | dst_mod]);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
} }
@ -1854,12 +1854,12 @@ fn mov_base64_offset32_reg64(
let src_mod = (src as u8 % 8) << 3; let src_mod = (src as u8 % 8) << 3;
let base_mod = base as u8 % 8; let base_mod = base as u8 % 8;
buf.reserve(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. // Using RSP or R12 requires a secondary index byte.
if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 {
buf.push(0x24); 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. /// `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 dst_mod = (dst as u8 % 8) << 3;
let base_mod = base as u8 % 8; let base_mod = base as u8 % 8;
buf.reserve(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. // Using RSP or R12 requires a secondary index byte.
if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 {
buf.push(0x24); 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. /// `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 dst_mod = (dst as u8 % 8) << 3;
let base_mod = base as u8 % 8; let base_mod = base as u8 % 8;
buf.reserve(9); 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. // Using RSP or R12 requires a secondary index byte.
if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 {
buf.push(0x24); 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. /// `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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF2, 0xF2,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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_high = src as u8 > 7;
let src_mod = src as u8 % 8; let src_mod = src as u8 % 8;
if dst_high || src_high { if dst_high || src_high {
buf.extend(&[ buf.extend([
0xF3, 0xF3,
0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x40 | ((dst_high as u8) << 2) | (src_high as u8),
0x0F, 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), 0xC0 | (dst_mod << 3) | (src_mod),
]) ])
} else { } 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; let dst_mod = dst as u8 % 8;
if dst as u8 > 7 { if dst as u8 > 7 {
buf.reserve(9); buf.reserve(9);
buf.extend(&[0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); buf.extend([0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]);
} else { } else {
buf.reserve(8); 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. // `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; let dst_mod = dst as u8 % 8;
if dst as u8 > 7 { if dst as u8 > 7 {
buf.reserve(9); buf.reserve(9);
buf.extend(&[0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); buf.extend([0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]);
} else { } else {
buf.reserve(8); 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. /// `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 { if src as u8 > 7 || base as u8 > 7 {
buf.push(rex); 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. // Using RSP or R12 requires a secondary index byte.
if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 {
buf.push(0x24); 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. /// `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 { if dst as u8 > 7 || base as u8 > 7 {
buf.push(rex); 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. // Using RSP or R12 requires a secondary index byte.
if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 {
buf.push(0x24); buf.push(0x24);
} }
buf.extend(&offset.to_le_bytes()); buf.extend(offset.to_le_bytes());
} }
/// `NEG r/m64` -> Two's complement negate r/m64. /// `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) { fn neg_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) {
let rex = add_rm_extension(reg, REX_W); let rex = add_rm_extension(reg, REX_W);
let reg_mod = reg as u8 % 8; 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 // 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; let reg_mod = reg as u8 % 8;
use X86_64GeneralReg::*; use X86_64GeneralReg::*;
match reg { match reg {
RAX | RCX | RDX | RBX => buf.extend(&[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]), RSP | RBP | RSI | RDI => buf.extend([REX, 0x0F, op_code, 0xC0 | reg_mod]),
R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 => { 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<T: RegTrait, U: RegTrait>(
let mod1 = (dst.value() % 8) << 3; let mod1 = (dst.value() % 8) << 3;
let mod2 = src.value() % 8; 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)] #[inline(always)]
@ -2099,7 +2099,7 @@ fn cvtsx2_help<T: RegTrait, V: RegTrait>(
let mod1 = (dst.value() % 8) << 3; let mod1 = (dst.value() % 8) << 3;
let mod2 = src.value() % 8; 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) /// `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 rex = add_rm_extension(dst, REX_W);
let dst_mod = dst as u8 % 8; let dst_mod = dst as u8 % 8;
buf.reserve(7); buf.reserve(7);
buf.extend(&[rex, 0x81, 0xE8 | dst_mod]); buf.extend([rex, 0x81, 0xE8 | dst_mod]);
buf.extend(&imm.to_le_bytes()); buf.extend(imm.to_le_bytes());
} }
/// `SUB r/m64,r64` -> Sub r64 to r/m64. /// `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; let reg_mod = reg as u8 % 8;
if reg as u8 > 7 { if reg as u8 > 7 {
let rex = add_opcode_extension(reg, REX); let rex = add_opcode_extension(reg, REX);
buf.extend(&[rex, 0x58 | reg_mod]); buf.extend([rex, 0x58 | reg_mod]);
} else { } else {
buf.push(0x58 | reg_mod); 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; let reg_mod = reg as u8 % 8;
if reg as u8 > 7 { if reg as u8 > 7 {
let rex = add_opcode_extension(reg, REX); let rex = add_opcode_extension(reg, REX);
buf.extend(&[rex, 0x50 | reg_mod]); buf.extend([rex, 0x50 | reg_mod]);
} else { } else {
buf.push(0x50 | reg_mod); buf.push(0x50 | reg_mod);
} }

View file

@ -156,7 +156,7 @@ trait Backend<'a> {
let module_id = env.module_id; let module_id = env.module_id;
let ident_ids = interns.all_ident_ids.get_mut(&module_id).unwrap(); 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() { for spec in new_specializations.into_iter() {

View file

@ -421,7 +421,7 @@ fn build_proc<'a, B: Backend<'a>>(
} }
Relocation::LinkedFunction { offset, name } => { Relocation::LinkedFunction { offset, name } => {
// If the symbol is an undefined roc function, we need to add it here. // 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 { let builtin_symbol = Symbol {
name: name.as_bytes().to_vec(), name: name.as_bytes().to_vec(),
value: 0, value: 0,
@ -435,7 +435,7 @@ fn build_proc<'a, B: Backend<'a>>(
output.add_symbol(builtin_symbol); output.add_symbol(builtin_symbol);
} }
// If the symbol is an undefined reference counting procedure, we need to add it here. // 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() { for (sym, rc_name) in rc_proc_names.iter() {
if name == rc_name { if name == rc_name {
let section_id = output.add_section( let section_id = output.add_section(

View file

@ -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> { pub struct Scope<'a, 'ctx> {
symbols: ImMap<Symbol, (Layout<'a>, BasicValueEnum<'ctx>)>, symbols: ImMap<Symbol, (Layout<'a>, BasicValueEnum<'ctx>)>,
pub top_level_thunks: ImMap<Symbol, (ProcLayout<'a>, FunctionValue<'ctx>)>, pub top_level_thunks: ImMap<Symbol, (ProcLayout<'a>, FunctionValue<'ctx>)>,
@ -973,7 +973,7 @@ pub fn build_exp_literal<'a, 'ctx, 'env>(
_ => unreachable!("incorrect small_str_bytes"), _ => unreachable!("incorrect small_str_bytes"),
} }
} else { } 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 number_of_elements = env.ptr_int().const_int(str_literal.len() as u64, false);
let alloca = let alloca =
@ -4554,7 +4554,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
fn_val.print_to_stderr(); fn_val.print_to_stderr();
if let Some(app_ll_file) = debug_output_file { 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!( panic!(
r"😱 LLVM errors when defining function {:?}; I wrote the full LLVM IR to {:?}", r"😱 LLVM errors when defining function {:?}; I wrote the full LLVM IR to {:?}",

View file

@ -1366,7 +1366,7 @@ fn union_layout_tags<'a>(
match union_layout { match union_layout {
NullableWrapped { NullableWrapped {
other_tags: tags, .. other_tags: tags, ..
} => *tags, } => tags,
NullableUnwrapped { other_fields, .. } => arena.alloc([*other_fields]), NullableUnwrapped { other_fields, .. } => arena.alloc([*other_fields]),
NonNullableUnwrapped(fields) => arena.alloc([*fields]), NonNullableUnwrapped(fields) => arena.alloc([*fields]),
Recursive(tags) => tags, Recursive(tags) => tags,

View file

@ -1237,7 +1237,7 @@ impl<'a> WasmBackend<'a> {
} }
CallType::HigherOrder(higher_order_lowlevel) => { 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 { CallType::Foreign {

View file

@ -69,7 +69,7 @@ impl std::fmt::Debug for VmBlock<'_> {
/// Rust representation matches Wasm encoding. /// Rust representation matches Wasm encoding.
/// It's an error to specify alignment higher than the "natural" alignment of the instruction /// It's an error to specify alignment higher than the "natural" alignment of the instruction
#[repr(u8)] #[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]
pub enum Align { pub enum Align {
Bytes1 = 0, Bytes1 = 0,
Bytes2 = 1, Bytes2 = 1,
@ -111,7 +111,7 @@ impl From<u32> for Align {
} }
} }
#[derive(Debug, Clone, PartialEq, Copy)] #[derive(Debug, Clone, PartialEq, Eq, Copy)]
pub enum VmSymbolState { pub enum VmSymbolState {
/// Value doesn't exist yet /// Value doesn't exist yet
NotYetPushed, NotYetPushed,

View file

@ -551,7 +551,7 @@ impl Parse<()> for RefType {
} }
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct TableType { pub struct TableType {
pub ref_type: RefType, pub ref_type: RefType,
pub limits: Limits, pub limits: Limits,
@ -659,7 +659,7 @@ impl Serialize for TableSection {
* *
*******************************************************************/ *******************************************************************/
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum Limits { pub enum Limits {
Min(u32), Min(u32),
MinMax(u32, 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 struct GlobalType {
pub value_type: ValueType, pub value_type: ValueType,
pub is_mutable: bool, pub is_mutable: bool,

View file

@ -44,7 +44,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) {
println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap()); println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap());
let mut output_path = PathBuf::from(std::env::var("OUT_DIR").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"); output_path.set_extension("dat");
#[cfg(not(windows))] #[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) { fn write_types_for_module_dummy(output_path: &Path) {
// write out a dummy file // write out a dummy file
std::fs::write(output_path, &[]).unwrap(); std::fs::write(output_path, []).unwrap();
} }
#[cfg(not(windows))] #[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 abilities = module.abilities_store;
let solved_implementations = module.resolved_implementations; 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 { let type_state = TypeState {
subs, subs,

View file

@ -3100,7 +3100,7 @@ fn load_platform_module<'a>(
) -> Result<Msg<'a>, LoadingProblem<'a>> { ) -> Result<Msg<'a>, LoadingProblem<'a>> {
let module_start_time = Instant::now(); let module_start_time = Instant::now();
let file_io_start = 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(); let file_io_duration = file_io_start.elapsed();
match file { match file {

View file

@ -70,7 +70,7 @@ pub enum ArgSide {
Right, Right,
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Associativity { pub enum Associativity {
/// left-associative operators: /// left-associative operators:
/// ///

View file

@ -471,7 +471,7 @@ impl<'a> CodeGenHelp<'a> {
) -> (bool, Vec<'a, Option<usize>>) { ) -> (bool, Vec<'a, Option<usize>>) {
use UnionLayout::*; use UnionLayout::*;
match union { 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), Recursive(tags) => self.union_tail_recursion_fields_help(tags),

View file

@ -284,7 +284,7 @@ impl AbilityAliases {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CapturedSymbols<'a> { pub enum CapturedSymbols<'a> {
None, None,
Captured(&'a [(Symbol, Variable)]), Captured(&'a [(Symbol, Variable)]),
@ -317,7 +317,7 @@ pub struct Proc<'a> {
pub host_exposed_layouts: HostExposedLayouts<'a>, pub host_exposed_layouts: HostExposedLayouts<'a>,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum HostExposedLayouts<'a> { pub enum HostExposedLayouts<'a> {
NotHostExposed, NotHostExposed,
HostExposed { HostExposed {
@ -326,13 +326,13 @@ pub enum HostExposedLayouts<'a> {
}, },
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum SelfRecursive { pub enum SelfRecursive {
NotSelfRecursive, NotSelfRecursive,
SelfRecursive(JoinPointId), SelfRecursive(JoinPointId),
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Parens { pub enum Parens {
NotNeeded, NotNeeded,
InTypeParam, InTypeParam,
@ -1575,7 +1575,7 @@ impl<'a, 'i> Env<'a, 'i> {
#[derive(Clone, Debug, PartialEq, Copy, Eq, Hash)] #[derive(Clone, Debug, PartialEq, Copy, Eq, Hash)]
pub struct JoinPointId(pub Symbol); pub struct JoinPointId(pub Symbol);
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Param<'a> { pub struct Param<'a> {
pub symbol: Symbol, pub symbol: Symbol,
pub borrow: bool, 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` /// 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> { pub enum BranchInfo<'a> {
None, None,
Constructor { Constructor {
@ -1702,7 +1702,7 @@ impl<'a> BranchInfo<'a> {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ModifyRc { pub enum ModifyRc {
/// Increment a reference count /// Increment a reference count
Inc(Symbol, u64), 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 { pub struct CallSpecId {
id: u32, id: u32,
} }
@ -1863,7 +1863,7 @@ impl CallSpecId {
pub const BACKEND_DUMMY: Self = Self { id: 0 }; pub const BACKEND_DUMMY: Self = Self { id: 0 };
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct UpdateModeId { pub struct UpdateModeId {
id: u32, id: u32,
} }
@ -1878,7 +1878,7 @@ impl UpdateModeId {
pub const BACKEND_DUMMY: Self = Self { id: 0 }; pub const BACKEND_DUMMY: Self = Self { id: 0 };
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct UpdateModeIds { pub struct UpdateModeIds {
next: u32, next: u32,
} }
@ -1914,7 +1914,7 @@ pub enum CallType<'a> {
HigherOrder(&'a HigherOrderLowLevel<'a>), HigherOrder(&'a HigherOrderLowLevel<'a>),
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct PassedFunction<'a> { pub struct PassedFunction<'a> {
/// name of the top-level function that is passed as an argument /// 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` /// 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, pub owns_captured_environment: bool,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct HigherOrderLowLevel<'a> { pub struct HigherOrderLowLevel<'a> {
pub op: crate::low_level::HigherOrder, pub op: crate::low_level::HigherOrder,
@ -7009,7 +7009,7 @@ fn substitute_in_call<'a>(
} => substitute(subs, name.name()).map(|new| CallType::ByName { } => substitute(subs, name.name()).map(|new| CallType::ByName {
name: name.replace_name(new), name: name.replace_name(new),
arg_layouts, arg_layouts,
ret_layout: *ret_layout, ret_layout,
specialization_id: *specialization_id, specialization_id: *specialization_id,
}), }),
CallType::Foreign { .. } => None, CallType::Foreign { .. } => None,
@ -7158,7 +7158,7 @@ fn substitute_in_expr<'a>(
} => match substitute(subs, *structure) { } => match substitute(subs, *structure) {
Some(structure) => Some(StructAtIndex { Some(structure) => Some(StructAtIndex {
index: *index, index: *index,
field_layouts: *field_layouts, field_layouts,
structure, structure,
}), }),
None => None, None => None,

View file

@ -1,6 +1,6 @@
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HigherOrder { pub enum HigherOrder {
ListMap { ListMap {
xs: Symbol, xs: Symbol,

View file

@ -128,7 +128,7 @@ fn function_s<'a, 'i>(
remainder, remainder,
} => { } => {
let id = *id; let id = *id;
let body: &Stmt = *body; let body: &Stmt = body;
let new_body = function_s(env, w, c, body); let new_body = function_s(env, w, c, body);
let new_join = if std::ptr::eq(body, new_body) || body == new_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) arena.alloc(new_switch)
} }
Refcounting(op, continuation) => { Refcounting(op, continuation) => {
let continuation: &Stmt = *continuation; let continuation: &Stmt = continuation;
let new_continuation = function_s(env, w, c, continuation); let new_continuation = function_s(env, w, c, continuation);
if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation {
@ -198,7 +198,7 @@ fn function_s<'a, 'i>(
layouts, layouts,
remainder, remainder,
} => { } => {
let continuation: &Stmt = *remainder; let continuation: &Stmt = remainder;
let new_continuation = function_s(env, w, c, continuation); let new_continuation = function_s(env, w, c, continuation);
if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation {
@ -223,7 +223,7 @@ fn function_s<'a, 'i>(
layouts, layouts,
remainder, remainder,
} => { } => {
let continuation: &Stmt = *remainder; let continuation: &Stmt = remainder;
let new_continuation = function_s(env, w, c, continuation); let new_continuation = function_s(env, w, c, continuation);
if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation {

View file

@ -109,7 +109,7 @@ pub enum StrSegment<'a> {
Interpolated(Loc<&'a Expr<'a>>), // e.g. (name) in "Hi, \(name)!" 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 { pub enum EscapedChar {
Newline, // \n Newline, // \n
Tab, // \t Tab, // \t
@ -581,7 +581,7 @@ pub enum AssignedField<'a, Val> {
Malformed(&'a str), Malformed(&'a str),
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CommentOrNewline<'a> { pub enum CommentOrNewline<'a> {
Newline, Newline,
LineComment(&'a str), LineComment(&'a str),
@ -880,7 +880,7 @@ impl<'a, T> Collection<'a, T> {
pub fn final_comments(&self) -> &'a [CommentOrNewline<'a>] { pub fn final_comments(&self) -> &'a [CommentOrNewline<'a>] {
if let Some(final_comments) = self.final_comments { if let Some(final_comments) = self.final_comments {
*final_comments final_comments
} else { } else {
&[] &[]
} }

View file

@ -546,7 +546,7 @@ fn numeric_negate_expression<'a, T>(
expr: Loc<Expr<'a>>, expr: Loc<Expr<'a>>,
spaces: &'a [CommentOrNewline<'a>], spaces: &'a [CommentOrNewline<'a>],
) -> Loc<Expr<'a>> { ) -> Loc<Expr<'a>> {
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. // for overflow reasons, we must make the unary minus part of the number literal.
let start = state.pos(); let start = state.pos();
let region = Region::new(start, expr.region.end()); let region = Region::new(start, expr.region.end());
@ -941,7 +941,7 @@ fn parse_defs_end<'a>(
ann_type: arena.alloc(*ann_type), ann_type: arena.alloc(*ann_type),
comment, comment,
body_pattern: arena.alloc(loc_pattern), body_pattern: arena.alloc(loc_pattern),
body_expr: *arena.alloc(loc_def_expr), body_expr: arena.alloc(loc_def_expr),
}; };
let region = let region =
@ -980,7 +980,7 @@ fn parse_defs_end<'a>(
ann_type: arena.alloc(*ann_type), ann_type: arena.alloc(*ann_type),
comment, comment,
body_pattern: arena.alloc(loc_pattern), body_pattern: arena.alloc(loc_pattern),
body_expr: *arena.alloc(loc_def_expr), body_expr: arena.alloc(loc_def_expr),
}; };
let region = let region =
@ -1904,7 +1904,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
| Expr::UnaryOp(_, _) => Err(()), | Expr::UnaryOp(_, _) => Err(()),
Expr::Str(string) => Ok(Pattern::StrLiteral(*string)), 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)), Expr::MalformedIdent(string, _problem) => Ok(Pattern::Malformed(string)),
} }
} }

View file

@ -52,7 +52,7 @@ pub enum VersionComparison {
DisallowsEqual, DisallowsEqual,
} }
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct PackageName<'a>(&'a str); pub struct PackageName<'a>(&'a str);
impl<'a> PackageName<'a> { impl<'a> PackageName<'a> {
@ -160,7 +160,7 @@ pub struct HostedHeader<'a> {
pub after_with: &'a [CommentOrNewline<'a>], pub after_with: &'a [CommentOrNewline<'a>],
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum To<'a> { pub enum To<'a> {
ExistingPackage(&'a str), ExistingPackage(&'a str),
NewPackage(PackageName<'a>), NewPackage(PackageName<'a>),
@ -262,7 +262,7 @@ pub struct TypedIdent<'a> {
pub ann: Loc<TypeAnnotation<'a>>, pub ann: Loc<TypeAnnotation<'a>>,
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct PackageEntry<'a> { pub struct PackageEntry<'a> {
pub shorthand: &'a str, pub shorthand: &'a str,
pub spaces_after_shorthand: &'a [CommentOrNewline<'a>], pub spaces_after_shorthand: &'a [CommentOrNewline<'a>],

View file

@ -7,19 +7,19 @@ use roc_parse::pattern::PatternType;
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::types::AliasKind; use roc_types::types::AliasKind;
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct CycleEntry { pub struct CycleEntry {
pub symbol: Symbol, pub symbol: Symbol,
pub symbol_region: Region, pub symbol_region: Region,
pub expr_region: Region, pub expr_region: Region,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum BadPattern { pub enum BadPattern {
Unsupported(PatternType), Unsupported(PatternType),
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ShadowKind { pub enum ShadowKind {
Variable, Variable,
Alias(Symbol), Alias(Symbol),
@ -28,7 +28,7 @@ pub enum ShadowKind {
} }
/// Problems that can occur in the course of canonicalization. /// Problems that can occur in the course of canonicalization.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum Problem { pub enum Problem {
UnusedDef(Symbol, Region), UnusedDef(Symbol, Region),
UnusedImport(Symbol, Region), UnusedImport(Symbol, Region),
@ -190,13 +190,13 @@ pub enum Problem {
}, },
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum ExtensionTypeKind { pub enum ExtensionTypeKind {
Record, Record,
TagUnion, TagUnion,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum PrecedenceProblem { pub enum PrecedenceProblem {
BothNonAssociative(Region, Loc<BinOp>, Loc<BinOp>), BothNonAssociative(Region, Loc<BinOp>, Loc<BinOp>),
} }
@ -245,7 +245,7 @@ pub enum FloatErrorKind {
IntSuffix, IntSuffix,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum RuntimeError { pub enum RuntimeError {
Shadowing { Shadowing {
original_region: Region, original_region: Region,
@ -368,7 +368,7 @@ impl RuntimeError {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MalformedPatternProblem { pub enum MalformedPatternProblem {
MalformedInt, MalformedInt,
MalformedFloat, MalformedFloat,

View file

@ -31,7 +31,7 @@ pub enum AbilityImplError {
} }
/// Indexes a requested deriving of an ability for an opaque type. /// 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 struct RequestedDeriveKey {
pub opaque: Symbol, pub opaque: Symbol,
pub ability: Symbol, pub ability: Symbol,

View file

@ -51,7 +51,7 @@ pub enum Unfulfilled {
}, },
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Eq, Debug, Clone)]
pub enum UnderivableReason { pub enum UnderivableReason {
NotABuiltin, NotABuiltin,
/// The surface type is not derivable /// The surface type is not derivable
@ -60,7 +60,7 @@ pub enum UnderivableReason {
NestedNotDerivable(ErrorType, NotDerivableContext), NestedNotDerivable(ErrorType, NotDerivableContext),
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Eq, Debug, Clone)]
pub enum NotDerivableContext { pub enum NotDerivableContext {
NoContext, NoContext,
Function, Function,
@ -70,12 +70,12 @@ pub enum NotDerivableContext {
Eq(NotDerivableEq), Eq(NotDerivableEq),
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Eq, Debug, Clone)]
pub enum NotDerivableDecode { pub enum NotDerivableDecode {
OptionalRecordField(Lowercase), OptionalRecordField(Lowercase),
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Eq, Debug, Clone)]
pub enum NotDerivableEq { pub enum NotDerivableEq {
FloatingPoint, FloatingPoint,
} }

View file

@ -341,11 +341,11 @@ fn annotate_with_debug_info<'ctx>(
let app_bc_file = "/tmp/roc-debugir.bc"; let app_bc_file = "/tmp/roc-debugir.bc";
// write the ll code to a file, so we can modify it // 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 // run the debugir https://github.com/vaivaswatha/debugir tool
match Command::new("debugir") match Command::new("debugir")
.args(&["-instnamer", app_ll_file]) .args(["-instnamer", app_ll_file])
.output() .output()
{ {
Ok(_) => {} Ok(_) => {}
@ -361,11 +361,11 @@ fn annotate_with_debug_info<'ctx>(
} }
Command::new("llvm-as") Command::new("llvm-as")
.args(&[app_dbg_ll_file, "-o", app_bc_file]) .args([app_dbg_ll_file, "-o", app_bc_file])
.output() .output()
.unwrap(); .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)] #[allow(dead_code)]
@ -459,7 +459,7 @@ fn llvm_module_to_wasm_file(
let output = zig() let output = zig()
.current_dir(dir_path) .current_dir(dir_path)
.args(&[ .args([
"wasm-ld", "wasm-ld",
concat!(env!("OUT_DIR"), "/wasm_test_platform.wasm"), concat!(env!("OUT_DIR"), "/wasm_test_platform.wasm"),
test_a_path.to_str().unwrap(), test_a_path.to_str().unwrap(),

View file

@ -174,7 +174,7 @@ fn verify_procedures<'a>(
use std::process::Command; use std::process::Command;
let is_tracked = Command::new("git") let is_tracked = Command::new("git")
.args(&["ls-files", "--error-unmatch", &path]) .args(["ls-files", "--error-unmatch", &path])
.output() .output()
.unwrap(); .unwrap();
@ -186,7 +186,7 @@ fn verify_procedures<'a>(
} }
let has_changes = Command::new("git") let has_changes = Command::new("git")
.args(&["diff", "--color=always", &path]) .args(["diff", "--color=always", &path])
.output() .output()
.unwrap(); .unwrap();

View file

@ -30,7 +30,7 @@ static EMPTY_TAG_UNION: &str = "[]";
/// List (List I64) /// List (List I64)
/// ///
/// Otherwise, parens are unnecessary. /// Otherwise, parens are unnecessary.
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Parens { pub enum Parens {
InFn, InFn,
InTypeParam, InTypeParam,

View file

@ -2250,7 +2250,7 @@ pub enum Reason {
}, },
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Eq, Debug, Clone)]
pub enum Category { pub enum Category {
Lookup(Symbol), Lookup(Symbol),
CallResult(Option<Symbol>, CalledVia), CallResult(Option<Symbol>, CalledVia),
@ -2334,7 +2334,7 @@ impl AliasKind {
} }
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct AliasVar { pub struct AliasVar {
pub name: Lowercase, pub name: Lowercase,
pub var: Variable, pub var: Variable,

View file

@ -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() { if let Some(&roc_file_name) = roc_file_names.first() {
let full_roc_file_path = project_dir_path.join(roc_file_name); 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)); .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) (full_roc_file_path, file_as_str)

View file

@ -42,7 +42,7 @@ impl QuadBufferBuilder {
max_y: f32, max_y: f32,
color: [f32; 4], color: [f32; 4],
) -> Self { ) -> Self {
self.vertex_data.extend(&[ self.vertex_data.extend([
Vertex { Vertex {
position: (min_x, min_y).into(), position: (min_x, min_y).into(),
color, color,
@ -60,7 +60,7 @@ impl QuadBufferBuilder {
color, color,
}, },
]); ]);
self.index_data.extend(&[ self.index_data.extend([
self.current_quad * 4, self.current_quad * 4,
self.current_quad * 4 + 1, self.current_quad * 4 + 1,
self.current_quad * 4 + 2, self.current_quad * 4 + 2,

View file

@ -232,8 +232,7 @@ pub mod highlight_tests {
node_to_string_w_children( node_to_string_w_children(
*highlight_defs("a = 0", &mut mark_node_pool) *highlight_defs("a = 0", &mut mark_node_pool)
.unwrap() .unwrap().first()
.get(0)
.unwrap(), .unwrap(),
&mut str_buffer, &mut str_buffer,
&mark_node_pool, &mark_node_pool,

View file

@ -1597,7 +1597,7 @@ mod tests {
// we need to compile the app first // we need to compile the app first
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(dir) .current_dir(dir)
.args(&[ .args([
"build-obj", "build-obj",
"app.zig", "app.zig",
"-fPIC", "-fPIC",
@ -1637,7 +1637,7 @@ mod tests {
// now we can compile the host (it uses libapp.so, hence the order here) // now we can compile the host (it uses libapp.so, hence the order here)
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(dir) .current_dir(dir)
.args(&[ .args([
"build-exe", "build-exe",
"libapp.so", "libapp.so",
"host.zig", "host.zig",
@ -1672,7 +1672,7 @@ mod tests {
std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap(); std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap();
surgery_elf( surgery_elf(
&*roc_app, &roc_app,
&dir.join("metadata"), &dir.join("metadata"),
&dir.join("final"), &dir.join("final"),
false, false,

View file

@ -47,7 +47,7 @@ pub fn create_dylib_macho(
} }
std::fs::write( std::fs::write(
&dummy_obj_file, dummy_obj_file,
out_object.write().expect("failed to build output object"), out_object.write().expect("failed to build output object"),
) )
.expect("failed to write object to file"); .expect("failed to write object to file");
@ -67,7 +67,7 @@ pub fn create_dylib_macho(
let output = Command::new("ld") let output = Command::new("ld")
.args(ld_prefix_args) .args(ld_prefix_args)
.args(&[ .args([
ld_flag_soname, ld_flag_soname,
dummy_lib_file.file_name().unwrap().to_str().unwrap(), dummy_lib_file.file_name().unwrap().to_str().unwrap(),
dummy_obj_file.to_str().unwrap(), dummy_obj_file.to_str().unwrap(),

View file

@ -226,7 +226,7 @@ fn generate_import_library(stub_lib_path: &Path, custom_names: &[String]) {
// > https://github.com/messense/implib-rs // > https://github.com/messense/implib-rs
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(stub_lib_path.parent().unwrap()) .current_dir(stub_lib_path.parent().unwrap())
.args(&[ .args([
"dlltool", "dlltool",
"-d", "-d",
def_filename.to_str().unwrap(), def_filename.to_str().unwrap(),

View file

@ -8,13 +8,13 @@ use roc_collections::all::MutMap;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Debug)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub enum VirtualOffset { pub enum VirtualOffset {
Absolute, Absolute,
Relative(u64), Relative(u64),
} }
#[derive(Serialize, Deserialize, PartialEq, Debug)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub struct SurgeryEntry { pub struct SurgeryEntry {
pub file_offset: u64, pub file_offset: u64,
pub virtual_offset: VirtualOffset, pub virtual_offset: VirtualOffset,

View file

@ -1617,7 +1617,7 @@ mod test {
// we need to compile the app first // we need to compile the app first
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(dir) .current_dir(dir)
.args(&[ .args([
"build-obj", "build-obj",
"app.zig", "app.zig",
"-target", "-target",
@ -1642,7 +1642,7 @@ mod test {
let file = std::fs::File::open(dir.join("app.obj")).unwrap(); let file = std::fs::File::open(dir.join("app.obj")).unwrap();
let roc_app = unsafe { memmap2::Mmap::map(&file) }.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; let symbols = roc_app_sections.roc_symbols;
// make the dummy dylib based on the app object // 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) // now we can compile the host (it uses libapp.dll, hence the order here)
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(dir) .current_dir(dir)
.args(&[ .args([
"build-exe", "build-exe",
"libapp.dll", "libapp.dll",
"host.zig", "host.zig",
@ -1689,7 +1689,7 @@ mod test {
std::fs::copy(&dir.join("preprocessedhost"), &dir.join("app.exe")).unwrap(); 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)] #[allow(dead_code)]
@ -1731,7 +1731,7 @@ mod test {
let output = std::process::Command::new("wine") let output = std::process::Command::new("wine")
.current_dir(dir) .current_dir(dir)
.args(&["app.exe"]) .args(["app.exe"])
.output() .output()
.unwrap(); .unwrap();
@ -1869,7 +1869,7 @@ mod test {
let output = std::process::Command::new(&zig) let output = std::process::Command::new(&zig)
.current_dir(dir) .current_dir(dir)
.args(&[ .args([
"build-exe", "build-exe",
"host.zig", "host.zig",
"-lc", "-lc",

View file

@ -239,7 +239,7 @@ fn run_expect_fx<'a, W: std::io::Write>(
) -> std::io::Result<bool> { ) -> std::io::Result<bool> {
use signal_hook::{consts::signal::SIGCHLD, consts::signal::SIGUSR1, iterator::Signals}; 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() } { match unsafe { libc::fork() } {
0 => unsafe { 0 => unsafe {

View file

@ -20,7 +20,7 @@ fn main() {
let platform_obj = build_wasm_platform(&out_dir, &source_path); let platform_obj = build_wasm_platform(&out_dir, &source_path);
let mut pre_linked_binary_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); 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"); pre_linked_binary_path.set_extension("o");
let output = Command::new(&zig_executable()) let output = Command::new(&zig_executable())

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
#[doc(hidden)] #[doc(hidden)]
pub use pretty_assertions::assert_eq as _pretty_assert_eq; pub use pretty_assertions::assert_eq as _pretty_assert_eq;
#[derive(PartialEq)] #[derive(PartialEq, Eq)]
pub struct DebugAsDisplay<T>(pub T); pub struct DebugAsDisplay<T>(pub T);
impl<T: std::fmt::Display> std::fmt::Debug for DebugAsDisplay<T> { impl<T: std::fmt::Display> std::fmt::Debug for DebugAsDisplay<T> {
@ -31,7 +31,7 @@ impl TmpDir {
let path = std::path::Path::new(dir); let path = std::path::Path::new(dir);
// ensure_empty_dir will fail if the dir doesn't already exist // ensure_empty_dir will fail if the dir doesn't already exist
std::fs::create_dir_all(path).unwrap(); 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(); let mut pathbuf = std::path::PathBuf::new();
pathbuf.push(path); pathbuf.push(path);

View file

@ -1562,11 +1562,11 @@ impl Query {
} }
hasher.update((self.arg_slots_touched.len() as u64).to_le_bytes()); hasher.update((self.arg_slots_touched.len() as u64).to_le_bytes());
for &arg_touched in &self.arg_slots_touched { 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()); hasher.update((self.ret_slots_touched.len() as u64).to_le_bytes());
for &ret_touched in &self.ret_slots_touched { 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()) 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 { fn hash_func_id_trivial(func_id: FuncId) -> api::FuncSpec {
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
let mut hasher = Sha256::new(); 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()) api::FuncSpec(hasher.finalize().into())
} }

View file

@ -1654,7 +1654,7 @@ pub fn solve_trivial(api_program: Program) -> Result<Solutions> {
// solutions // solutions
fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) { fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) {
let header = (bstr.len() as u64).to_le_bytes(); let header = (bstr.len() as u64).to_le_bytes();
hasher.update(&header); hasher.update(header);
hasher.update(bstr); hasher.update(bstr);
} }