From 5f865a4a0c6c6887c6750868763a1fc01a701339 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 28 Feb 2022 18:18:41 +0100 Subject: [PATCH] fmt --- ast/src/mem_pool/pool.rs | 22 +++++++++++++--------- cli_utils/src/bench_utils.rs | 8 ++------ compiler/build/src/target.rs | 2 +- compiler/can/src/annotation.rs | 3 +-- linker/src/lib.rs | 24 ++++++------------------ roc_std/src/lib.rs | 15 +++++++++------ 6 files changed, 32 insertions(+), 42 deletions(-) diff --git a/ast/src/mem_pool/pool.rs b/ast/src/mem_pool/pool.rs index ec55b04315..e28dbc33bd 100644 --- a/ast/src/mem_pool/pool.rs +++ b/ast/src/mem_pool/pool.rs @@ -106,7 +106,8 @@ impl Pool { // addresses from the OS which will be lazily translated into // physical memory one 4096-byte page at a time, once we actually // try to read or write in that page's address range. - #[cfg(unix)]{ + #[cfg(unix)] + { use libc::{MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE}; libc::mmap( @@ -118,10 +119,11 @@ impl Pool { 0, ) } - #[cfg(windows)]{ - use winapi::um::memoryapi::{VirtualAlloc}; + #[cfg(windows)] + { + use winapi::um::memoryapi::VirtualAlloc; + use winapi::um::winnt::PAGE_READWRITE; use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE}; - use winapi::um::winnt::{PAGE_READWRITE}; VirtualAlloc( std::ptr::null_mut(), @@ -244,20 +246,22 @@ impl std::ops::IndexMut> for Pool { impl Drop for Pool { fn drop(&mut self) { unsafe { - #[cfg(unix)]{ + #[cfg(unix)] + { libc::munmap( self.nodes as *mut c_void, NODE_BYTES * self.capacity as usize, ); } - #[cfg(windows)]{ - use winapi::um::memoryapi::{VirtualFree}; - use winapi::um::winnt::{MEM_RELEASE}; + #[cfg(windows)] + { + use winapi::um::memoryapi::VirtualFree; + use winapi::um::winnt::MEM_RELEASE; VirtualFree( self.nodes as *mut c_void, NODE_BYTES * self.capacity as usize, - MEM_RELEASE + MEM_RELEASE, ); } } diff --git a/cli_utils/src/bench_utils.rs b/cli_utils/src/bench_utils.rs index 762970052e..bb46698602 100644 --- a/cli_utils/src/bench_utils.rs +++ b/cli_utils/src/bench_utils.rs @@ -42,12 +42,10 @@ fn check_cmd_output( .unwrap() .to_string(); - let out= if cmd_str.contains("cfold") { + let out = if cmd_str.contains("cfold") { let child = thread::Builder::new() .stack_size(CFOLD_STACK_SIZE) - .spawn( - move|| {run_cmd(&cmd_str, &[stdin_str], &[])} - ) + .spawn(move || run_cmd(&cmd_str, &[stdin_str], &[])) .unwrap(); child.join().unwrap() @@ -55,7 +53,6 @@ fn check_cmd_output( run_cmd(&cmd_str, &[stdin_str], &[]) }; - if !&out.stdout.ends_with(expected_ending) { panic!( "expected output to end with {:?} but instead got {:#?}", @@ -103,7 +100,6 @@ fn bench_cmd( } } - pub fn bench_nqueens(bench_group_opt: Option<&mut BenchmarkGroup>) { exec_bench_w_input( &example_file("benchmarks", "NQueens.roc"), diff --git a/compiler/build/src/target.rs b/compiler/build/src/target.rs index be854c74bb..92dfed1c8e 100644 --- a/compiler/build/src/target.rs +++ b/compiler/build/src/target.rs @@ -45,7 +45,7 @@ pub fn target_triple_str(target: &Triple) -> &'static str { architecture: Architecture::X86_64, operating_system: OperatingSystem::Windows, .. - }=> "x86_64-pc-windows-gnu", + } => "x86_64-pc-windows-gnu", _ => panic!("TODO gracefully handle unsupported target: {:?}", target), } } diff --git a/compiler/can/src/annotation.rs b/compiler/can/src/annotation.rs index 8d3febe818..a2a32e3120 100644 --- a/compiler/can/src/annotation.rs +++ b/compiler/can/src/annotation.rs @@ -383,8 +383,7 @@ fn can_annotation_help( As( loc_inner, _spaces, - alias_header - @ TypeHeader { + alias_header @ TypeHeader { name, vars: loc_vars, }, diff --git a/linker/src/lib.rs b/linker/src/lib.rs index e7abf8fe35..9dc6d76caa 100644 --- a/linker/src/lib.rs +++ b/linker/src/lib.rs @@ -366,9 +366,7 @@ fn preprocess_impl( Some(section) => { let file_offset = match section.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, @@ -493,9 +491,7 @@ fn preprocess_impl( for sec in text_sections { let (file_offset, compressed) = match sec.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, @@ -625,9 +621,7 @@ fn preprocess_impl( }; let dyn_offset = match dyn_sec.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, @@ -713,9 +707,7 @@ fn preprocess_impl( }; let symtab_offset = match symtab_sec.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, @@ -737,9 +729,7 @@ fn preprocess_impl( }; let dynsym_offset = match dynsym_sec.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, @@ -758,9 +748,7 @@ fn preprocess_impl( { match sec.compressed_file_range() { Ok( - range - @ - CompressedFileRange { + range @ CompressedFileRange { format: CompressionFormat::None, .. }, diff --git a/roc_std/src/lib.rs b/roc_std/src/lib.rs index b4c4066457..98e70384b1 100644 --- a/roc_std/src/lib.rs +++ b/roc_std/src/lib.rs @@ -12,7 +12,6 @@ mod roc_str; pub use roc_list::RocList; pub use roc_str::RocStr; - // A list of C functions that are being imported #[cfg(not(windows))] extern "C" { @@ -29,18 +28,22 @@ extern "C" { #[cfg(windows)] const ERR_MSG: &str = "should not be called from within the repo. If you got this while running a roc app, the linker should have filled this function in, but it did not happen."; #[cfg(windows)] -pub fn roc_alloc(_size: usize, _alignment: u32) -> *mut c_void {panic!("roc_alloc {}", ERR_MSG)} +pub fn roc_alloc(_size: usize, _alignment: u32) -> *mut c_void { + panic!("roc_alloc {}", ERR_MSG) +} #[cfg(windows)] pub fn roc_realloc( _ptr: *mut c_void, _new_size: usize, _old_size: usize, _alignment: u32, -) -> *mut c_void {panic!("roc_realloc {}", ERR_MSG)} +) -> *mut c_void { + panic!("roc_realloc {}", ERR_MSG) +} #[cfg(windows)] -pub fn roc_dealloc(_ptr: *mut c_void, _alignment: u32) {panic!("roc_dealloc {}", ERR_MSG)} - - +pub fn roc_dealloc(_ptr: *mut c_void, _alignment: u32) { + panic!("roc_dealloc {}", ERR_MSG) +} const REFCOUNT_1: isize = isize::MIN;