Skip to content

Commit 3b57217

Browse files
committed
minimize use of features based on PR feedback
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 700700b commit 3b57217

File tree

13 files changed

+9
-47
lines changed

13 files changed

+9
-47
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ go = ['dep:wit-bindgen-go']
8585
csharp = ['dep:wit-bindgen-csharp']
8686
csharp-mono = ['csharp']
8787
moonbit = ['dep:wit-bindgen-moonbit']
88-
async = ["wit-bindgen-rust/async"]
88+
async = []
8989

9090
[dev-dependencies]
9191
heck = { workspace = true }

crates/core/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ doctest = false
1818
wit-parser = { workspace = true }
1919
anyhow = { workspace = true }
2020
heck = { workspace = true }
21-
22-
[features]
23-
default = ["async"]
24-
async = []

crates/core/src/abi.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,6 @@ pub fn call(
753753
bindgen: &mut impl Bindgen,
754754
async_: bool,
755755
) {
756-
if async_ && !cfg!(feature = "async") {
757-
panic!("must enable `async` feature to lift or lower using the async ABI");
758-
}
759-
760756
Generator::new(resolve, variant, lift_lower, bindgen, async_).call(func);
761757
}
762758

crates/core/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ pub enum Direction {
2222

2323
pub trait WorldGenerator {
2424
fn generate(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) -> Result<()> {
25-
// TODO: Should we refine this test to inspect only types reachable from
26-
// the specified world?
27-
if !cfg!(feature = "async")
28-
&& resolve.types.iter().any(|(_, ty)| {
29-
matches!(
30-
ty.kind,
31-
TypeDefKind::Future(_) | TypeDefKind::Stream(_) | TypeDefKind::ErrorContext
32-
)
33-
})
34-
{
35-
anyhow::bail!(
36-
"must enable `async` feature when using WIT files \
37-
containing future, stream, or error types"
38-
);
39-
}
40-
4125
let world = &resolve.worlds[id];
4226
self.preprocess(resolve, id);
4327

crates/guest-rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ wit-bindgen-rt = { path = "./rt", version = "0.36.0", features = ["bitflags"] }
1919
default = ["macros", "realloc", "async"]
2020
macros = ["dep:wit-bindgen-rust-macro"]
2121
realloc = []
22-
async = ["macros", "wit-bindgen-rt/async", "wit-bindgen-rust-macro/async"]
22+
async = ["macros", "wit-bindgen-rt/async"]

crates/guest-rust/macro/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ syn = { workspace = true }
2525
prettyplease = { workspace = true }
2626

2727
[features]
28-
default = ["async"]
29-
async = ["wit-bindgen-rust/async"]
28+
async = []

crates/guest-rust/macro/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ impl Parse for Config {
151151
return Err(Error::new(span, "cannot specify second async config"));
152152
}
153153
async_configured = true;
154-
if !matches!(val, AsyncConfig::None) && !cfg!(feature = "async") {
155-
return Err(Error::new(
156-
span,
157-
"must enable `async` feature to enable async imports and/or exports",
158-
));
159-
}
160154
opts.async_ = val;
161155
}
162156
}

crates/guest-rust/rt/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ futures = { version = "0.3.30", optional = true }
1616
once_cell = { version = "1.19.0", optional = true }
1717

1818
[features]
19-
default = ["async"]
2019
async = ["dep:futures", "dep:once_cell"]

crates/guest-rust/rt/src/async_support.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![deny(missing_docs)]
22
#![allow(static_mut_refs)]
33

4+
extern crate std;
5+
46
use {
57
futures::{
68
channel::oneshot,
@@ -11,6 +13,7 @@ use {
1113
std::{
1214
alloc::{self, Layout},
1315
any::Any,
16+
boxed::Box,
1417
collections::hash_map,
1518
collections::HashMap,
1619
fmt::{self, Debug, Display},
@@ -19,6 +22,7 @@ use {
1922
ptr,
2023
sync::Arc,
2124
task::{Context, Poll, Wake, Waker},
25+
vec::Vec,
2226
},
2327
};
2428

crates/guest-rust/rt/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(not(feature = "async"), no_std)]
1+
#![no_std]
22

33
extern crate alloc;
44

@@ -113,10 +113,6 @@ pub fn run_ctors_once() {
113113
}
114114
}
115115

116-
/// Support for using the Component Model Async ABI
117-
#[cfg(not(feature = "async"))]
118-
pub mod async_support {}
119-
120116
/// Support for using the Component Model Async ABI
121117
#[cfg(feature = "async")]
122118
pub mod async_support;

0 commit comments

Comments
 (0)