11use crate :: bindgen:: { FunctionBindgen , POINTER_SIZE_EXPRESSION } ;
22use crate :: {
3- full_wit_type_name, int_repr, to_rust_ident, to_upper_camel_case, wasm_type, FnSig , Identifier ,
4- InterfaceName , Ownership , RuntimeItem , RustFlagsRepr , RustWasm , TypeGeneration , WasmType ,
3+ FnSig , Identifier , InterfaceName , Ownership , RuntimeItem , RustFlagsRepr , RustWasm ,
4+ TypeGeneration , WasmType , full_wit_type_name, int_repr, to_rust_ident, to_upper_camel_case,
5+ wasm_type,
56} ;
67use anyhow:: Result ;
78use heck:: * ;
@@ -10,7 +11,7 @@ use std::fmt::Write as _;
1011use std:: mem;
1112use wit_bindgen_core:: abi:: { self , AbiVariant , LiftLower } ;
1213use wit_bindgen_core:: {
13- dealias, uwrite, uwriteln, wit_parser:: * , AnonymousTypeGenerator , Source , TypeInfo ,
14+ AnonymousTypeGenerator , Source , TypeInfo , dealias, uwrite, uwriteln, wit_parser:: * ,
1415} ;
1516
1617pub struct InterfaceGenerator < ' a > {
@@ -674,7 +675,7 @@ macro_rules! {macro_name} {{
674675 lift_read = self . lift_from_memory ( "src" , & payload_type, & module) ;
675676 start_read_sig = "fn future_read(_: u32, _: *mut u8) -> u32" . to_owned ( ) ;
676677 start_read = "unsafe extern \" C\" fn start_read(future: u32, dst: *mut u8) \
677- -> u32 { future_read(future, dst) }"
678+ -> u32 { unsafe { future_read(future, dst) } }"
678679 . to_owned ( ) ;
679680 if sig. indirect_params {
680681 lift_write = self . lift_from_memory (
@@ -686,7 +687,7 @@ macro_rules! {macro_name} {{
686687 lower = format ! (
687688 r#"
688689 let (ptr, cleanup) = {runtime}::Cleanup::new(
689- ::std::alloc::Layout::from_size_align_unchecked({size}, {align})
690+ unsafe {{ ::std::alloc::Layout::from_size_align_unchecked({size}, {align}) }}
690691 );
691692 {body}
692693 dst[0] = {async_support}::CoreVal {{ as_i32: ptr as isize as i32 }};
@@ -696,7 +697,7 @@ macro_rules! {macro_name} {{
696697 start_write_sig = "fn future_write(_: u32, _: *const u8) -> u32" . to_owned ( ) ;
697698 start_write = format ! (
698699 "unsafe extern \" C\" fn start_write(future: u32, src: &{async_support}::LoweredWrite) \
699- -> u32 {{ future_write(future, src[0].as_i32 as isize as *const u8) }}"
700+ -> u32 {{ unsafe {{ future_write(future, src[0].as_i32 as isize as *const u8) }} }}"
700701 ) ;
701702 } else {
702703 lift_write = self . lift_flat (
@@ -738,7 +739,7 @@ macro_rules! {macro_name} {{
738739 . join ( ", " ) ;
739740 start_write = format ! (
740741 "unsafe extern \" C\" fn start_write(future: u32, src: &{async_support}::LoweredWrite) \
741- -> u32 {{ future_write(future, {args}) }}"
742+ -> u32 {{ unsafe {{ future_write(future, {args}) }} }}"
742743 ) ;
743744 }
744745 } else {
@@ -749,11 +750,12 @@ macro_rules! {macro_name} {{
749750 start_read_sig = format ! ( "fn future_read(_: u32) -> u32" ) ;
750751 start_write_sig = format ! ( "fn future_write(_: u32) -> u32" ) ;
751752 start_read = format ! (
752- "unsafe extern \" C\" fn start_read(future: u32, _: *mut u8) -> u32 {{ future_read(future) }}"
753+ "unsafe extern \" C\" fn start_read(future: u32, _: *mut u8) \
754+ -> u32 {{ unsafe {{ future_read(future) }} }}"
753755 ) ;
754756 start_write = format ! (
755757 "unsafe extern \" C\" fn start_write(future: u32, _: &{async_support}::LoweredWrite) \
756- -> u32 {{ future_write(future) }}"
758+ -> u32 {{ unsafe {{ future_write(future) }} }}"
757759 ) ;
758760 }
759761
0 commit comments