@@ -26,7 +26,7 @@ use std::ops::{Deref, DerefMut};
2626use std:: ptr:: { self , NonNull } ;
2727use std:: sync:: Arc ;
2828
29- pub const LUCET_INSTANCE_MAGIC : u64 = 746932922 ;
29+ pub const LUCET_INSTANCE_MAGIC : u64 = 746_932_922 ;
3030
3131thread_local ! {
3232 /// The host context.
@@ -79,7 +79,7 @@ pub fn new_instance_handle(
7979 embed_ctx : CtxMap ,
8080) -> Result < InstanceHandle , Error > {
8181 let inst = NonNull :: new ( instance)
82- . ok_or ( lucet_format_err ! ( "instance pointer is null; this is a bug" ) ) ?;
82+ . ok_or_else ( || lucet_format_err ! ( "instance pointer is null; this is a bug" ) ) ?;
8383
8484 lucet_ensure ! (
8585 unsafe { inst. as_ref( ) . magic } != LUCET_INSTANCE_MAGIC ,
@@ -564,12 +564,9 @@ impl Instance {
564564 ///
565565 /// On success, returns the number of pages that existed before the call.
566566 pub fn grow_memory ( & mut self , additional_pages : u32 ) -> Result < u32 , Error > {
567- let additional_bytes =
568- additional_pages
569- . checked_mul ( WASM_PAGE_SIZE )
570- . ok_or ( lucet_format_err ! (
571- "additional pages larger than wasm address space" ,
572- ) ) ?;
567+ let additional_bytes = additional_pages
568+ . checked_mul ( WASM_PAGE_SIZE )
569+ . ok_or_else ( || lucet_format_err ! ( "additional pages larger than wasm address space" , ) ) ?;
573570 let orig_len = self
574571 . alloc
575572 . expand_heap ( additional_bytes, self . module . as_ref ( ) ) ?;
@@ -750,7 +747,7 @@ impl Instance {
750747
751748 let mut inst = Instance {
752749 magic : LUCET_INSTANCE_MAGIC ,
753- embed_ctx : embed_ctx ,
750+ embed_ctx,
754751 module,
755752 ctx : Context :: new ( ) ,
756753 state : State :: Ready ,
@@ -976,8 +973,9 @@ impl Instance {
976973 // handler.
977974
978975 // Run the C-style fatal handler, if it exists.
979- self . c_fatal_handler
980- . map ( |h| unsafe { h ( self as * mut Instance ) } ) ;
976+ if let Some ( h) = self . c_fatal_handler {
977+ unsafe { h ( self as * mut Instance ) }
978+ }
981979
982980 // If there is no C-style fatal handler, or if it (erroneously) returns,
983981 // call the Rust handler that we know will not return
0 commit comments