mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
clippy --fix fixes
This commit is contained in:
parent
9973d4b8d2
commit
4cd8f0a056
57 changed files with 366 additions and 374 deletions
|
@ -68,7 +68,7 @@ fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap<St
|
|||
.next()
|
||||
.unwrap();
|
||||
|
||||
let address = sym.address() as u64;
|
||||
let address = sym.address();
|
||||
|
||||
// special exceptions for roc_ functions that map to libc symbols
|
||||
let direct_mapping = match name {
|
||||
|
@ -972,7 +972,7 @@ fn scan_elf_dynamic_deps(
|
|||
|
||||
dyn_lib_index += 1;
|
||||
}
|
||||
let dynamic_lib_count = dyn_lib_index as usize;
|
||||
let dynamic_lib_count = dyn_lib_index;
|
||||
|
||||
if shared_lib_index.is_none() {
|
||||
panic!("Shared lib not found as a dependency of the executable");
|
||||
|
@ -1374,8 +1374,8 @@ fn surgery_elf_help(
|
|||
};
|
||||
|
||||
if let Some(target_offset) = target_offset {
|
||||
let virt_base = section_virtual_offset as usize + rel.0 as usize;
|
||||
let base = section_offset as usize + rel.0 as usize;
|
||||
let virt_base = section_virtual_offset + rel.0 as usize;
|
||||
let base = section_offset + rel.0 as usize;
|
||||
let target: i64 = match rel.1.kind() {
|
||||
RelocationKind::Relative | RelocationKind::PltRelative => {
|
||||
target_offset - virt_base as i64 + rel.1.addend()
|
||||
|
@ -1449,14 +1449,14 @@ fn surgery_elf_help(
|
|||
offset += new_section_count * sh_ent_size as usize;
|
||||
let section_headers = load_structs_inplace_mut::<elf::SectionHeader64<LE>>(
|
||||
exec_mmap,
|
||||
new_sh_offset as usize,
|
||||
new_sh_offset,
|
||||
sh_num as usize + new_section_count,
|
||||
);
|
||||
|
||||
let new_rodata_section_size = new_text_section_offset as u64 - new_rodata_section_offset as u64;
|
||||
let new_rodata_section_virtual_size =
|
||||
new_text_section_vaddr as u64 - new_rodata_section_vaddr as u64;
|
||||
let new_text_section_vaddr = new_rodata_section_vaddr as u64 + new_rodata_section_size as u64;
|
||||
let new_text_section_vaddr = new_rodata_section_vaddr as u64 + new_rodata_section_size;
|
||||
let new_text_section_size = new_sh_offset as u64 - new_text_section_offset as u64;
|
||||
|
||||
// set the new rodata section header
|
||||
|
@ -1610,7 +1610,7 @@ fn surgery_elf_help(
|
|||
dynsym_offset as usize + *i as usize * mem::size_of::<elf::Sym64<LE>>(),
|
||||
);
|
||||
sym.st_shndx = endian::U16::new(LE, new_text_section_index as u16);
|
||||
sym.st_value = endian::U64::new(LE, func_virt_offset as u64);
|
||||
sym.st_value = endian::U64::new(LE, func_virt_offset);
|
||||
sym.st_size = endian::U64::new(
|
||||
LE,
|
||||
match app_func_size_map.get(func_name) {
|
||||
|
@ -1627,7 +1627,7 @@ fn surgery_elf_help(
|
|||
symtab_offset as usize + *i as usize * mem::size_of::<elf::Sym64<LE>>(),
|
||||
);
|
||||
sym.st_shndx = endian::U16::new(LE, new_text_section_index as u16);
|
||||
sym.st_value = endian::U64::new(LE, func_virt_offset as u64);
|
||||
sym.st_value = endian::U64::new(LE, func_virt_offset);
|
||||
sym.st_size = endian::U64::new(
|
||||
LE,
|
||||
match app_func_size_map.get(func_name) {
|
||||
|
@ -1812,7 +1812,7 @@ mod tests {
|
|||
false,
|
||||
);
|
||||
|
||||
std::fs::copy(&preprocessed_host_filename, &dir.join("final")).unwrap();
|
||||
std::fs::copy(&preprocessed_host_filename, dir.join("final")).unwrap();
|
||||
|
||||
surgery_elf(
|
||||
&roc_app,
|
||||
|
@ -1833,7 +1833,7 @@ mod tests {
|
|||
|
||||
zig_host_app_help(dir, &Triple::from_str("x86_64-unknown-linux-musl").unwrap());
|
||||
|
||||
let output = std::process::Command::new(&dir.join("final"))
|
||||
let output = std::process::Command::new(dir.join("final"))
|
||||
.current_dir(dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
|
|
@ -255,7 +255,7 @@ fn generate_dynamic_lib(target: &Triple, stub_dll_symbols: &[String], stub_lib_p
|
|||
let bytes = crate::generate_dylib::generate(target, stub_dll_symbols)
|
||||
.unwrap_or_else(|e| internal_error!("{e}"));
|
||||
|
||||
if let Err(e) = std::fs::write(stub_lib_path, &bytes) {
|
||||
if let Err(e) = std::fs::write(stub_lib_path, bytes) {
|
||||
internal_error!("failed to write stub lib to {:?}: {e}", stub_lib_path)
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ fn generate_import_library(stub_lib_path: &Path, custom_names: &[String]) {
|
|||
// For when we want to do this in-memory in the future. We can also consider using
|
||||
//
|
||||
// > 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())
|
||||
.args([
|
||||
"dlltool",
|
||||
|
|
|
@ -67,7 +67,7 @@ fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap<St
|
|||
.next()
|
||||
.unwrap();
|
||||
|
||||
let address = sym.address() as u64;
|
||||
let address = sym.address();
|
||||
|
||||
// special exceptions for memcpy and memset.
|
||||
if name == "roc_memcpy" {
|
||||
|
@ -705,19 +705,19 @@ fn gen_macho_le(
|
|||
// Instead, its file size should be increased.
|
||||
if old_file_offest > 0 {
|
||||
cmd.fileoff
|
||||
.set(LittleEndian, old_file_offest + md.added_byte_count as u64);
|
||||
.set(LittleEndian, old_file_offest + md.added_byte_count);
|
||||
cmd.vmaddr.set(
|
||||
LittleEndian,
|
||||
cmd.vmaddr.get(NativeEndian) + md.added_byte_count as u64,
|
||||
cmd.vmaddr.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
} else {
|
||||
cmd.filesize.set(
|
||||
LittleEndian,
|
||||
cmd.filesize.get(NativeEndian) + md.added_byte_count as u64,
|
||||
cmd.filesize.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
cmd.vmsize.set(
|
||||
LittleEndian,
|
||||
cmd.vmsize.get(NativeEndian) + md.added_byte_count as u64,
|
||||
cmd.vmsize.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ fn gen_macho_le(
|
|||
if entry_type == macho::N_ABS || entry_type == macho::N_SECT {
|
||||
entry.n_value.set(
|
||||
LittleEndian,
|
||||
entry.n_value.get(NativeEndian) + md.added_byte_count as u64,
|
||||
entry.n_value.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ fn gen_macho_le(
|
|||
|
||||
cmd.entryoff.set(
|
||||
LittleEndian,
|
||||
cmd.entryoff.get(NativeEndian) + md.added_byte_count as u64,
|
||||
cmd.entryoff.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
}
|
||||
macho::LC_NOTE => {
|
||||
|
@ -1058,7 +1058,7 @@ fn gen_macho_le(
|
|||
if cmd.size.get(NativeEndian) > 0 {
|
||||
cmd.offset.set(
|
||||
LittleEndian,
|
||||
cmd.offset.get(NativeEndian) + md.added_byte_count as u64,
|
||||
cmd.offset.get(NativeEndian) + md.added_byte_count,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1397,8 +1397,8 @@ fn surgery_macho_help(
|
|||
};
|
||||
|
||||
if let Some(target_offset) = target_offset {
|
||||
let virt_base = section_virtual_offset as usize + rel.0 as usize;
|
||||
let base = section_offset as usize + rel.0 as usize;
|
||||
let virt_base = section_virtual_offset + rel.0 as usize;
|
||||
let base = section_offset + rel.0 as usize;
|
||||
let target: i64 = match rel.1.kind() {
|
||||
RelocationKind::Relative | RelocationKind::PltRelative => {
|
||||
target_offset - virt_base as i64 + rel.1.addend()
|
||||
|
|
|
@ -307,7 +307,7 @@ pub(crate) fn surgery_pe(executable_path: &Path, metadata_path: &Path, roc_app_b
|
|||
let app_code_section_va = md.last_host_section_address
|
||||
+ next_multiple_of(
|
||||
md.last_host_section_size as usize,
|
||||
section_alignment as usize,
|
||||
section_alignment,
|
||||
) as u64;
|
||||
|
||||
let mut section_file_offset = md.dynhost_file_size;
|
||||
|
@ -470,9 +470,9 @@ pub(crate) fn surgery_pe(executable_path: &Path, metadata_path: &Path, roc_app_b
|
|||
update_optional_header(
|
||||
executable,
|
||||
md.optional_header_offset,
|
||||
code_bytes_added as u32,
|
||||
file_bytes_added as u32,
|
||||
data_bytes_added as u32,
|
||||
code_bytes_added,
|
||||
file_bytes_added,
|
||||
data_bytes_added,
|
||||
);
|
||||
|
||||
let symbols: Vec<_> = symbols
|
||||
|
@ -707,7 +707,7 @@ impl Preprocessor {
|
|||
|
||||
Self {
|
||||
extra_sections_start: section_table_offset as usize
|
||||
+ sections.len() as usize * Self::SECTION_HEADER_WIDTH,
|
||||
+ sections.len() * Self::SECTION_HEADER_WIDTH,
|
||||
extra_sections_width,
|
||||
additional_header_space,
|
||||
additional_reloc_space,
|
||||
|
@ -1724,7 +1724,7 @@ mod test {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
std::fs::copy(&preprocessed_host_filename, &dir.join("app.exe")).unwrap();
|
||||
std::fs::copy(&preprocessed_host_filename, dir.join("app.exe")).unwrap();
|
||||
|
||||
surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app);
|
||||
}
|
||||
|
@ -1739,7 +1739,7 @@ mod test {
|
|||
|
||||
runner(dir);
|
||||
|
||||
let output = std::process::Command::new(&dir.join("app.exe"))
|
||||
let output = std::process::Command::new(dir.join("app.exe"))
|
||||
.current_dir(dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
@ -1908,7 +1908,7 @@ mod test {
|
|||
|
||||
std::fs::write(dir.join("host.zig"), host_zig.as_bytes()).unwrap();
|
||||
|
||||
let mut command = std::process::Command::new(&zig);
|
||||
let mut command = std::process::Command::new(zig);
|
||||
command.current_dir(dir).args([
|
||||
"build-exe",
|
||||
"host.zig",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue