Skip to content

Commit 292b864

Browse files
committed
fix(runtime): fix pluggable_async_example feature gates
Change module-level #![cfg(feature = "async-api")] to item-level #[cfg(feature = "async-api")] attributes to allow the fallback main() function to be visible when the feature is disabled. Previously, the entire module was gated causing the compiler to not see any main() function, resulting in E0601 error. With item-level attributes, the fallback main() on lines 117-121 is now properly visible when async-api feature is not enabled. Fixes: E0601 missing main function error Related: #121
1 parent 2e66788 commit 292b864

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

wrt-runtime/examples/pluggable_async_example.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
//! 2. Working with basic async/await patterns
66
//! 3. Integration patterns for async code
77
8-
#![cfg(feature = "async-api")]
9-
8+
#[cfg(feature = "async-api")]
109
use core::{
1110
future::Future,
1211
marker::Unpin,
@@ -17,29 +16,33 @@ use core::{
1716
},
1817
};
1918

19+
#[cfg(feature = "async-api")]
2020
use wrt_foundation::{
2121
is_using_fallback,
2222
with_async,
2323
AsyncRuntime,
2424
ExecutorError,
2525
};
2626

27-
#[cfg(feature = "std")]
27+
#[cfg(all(feature = "async-api", feature = "std"))]
2828
extern crate alloc;
29-
#[cfg(feature = "std")]
29+
#[cfg(all(feature = "async-api", feature = "std"))]
3030
use std::boxed::Box;
3131

3232
/// Simple async function for testing
33+
#[cfg(feature = "async-api")]
3334
async fn hello_async() -> &'static str {
3435
"Hello from simple async!"
3536
}
3637

3738
/// Example future that is immediately ready
39+
#[cfg(feature = "async-api")]
3840
#[derive(Debug)]
3941
struct ReadyFuture {
4042
value: &'static str,
4143
}
4244

45+
#[cfg(feature = "async-api")]
4346
impl Future for ReadyFuture {
4447
type Output = &'static str;
4548

@@ -48,8 +51,10 @@ impl Future for ReadyFuture {
4851
}
4952
}
5053

54+
#[cfg(feature = "async-api")]
5155
impl Unpin for ReadyFuture {}
5256

57+
#[cfg(feature = "async-api")]
5358
fn main() {
5459
println!("=== Simple Async Executor Example ===\n");
5560

0 commit comments

Comments
 (0)