Skip to content

Commit d0a5599

Browse files
ifsheldondicej
andauthored
Remove async-trait in bindgen (bytecodealliance#9867)
* use trait_variant and async-func-in-trait instead of async-trait * remove all async_trait::async_trait related to bindgen! proc_macro * remove pub use async_trait::async_trait in __internal * bless `component-macro` tests to reflect `async_trait` removal Signed-off-by: Joel Dice <joel.dice@fermyon.com> * add `trait-variant` exemption to supply-chain/config.toml This exempts the `trait-variant` crate from vetting since it is published and maintained by the rust-lang organization and is officially recommended by the Rust project. Signed-off-by: Joel Dice <joel.dice@fermyon.com> --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Joel Dice <joel.dice@fermyon.com>
1 parent 4da801c commit d0a5599

File tree

76 files changed

+157
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+157
-253
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ humantime = { workspace = true }
7373
tempfile = { workspace = true, optional = true }
7474

7575
async-trait = { workspace = true }
76+
trait-variant = { workspace = true }
7677
bytes = { workspace = true }
7778
cfg-if = { workspace = true }
7879
tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] }
@@ -96,6 +97,7 @@ criterion = { workspace = true }
9697
num_cpus = "1.13.0"
9798
memchr = "2.4"
9899
async-trait = { workspace = true }
100+
trait-variant = { workspace = true }
99101
wat = { workspace = true }
100102
rayon = "1.5.0"
101103
wasmtime-wast = { workspace = true, features = ['component-model'] }
@@ -313,6 +315,7 @@ tracing = "0.1.26"
313315
bitflags = "2.0"
314316
thiserror = "1.0.43"
315317
async-trait = "0.1.71"
318+
trait-variant = "0.1.2"
316319
heck = "0.5"
317320
similar = "2.1.0"
318321
toml = "0.8.10"

crates/component-macro/tests/expanded/char_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub mod foo {
193193
pub mod chars {
194194
#[allow(unused_imports)]
195195
use wasmtime::component::__internal::anyhow;
196-
#[wasmtime::component::__internal::async_trait]
196+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
197197
pub trait Host: Send {
198198
/// A function that accepts a character
199199
async fn take_char(&mut self, x: char) -> ();
@@ -255,7 +255,6 @@ pub mod foo {
255255
{
256256
add_to_linker_get_host(linker, get)
257257
}
258-
#[wasmtime::component::__internal::async_trait]
259258
impl<_T: Host + ?Sized + Send> Host for &mut _T {
260259
/// A function that accepts a character
261260
async fn take_char(&mut self, x: char) -> () {

crates/component-macro/tests/expanded/char_tracing_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub mod foo {
193193
pub mod chars {
194194
#[allow(unused_imports)]
195195
use wasmtime::component::__internal::anyhow;
196-
#[wasmtime::component::__internal::async_trait]
196+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
197197
pub trait Host: Send {
198198
/// A function that accepts a character
199199
async fn take_char(&mut self, x: char) -> ();
@@ -284,7 +284,6 @@ pub mod foo {
284284
{
285285
add_to_linker_get_host(linker, get)
286286
}
287-
#[wasmtime::component::__internal::async_trait]
288287
impl<_T: Host + ?Sized + Send> Host for &mut _T {
289288
/// A function that accepts a character
290289
async fn take_char(&mut self, x: char) -> () {

crates/component-macro/tests/expanded/conventions_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub mod foo {
227227
>::ALIGN32
228228
);
229229
};
230-
#[wasmtime::component::__internal::async_trait]
230+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
231231
pub trait Host: Send {
232232
async fn kebab_case(&mut self) -> ();
233233
async fn foo(&mut self, x: LudicrousSpeed) -> ();
@@ -403,7 +403,6 @@ pub mod foo {
403403
{
404404
add_to_linker_get_host(linker, get)
405405
}
406-
#[wasmtime::component::__internal::async_trait]
407406
impl<_T: Host + ?Sized + Send> Host for &mut _T {
408407
async fn kebab_case(&mut self) -> () {
409408
Host::kebab_case(*self).await

crates/component-macro/tests/expanded/conventions_tracing_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub mod foo {
227227
>::ALIGN32
228228
);
229229
};
230-
#[wasmtime::component::__internal::async_trait]
230+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
231231
pub trait Host: Send {
232232
async fn kebab_case(&mut self) -> ();
233233
async fn foo(&mut self, x: LudicrousSpeed) -> ();
@@ -563,7 +563,6 @@ pub mod foo {
563563
{
564564
add_to_linker_get_host(linker, get)
565565
}
566-
#[wasmtime::component::__internal::async_trait]
567566
impl<_T: Host + ?Sized + Send> Host for &mut _T {
568567
async fn kebab_case(&mut self) -> () {
569568
Host::kebab_case(*self).await

crates/component-macro/tests/expanded/dead-code_async.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub mod a {
202202
4 == < LiveType as wasmtime::component::ComponentType >::ALIGN32
203203
);
204204
};
205-
#[wasmtime::component::__internal::async_trait]
205+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
206206
pub trait Host: Send {
207207
async fn f(&mut self) -> LiveType;
208208
}
@@ -248,7 +248,6 @@ pub mod a {
248248
{
249249
add_to_linker_get_host(linker, get)
250250
}
251-
#[wasmtime::component::__internal::async_trait]
252251
impl<_T: Host + ?Sized + Send> Host for &mut _T {
253252
async fn f(&mut self) -> LiveType {
254253
Host::f(*self).await
@@ -259,7 +258,7 @@ pub mod a {
259258
pub mod interface_with_dead_type {
260259
#[allow(unused_imports)]
261260
use wasmtime::component::__internal::anyhow;
262-
#[wasmtime::component::__internal::async_trait]
261+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
263262
pub trait Host: Send {}
264263
pub trait GetHost<
265264
T,
@@ -293,7 +292,6 @@ pub mod a {
293292
{
294293
add_to_linker_get_host(linker, get)
295294
}
296-
#[wasmtime::component::__internal::async_trait]
297295
impl<_T: Host + ?Sized + Send> Host for &mut _T {}
298296
}
299297
}

crates/component-macro/tests/expanded/dead-code_tracing_async.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub mod a {
202202
4 == < LiveType as wasmtime::component::ComponentType >::ALIGN32
203203
);
204204
};
205-
#[wasmtime::component::__internal::async_trait]
205+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
206206
pub trait Host: Send {
207207
async fn f(&mut self) -> LiveType;
208208
}
@@ -261,7 +261,6 @@ pub mod a {
261261
{
262262
add_to_linker_get_host(linker, get)
263263
}
264-
#[wasmtime::component::__internal::async_trait]
265264
impl<_T: Host + ?Sized + Send> Host for &mut _T {
266265
async fn f(&mut self) -> LiveType {
267266
Host::f(*self).await
@@ -272,7 +271,7 @@ pub mod a {
272271
pub mod interface_with_dead_type {
273272
#[allow(unused_imports)]
274273
use wasmtime::component::__internal::anyhow;
275-
#[wasmtime::component::__internal::async_trait]
274+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
276275
pub trait Host: Send {}
277276
pub trait GetHost<
278277
T,
@@ -306,7 +305,6 @@ pub mod a {
306305
{
307306
add_to_linker_get_host(linker, get)
308307
}
309-
#[wasmtime::component::__internal::async_trait]
310308
impl<_T: Host + ?Sized + Send> Host for &mut _T {}
311309
}
312310
}

crates/component-macro/tests/expanded/direct-import_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct FooIndices {}
9595
/// [`Component`]: wasmtime::component::Component
9696
/// [`Linker`]: wasmtime::component::Linker
9797
pub struct Foo {}
98-
#[wasmtime::component::__internal::async_trait]
98+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
9999
pub trait FooImports: Send {
100100
async fn foo(&mut self) -> ();
101101
}
@@ -111,7 +111,6 @@ where
111111
{
112112
type Host = O;
113113
}
114-
#[wasmtime::component::__internal::async_trait]
115114
impl<_T: FooImports + ?Sized + Send> FooImports for &mut _T {
116115
async fn foo(&mut self) -> () {
117116
FooImports::foo(*self).await

crates/component-macro/tests/expanded/direct-import_tracing_async.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct FooIndices {}
9595
/// [`Component`]: wasmtime::component::Component
9696
/// [`Linker`]: wasmtime::component::Linker
9797
pub struct Foo {}
98-
#[wasmtime::component::__internal::async_trait]
98+
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
9999
pub trait FooImports: Send {
100100
async fn foo(&mut self) -> ();
101101
}
@@ -111,7 +111,6 @@ where
111111
{
112112
type Host = O;
113113
}
114-
#[wasmtime::component::__internal::async_trait]
115114
impl<_T: FooImports + ?Sized + Send> FooImports for &mut _T {
116115
async fn foo(&mut self) -> () {
117116
FooImports::foo(*self).await

0 commit comments

Comments
 (0)