1111#![ allow( unsafe_code) ]
1212#![ allow( clippy:: allow_attributes_without_reason) ]
1313
14+ #[ cfg( all( feature = "async-runtime" , feature = "async-raw" ) ) ]
15+ compile_error ! ( "cannot enable both `async-runtime` and `async-raw` features" ) ;
16+
1417use std:: alloc:: Layout ;
1518use std:: ptr;
1619
@@ -372,17 +375,17 @@ pub trait Interpreter: 'static {
372375
373376 fn export_call ( wit : Wit , func : ExportFunction , cx : & mut Self :: CallCx < ' _ > ) ;
374377
375- #[ cfg( feature = "async" ) ]
378+ #[ cfg( feature = "async-runtime " ) ]
376379 fn export_call_async (
377380 wit : Wit ,
378381 func : ExportFunction ,
379382 cx : Box < Self :: CallCx < ' static > > ,
380383 ) -> impl std:: future:: Future < Output = ( ) > ;
381384
382- #[ cfg( not ( feature = "async" ) ) ]
385+ #[ cfg( feature = "async-raw" ) ]
383386 fn export_async_start ( wit : Wit , func : ExportFunction , cx : Box < Self :: CallCx < ' static > > ) -> u32 ;
384387
385- #[ cfg( not ( feature = "async" ) ) ]
388+ #[ cfg( feature = "async-raw" ) ]
386389 fn export_async_callback ( event0 : u32 , event1 : u32 , event2 : u32 ) -> u32 ;
387390
388391 fn export_finish ( cx : Box < Self :: CallCx < ' _ > > , func : ExportFunction ) {
@@ -529,7 +532,7 @@ pub trait RawInterpreter: Interpreter {
529532 unsafe {
530533 let wit = Wit :: from_raw ( WIT_T ) ;
531534 let func = wit. export_func ( which) ;
532- #[ cfg( feature = "async" ) ]
535+ #[ cfg( feature = "async-runtime " ) ]
533536 {
534537 wit_bindgen:: rt:: async_support:: start_task ( Self :: export_call_async (
535538 wit,
@@ -538,21 +541,32 @@ pub trait RawInterpreter: Interpreter {
538541 ) )
539542 . cast_unsigned ( )
540543 }
541- #[ cfg( not ( feature = "async" ) ) ]
544+ #[ cfg( feature = "async-raw" ) ]
542545 {
543546 Self :: export_async_start ( wit, func, Box :: from_raw ( cx. cast ( ) ) )
544547 }
548+ #[ cfg( not( any( feature = "async-runtime" , feature = "async-raw" ) ) ) ]
549+ {
550+ _ = func;
551+ panic ! ( "no async features enabled" )
552+ }
545553 }
546554 }
547555
548556 unsafe fn raw_export_async_callback ( a : u32 , b : u32 , c : u32 , which : usize ) -> u32 {
549557 debug_println ! ( "export_async_callback({a:#x}, {b:#x}, {c:#x}, {which})" ) ;
550- #[ cfg( feature = "async" ) ]
558+ #[ cfg( feature = "async-runtime " ) ]
551559 unsafe {
552560 wit_bindgen:: rt:: async_support:: callback ( a, b, c)
553561 }
554- #[ cfg( not( feature = "async" ) ) ]
555- Self :: export_async_callback ( a, b, c)
562+ #[ cfg( feature = "async-raw" ) ]
563+ {
564+ Self :: export_async_callback ( a, b, c)
565+ }
566+ #[ cfg( not( any( feature = "async-runtime" , feature = "async-raw" ) ) ) ]
567+ {
568+ panic ! ( "no async features enabled" )
569+ }
556570 }
557571
558572 unsafe fn raw_export_finish ( cx : * mut u8 , which : usize ) {
0 commit comments